Skip to content

test_gas_costs()

Documentation for tests/byzantium/eip197_ec_pairing/test_gas.py::test_gas_costs@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/byzantium/eip197_ec_pairing/test_gas.py::test_gas_costs --fork Amsterdam

Test the base gas cost of the ecpairing precompile with zero pairs.

Source code in tests/byzantium/eip197_ec_pairing/test_gas.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@pytest.mark.valid_from("Byzantium")
@pytest.mark.parametrize("enough_gas", [True, False])
def test_gas_costs(
    state_test: StateTestFiller,
    pre: Alloc,
    precompile_gas: int,
    enough_gas: bool,
) -> None:
    """
    Test the base gas cost of the ecpairing precompile with zero pairs.
    """
    gas = precompile_gas if enough_gas else precompile_gas - 1
    storage = Storage()

    account = pre.deploy_contract(
        code=Op.SSTORE(
            storage.store_next(1 if enough_gas else 0),
            Op.STATICCALL(gas=gas, address=Spec.ECPAIRING),
        ),
        storage=storage.canary(),
    )

    tx = Transaction(
        to=account,
        sender=pre.fund_eoa(),
        gas_limit=1_000_000,
        protected=True,
    )

    post = {account: Account(storage=storage)}

    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 12 forks.