Skip to content

test_valid_gas_pairing()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_valid_gas_pairing@83970623.

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_valid_gas_pairing --fork Prague

Test the BLS12_PAIRING precompile, by expecting the call to succeed for all possible input lengths (up to k == PAIRINGS_TO_TEST).

If any of the calls fails, the test will fail.

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
@pytest.mark.parametrize(
    "precompile_gas_list,precompile_data_length_list",
    [
        pytest.param(
            [PAIRING_GAS(i * Spec.LEN_PER_PAIR) for i in range(1, PAIRINGS_TO_TEST + 1)],
            [i * Spec.LEN_PER_PAIR for i in range(1, PAIRINGS_TO_TEST + 1)],
            id="sufficient_gas",
        ),
        pytest.param(
            [PAIRING_GAS(i * Spec.LEN_PER_PAIR) + 1 for i in range(1, PAIRINGS_TO_TEST + 1)],
            [i * Spec.LEN_PER_PAIR for i in range(1, PAIRINGS_TO_TEST + 1)],
            id="extra_gas",
        ),
    ],
)
@pytest.mark.parametrize("expected_output", [Spec.PAIRING_TRUE], ids=[""])
@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""])
@pytest.mark.parametrize("precompile_address", [Spec.PAIRING])
def test_valid_gas_pairing(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
):
    """
    Test the BLS12_PAIRING precompile, by expecting the call to succeed for all possible input
    lengths (up to k == PAIRINGS_TO_TEST).

    If any of the calls fails, 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---sufficient_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [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]
...fork_Prague-blockchain_test-precompile_address_15---extra_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [70301, 102901, 135501, 168101, 200701, 233301, 265901, 298501, 331101, 363701, 396301, 428901, 461501, 494101, 526701, 559301, 591901, 624501, 657101, 689701] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]
...fork_Prague-state_test-precompile_address_15---sufficient_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [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]
...fork_Prague-state_test-precompile_address_15---extra_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [70301, 102901, 135501, 168101, 200701, 233301, 265901, 298501, 331101, 363701, 396301, 428901, 461501, 494101, 526701, 559301, 591901, 624501, 657101, 689701] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]
...fork_Osaka-blockchain_test-precompile_address_15---sufficient_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [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]
...fork_Osaka-blockchain_test-precompile_address_15---extra_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [70301, 102901, 135501, 168101, 200701, 233301, 265901, 298501, 331101, 363701, 396301, 428901, 461501, 494101, 526701, 559301, 591901, 624501, 657101, 689701] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]
...fork_Osaka-state_test-precompile_address_15---sufficient_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [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]
...fork_Osaka-state_test-precompile_address_15---extra_gas 15 100000000 00000000000000000000000000000000 00000000000000000000000000000001 [70301, 102901, 135501, 168101, 200701, 233301, 265901, 298501, 331101, 363701, 396301, 428901, 461501, 494101, 526701, 559301, 591901, 624501, 657101, 689701] [384, 768, 1152, 1536, 1920, 2304, 2688, 3072, 3456, 3840, 4224, 4608, 4992, 5376, 5760, 6144, 6528, 6912, 7296, 7680]