Skip to content

test_tstore()

Documentation for tests/benchmark/compute/instruction/test_storage.py::test_tstore@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_storage.py::test_tstore --gas-benchmark-values 1

Benchmark TSTORE instruction.

Source code in tests/benchmark/compute/instruction/test_storage.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@pytest.mark.repricing(fixed_key=False, fixed_value=False)
@pytest.mark.parametrize("fixed_key", [True, False])
@pytest.mark.parametrize("fixed_value", [True, False])
def test_tstore(
    benchmark_test: BenchmarkTestFiller,
    fixed_key: bool,
    fixed_value: bool,
) -> None:
    """Benchmark TSTORE instruction."""
    init_key = 42
    setup = Op.PUSH1(init_key)

    attack_block = Op.TSTORE(Op.DUP2, Op.GAS if not fixed_value else Op.DUP1)
    cleanup = Op.POP + Op.GAS if not fixed_key else Bytecode()

    benchmark_test(
        target_opcode=Op.TSTORE,
        code_generator=JumpLoopGenerator(
            setup=setup, attack_block=attack_block, cleanup=cleanup
        ),
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.