Skip to content

test_invalid_length_g1msm()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_length_g1msm@26332146.

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

Test the BLS12_G1MSM 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
@pytest.mark.parametrize_by_fork(
    "precompile_gas_list,precompile_data_length_list",
    get_split_discount_table_by_fork(
        G1_GAS, len(Spec.G1MSM_DISCOUNT_TABLE), G1_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.G1MSM])
def test_invalid_length_g1msm(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
) -> None:
    """
    Test the BLS12_G1MSM 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(
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 10 parametrized test cases across 3 forks.