test_tload()
Documentation for tests/benchmark/compute/instruction/test_storage.py::test_tload@8db70f93.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/benchmark/compute/instruction/test_storage.py::test_tload --gas-benchmark-values 1
Benchmark TLOAD instruction.
Source code in tests/benchmark/compute/instruction/test_storage.py
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.repricing(fixed_key=True, fixed_value=True)
@pytest.mark.parametrize("fixed_key", [True, False])
@pytest.mark.parametrize("fixed_value", [True, False])
def test_tload(
benchmark_test: BenchmarkTestFiller,
fixed_key: bool,
fixed_value: bool,
) -> None:
"""Benchmark TLOAD instruction."""
setup = Bytecode()
if not fixed_key and not fixed_value:
setup = Op.GAS + Op.TSTORE(Op.DUP2, Op.GAS)
attack_block = Op.TLOAD(Op.DUP1)
if not fixed_key and fixed_value:
attack_block = Op.TLOAD(Op.GAS)
if fixed_key and not fixed_value:
setup = Op.TSTORE(Op.CALLDATASIZE, Op.GAS)
attack_block = Op.TLOAD(Op.CALLDATASIZE)
if fixed_key and fixed_value:
attack_block = Op.TLOAD(Op.CALLDATASIZE)
tx_data = b"42" if fixed_key and not fixed_value else b""
benchmark_test(
target_opcode=Op.TLOAD,
code_generator=ExtCallGenerator(
setup=setup,
attack_block=attack_block,
tx_kwargs={"data": tx_data},
),
)
|
Parametrized Test Cases
This test generates 4 parametrized test cases across 3 forks.