test_gas_costs()
Documentation for tests/byzantium/eip196_ec_add_mul/test_gas.py::test_gas_costs@b314d18e.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/byzantium/eip196_ec_add_mul/test_gas.py::test_gas_costs --fork Amsterdam
Tests the constant gas behavior of ecadd/ecmul precompiled contracts.
Source code in tests/byzantium/eip196_ec_add_mul/test_gas.py
26
27
28
29
30
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
63
64
65 | @pytest.mark.valid_from("Byzantium")
@pytest.mark.parametrize(
"precompile_address",
[
pytest.param(Spec.ECADD, id="ecadd"),
pytest.param(Spec.ECMUL, id="ecmul"),
],
)
@pytest.mark.parametrize("enough_gas", [True, False])
def test_gas_costs(
state_test: StateTestFiller,
pre: Alloc,
precompile_address: Address,
precompile_gas: int,
enough_gas: bool,
) -> None:
"""
Tests the constant gas behavior of `ecadd/ecmul` precompiled contracts.
"""
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=precompile_address),
),
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 4 parametrized test cases across 12 forks.