Skip to content

test_invalid_gas_pairing()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_gas_pairing@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_gas_pairing --fork Prague

Test the BLS12_PAIRING precompile, by expecting the call to fail for all possible input lengths (up to k == PAIRINGS_TO_TEST) because the appropriate amount of gas is not provided.

If any of the calls succeeds, the test will fail.

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
@pytest.mark.parametrize(
    "precompile_gas_list,precompile_data_length_list",
    [
        pytest.param(
            [0],
            [Spec.LEN_PER_PAIR],
            id="zero_gas_passed",
        ),
        pytest.param(
            [PAIRING_GAS(i * Spec.LEN_PER_PAIR) - 1 for i in range(1, PAIRINGS_TO_TEST + 1)],
            [i * Spec.LEN_PER_PAIR for i in range(1, PAIRINGS_TO_TEST + 1)],
            id="insufficient_gas",
        ),
    ],
)
@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""])
@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""])
@pytest.mark.parametrize("precompile_address", [Spec.PAIRING])
def test_invalid_gas_pairing(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
):
    """
    Test the BLS12_PAIRING precompile, by expecting the call to fail for all possible input
    lengths (up to k == PAIRINGS_TO_TEST) because the appropriate amount of gas is not provided.

    If any of the calls succeeds, the test will fail.
    """
    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) precompile_address tx_gas_limit expected_output precompile_gas_list precompile_data_length_list
...fork_Prague-state_test-precompile_address_15---zero_gas_passed 15 100000000 [0] [384]
...fork_Prague-state_test-precompile_address_15---insufficient_gas 15 100000000 [70299, 102899, 135499, 168099, 200699, 233299, 265899, 298499, 331099, 363699, 396299, 428899, 461499, 494099, 526699, 559299, 591899, 624499, 657099, 689699] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]
...fork_Prague-blockchain_test_from_state_test-precompile_address_15---zero_gas_passed 15 100000000 [0] [384]
...fork_Prague-blockchain_test_from_state_test-precompile_address_15---insufficient_gas 15 100000000 [70299, 102899, 135499, 168099, 200699, 233299, 265899, 298499, 331099, 363699, 396299, 428899, 461499, 494099, 526699, 559299, 591899, 624499, 657099, 689699] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]
...fork_Osaka-state_test-precompile_address_15---zero_gas_passed 15 100000000 [0] [384]
...fork_Osaka-state_test-precompile_address_15---insufficient_gas 15 100000000 [70299, 102899, 135499, 168099, 200699, 233299, 265899, 298499, 331099, 363699, 396299, 428899, 461499, 494099, 526699, 559299, 591899, 624499, 657099, 689699] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]
...fork_Osaka-blockchain_test_from_state_test-precompile_address_15---zero_gas_passed 15 100000000 [0] [384]
...fork_Osaka-blockchain_test_from_state_test-precompile_address_15---insufficient_gas 15 100000000 [70299, 102899, 135499, 168099, 200699, 233299, 265899, 298499, 331099, 363699, 396299, 428899, 461499, 494099, 526699, 559299, 591899, 624499, 657099, 689699] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]