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@20373115.

Generate fixtures for these test cases for Amsterdam with:

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

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
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
@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

This test generates 2 parametrized test cases across 3 forks.