Skip to content

test_swapn()

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

Generate fixtures for these test cases for Amsterdam with:

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

Benchmark SWAPN instruction.

Source code in tests/benchmark/compute/instruction/test_stack.py
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@pytest.mark.repricing
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.parametrize(
    "stack_index",
    [17, 107, 235],
    ids=lambda x: f"stack_{x}",
)
def test_swapn(
    benchmark_test: BenchmarkTestFiller,
    stack_index: int,
) -> None:
    """Benchmark SWAPN instruction."""
    opcode = Op.SWAPN[stack_index]
    benchmark_test(
        target_opcode=Op.SWAPN,
        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.