Skip to content

test_invalid_multi_inf()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py::test_invalid_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_invalid_multi_inf --fork Prague

Test maximum input given the current environment gas limit for the BLS12_PAIRING precompile and an invalid tail.

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
@pytest.mark.slow
@pytest.mark.parametrize("precompile_gas", [None], ids=[""])
@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""])
def test_invalid_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 and an invalid tail.
    """
    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 = PointG1(Spec.P, 0) + Spec.INF_G2

    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 + input_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--- None 15
...fork_Prague-blockchain_test_from_state_test--- None 15
...fork_Osaka-state_test--- None 15
...fork_Osaka-blockchain_test_from_state_test--- None 15