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@16d4f3bd.

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_length_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 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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
@pytest.mark.parametrize(
    "precompile_gas_list,precompile_data_length_list",
    [
        pytest.param(
            [PAIRING_GAS(Spec.LEN_PER_PAIR)],
            [0],
            id="zero_length",
        ),
        pytest.param(
            [PAIRING_GAS(i * Spec.LEN_PER_PAIR) for i in range(1, PAIRINGS_TO_TEST + 1)],
            [(i * Spec.LEN_PER_PAIR) - 1 for i in range(1, PAIRINGS_TO_TEST + 1)],
            id="input_too_short",
        ),
        pytest.param(
            [PAIRING_GAS(i * Spec.LEN_PER_PAIR) for i in range(1, PAIRINGS_TO_TEST + 1)],
            [(i * Spec.LEN_PER_PAIR) + 1 for i in range(1, PAIRINGS_TO_TEST + 1)],
            id="input_too_long",
        ),
    ],
)
@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_length_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 incorrect input length was used.

    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-blockchain_test-precompile_address_15---zero_length 15 100000000 [70300] [0]
...fork_Prague-blockchain_test-precompile_address_15---input_too_short 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [383, 767, 1151, 1535, 1919, 2303, 2687, 3071, 3455, 3839, 4223, 4607, 4991, 5375, 5759, 6143, 6527, 6911, 7295, 7679]
...fork_Prague-blockchain_test-precompile_address_15---input_too_long 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [385, 769, 1153, 1537, 1921, 2305, 2689, 3073, 3457, 3841, 4225, 4609, 4993, 5377, 5761, 6145, 6529, 6913, 7297, 7681]
...fork_Prague-state_test-precompile_address_15---zero_length 15 100000000 [70300] [0]
...fork_Prague-state_test-precompile_address_15---input_too_short 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [383, 767, 1151, 1535, 1919, 2303, 2687, 3071, 3455, 3839, 4223, 4607, 4991, 5375, 5759, 6143, 6527, 6911, 7295, 7679]
...fork_Prague-state_test-precompile_address_15---input_too_long 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [385, 769, 1153, 1537, 1921, 2305, 2689, 3073, 3457, 3841, 4225, 4609, 4993, 5377, 5761, 6145, 6529, 6913, 7297, 7681]
...fork_Osaka-blockchain_test-precompile_address_15---zero_length 15 100000000 [70300] [0]
...fork_Osaka-blockchain_test-precompile_address_15---input_too_short 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [383, 767, 1151, 1535, 1919, 2303, 2687, 3071, 3455, 3839, 4223, 4607, 4991, 5375, 5759, 6143, 6527, 6911, 7295, 7679]
...fork_Osaka-blockchain_test-precompile_address_15---input_too_long 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [385, 769, 1153, 1537, 1921, 2305, 2689, 3073, 3457, 3841, 4225, 4609, 4993, 5377, 5761, 6145, 6529, 6913, 7297, 7681]
...fork_Osaka-state_test-precompile_address_15---zero_length 15 100000000 [70300] [0]
...fork_Osaka-state_test-precompile_address_15---input_too_short 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [383, 767, 1151, 1535, 1919, 2303, 2687, 3071, 3455, 3839, 4223, 4607, 4991, 5375, 5759, 6143, 6527, 6911, 7295, 7679]
...fork_Osaka-state_test-precompile_address_15---input_too_long 15 100000000 [70300, 102900, 135500, 168100, 200700, 233300, 265900, 298500, 331100, 363700, 396300, 428900, 461500, 494100, 526700, 559300, 591900, 624500, 657100, 689700] [385, 769, 1153, 1537, 1921, 2305, 2689, 3073, 3457, 3841, 4225, 4609, 4993, 5377, 5761, 6145, 6529, 6913, 7297, 7681]