Skip to content

test_exchange()

Documentation for tests/benchmark/compute/instruction/test_stack.py::test_exchange@c17999c0.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_stack.py::test_exchange --gas-benchmark-values 1

Benchmark EXCHANGE instruction.

Source code in tests/benchmark/compute/instruction/test_stack.py
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
@pytest.mark.repricing
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.parametrize(
    "n,m",
    [
        pytest.param(1, 2, id="n_1_m_2"),
        pytest.param(1, 29, id="n_1_m_29"),
        pytest.param(14, 16, id="n_14_m_16"),
    ],
)
def test_exchange(
    benchmark_test: BenchmarkTestFiller,
    n: int,
    m: int,
) -> None:
    """Benchmark EXCHANGE instruction."""
    opcode = Op.EXCHANGE[n, m]
    benchmark_test(
        target_opcode=Op.EXCHANGE,
        code_generator=JumpLoopGenerator(
            attack_block=opcode, setup=Op.PUSH0 * opcode.min_stack_height
        ),
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 1 fork.