Skip to content

test_invalid_length_pairing()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_length_pairing@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_length_pairing --fork Osaka

Test the BLS12_PAIRING precompile, by expecting the call to fail for all possible input lengths (up to k == PAIRINGS_TO_TEST) because the incorrect input length was used.

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
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
@pytest.mark.parametrize_by_fork(
    "precompile_gas_list,precompile_data_length_list",
    get_split_discount_table_by_fork(PAIRING_GAS, PAIRINGS_TO_TEST, Spec.LEN_PER_PAIR),
)
@pytest.mark.parametrize(
    "input_length_modifier",
    [
        pytest.param(-1, id="input_one_byte_too_short"),
        pytest.param(1, id="input_one_byte_too_long"),
    ],
)
@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""])
@pytest.mark.parametrize("precompile_address", [Spec.PAIRING])
def test_invalid_length_pairing(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """
    Test the BLS12_PAIRING precompile, by expecting the call to fail for all
    possible input lengths (up to k == PAIRINGS_TO_TEST) because the incorrect
    input length was used.

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

Parametrized Test Cases

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

Test ID (Abbreviated) precompile_gas_list precompile_data_length_list precompile_address expected_output input_length_modifier
...fork_Prague-full_discount_table-state_test-precompile_address_15--input_one_byte_too_short [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 -1
...fork_Prague-full_discount_table-state_test-precompile_address_15--input_one_byte_too_long [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 1
...fork_Prague-full_discount_table-blockchain_test_from_state_test-precompile_address_15--input_one_byte_too_short [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 -1
...fork_Prague-full_discount_table-blockchain_test_from_state_test-precompile_address_15--input_one_byte_too_long [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 1
...fork_Osaka-discount_table_1_of_1-state_test-precompile_address_15--input_one_byte_too_short [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 -1
...fork_Osaka-discount_table_1_of_1-state_test-precompile_address_15--input_one_byte_too_long [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 1
...fork_Osaka-discount_table_1_of_1-blockchain_test_from_state_test-precompile_address_15--input_one_byte_too_short [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 -1
...fork_Osaka-discount_table_1_of_1-blockchain_test_from_state_test-precompile_address_15--input_one_byte_too_long [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680] 15 1