Skip to content

test_invalid_length_g2msm()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_length_g2msm@892e6d1e.

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_g2msm --fork Amsterdam

Test the BLS12_G2MSM discount gas table in full, by expecting the call to fail for all possible input lengths provided because they are too long or short, or zero length.

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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
@pytest.mark.parametrize_by_fork(
    "precompile_gas_list,precompile_data_length_list",
    get_split_discount_table_by_fork(
        G2_GAS, len(Spec.G2MSM_DISCOUNT_TABLE), G2_MSM_K_INPUT_LENGTH
    ),
)
@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.G2MSM])
def test_invalid_length_g2msm(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """
    Test the BLS12_G2MSM discount gas table in full, by expecting the call to
    fail for all possible input lengths provided because they are too long or
    short, or zero length.

    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 14 parametrized test cases across 3 forks.