Skip to content

test_swap()

Documentation for tests/benchmark/compute/instruction/test_stack.py::test_swap@ffe48572.

Generate fixtures for these test cases for Bogota with:

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

Benchmark SWAP instruction.

Source code in tests/benchmark/compute/instruction/test_stack.py
@pytest.mark.repricing
@pytest.mark.parametrize(
    "opcode",
    [
        Op.SWAP1,
        Op.SWAP2,
        Op.SWAP3,
        Op.SWAP4,
        Op.SWAP5,
        Op.SWAP6,
        Op.SWAP7,
        Op.SWAP8,
        Op.SWAP9,
        Op.SWAP10,
        Op.SWAP11,
        Op.SWAP12,
        Op.SWAP13,
        Op.SWAP14,
        Op.SWAP15,
        Op.SWAP16,
    ],
)
def test_swap(
    benchmark_test: BenchmarkTestFiller,
    opcode: Op,
) -> None:
    """Benchmark SWAP instruction."""
    benchmark_test(
        target_opcode=opcode,
        code_generator=JumpLoopGenerator(
            attack_block=opcode, setup=Op.PUSH0 * opcode.min_stack_height
        ),
    )

Parametrized Test Cases

This test generates 16 parametrized test cases across 4 forks.