test_gas_usage()
Documentation for tests/cancun/eip1153_tstore/test_tstorage.py::test_gas_usage@892e6d1e.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_gas_usage --fork Amsterdam
Test that tstore and tload consume the expected gas.
Source code in tests/cancun/eip1153_tstore/test_tstorage.py
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 | @pytest.mark.ported_from(
[
"https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/Cancun/stEIP1153-transientStorage/17_tstoreGasFiller.yml", # noqa: E501
],
pr=["https://github.com/ethereum/execution-specs/pull/2385"],
)
@GasMeasureTestCases.parametrize()
def test_gas_usage(
state_test: StateTestFiller,
pre: Alloc,
fork: Fork,
bytecode: Bytecode,
extra_stack_items: int,
) -> None:
"""Test that tstore and tload consume the expected gas."""
expected_gas = bytecode.gas_cost(fork)
gas_measure_bytecode = CodeGasMeasure(
code=bytecode,
extra_stack_items=extra_stack_items,
)
env = Environment()
code_address = pre.deploy_contract(code=gas_measure_bytecode)
tx = Transaction(
sender=pre.fund_eoa(),
to=code_address,
gas_limit=1_000_000,
)
post = {
code_address: Account(
code=gas_measure_bytecode, storage={0: expected_gas}
),
}
state_test(env=env, pre=pre, tx=tx, post=post)
|
Parametrized Test Cases
This test generates 2 parametrized test cases across 4 forks.