Skip to content

test_gas_usage()

Documentation for tests/cancun/eip1153_tstore/test_tstorage.py::test_gas_usage@verkle@v0.0.6.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_gas_usage --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Cancun:

fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_gas_usage --until=Cancun

Test that tstore and tload consume the expected gas.

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
@GasMeasureTestCases.parametrize()
def test_gas_usage(
    state_test: StateTestFiller,
    pre: Alloc,
    bytecode: Bytecode,
    expected_gas: int,
    overhead_cost: int,
    extra_stack_items: int,
):
    """
    Test that tstore and tload consume the expected gas.
    """
    gas_measure_bytecode = CodeGasMeasure(
        code=bytecode, overhead_cost=overhead_cost, 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

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID bytecode expected_gas extra_stack_items overhead_cost
tload 100 1 3
tstore_tload 200 1 9
tstore_cold 100 0 6
tstore_warm 200 0 12
tload 100 1 3
tstore_tload 200 1 9
tstore_cold 100 0 6
tstore_warm 200 0 12