Skip to content

test_valid_multi_inf()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid_multi_inf@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_valid_multi_inf --fork Prague

Test maximum input given the current environment gas limit for the BLS12_PAIRING precompile.

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@pytest.mark.slow
@pytest.mark.parametrize("precompile_gas", [None], ids=[""])
@pytest.mark.parametrize("expected_output", [Spec.PAIRING_TRUE], ids=[""])
def test_valid_multi_inf(
    state_test: StateTestFiller,
    pre: Alloc,
    call_contract_address: Address,
    sender: EOA,
    fork: Fork,
    post: dict,
):
    """
    Test maximum input given the current environment gas limit for the BLS12_PAIRING
    precompile.
    """
    intrinsic_gas_cost_calculator = fork.transaction_intrinsic_cost_calculator()
    memory_expansion_gas_calculator = fork.memory_expansion_gas_calculator()
    extra_gas = 100_000

    environment_gas_limit = Environment().gas_limit

    inf_data = Spec.INF_G1 + Spec.INF_G2
    input_data = inf_data

    while True:
        precompile_gas = pairing_gas(len(input_data + inf_data))
        new_tx_gas_limit = (
            extra_gas
            + intrinsic_gas_cost_calculator(calldata=input_data + inf_data)
            + memory_expansion_gas_calculator(new_bytes=len(input_data + inf_data))
            + precompile_gas
        )
        if new_tx_gas_limit > environment_gas_limit:
            break
        tx_gas_limit = new_tx_gas_limit
        input_data += inf_data

    tx = Transaction(
        gas_limit=tx_gas_limit,
        data=input_data,
        to=call_contract_address,
        sender=sender,
    )
    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated) expected_output precompile_gas precompile_address
...fork_Prague-state_test--- 00000000000000000000000000000000 00000000000000000000000000000001 None 15
...fork_Prague-blockchain_test_from_state_test--- 00000000000000000000000000000000 00000000000000000000000000000001 None 15
...fork_Osaka-state_test--- 00000000000000000000000000000000 00000000000000000000000000000001 None 15
...fork_Osaka-blockchain_test_from_state_test--- 00000000000000000000000000000000 00000000000000000000000000000001 None 15