Skip to content

test_calldataload()

Documentation for tests/benchmark/compute/instruction/test_call_context.py::test_calldataload@8db70f93.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_call_context.py::test_calldataload --gas-benchmark-values 1

Benchmark CALLDATALOAD instruction.

Source code in tests/benchmark/compute/instruction/test_call_context.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@pytest.mark.repricing(zero_data=True)
@pytest.mark.parametrize("calldata_size", [0, 32, 256, 1024])
@pytest.mark.parametrize("zero_data", [True, False])
def test_calldataload(
    benchmark_test: BenchmarkTestFiller, calldata_size: int, zero_data: bool
) -> None:
    """Benchmark CALLDATALOAD instruction."""
    calldata = (
        b"\x00" * calldata_size
        if zero_data
        else Bytes([i % 256 for i in range(calldata_size)])
    )
    benchmark_test(
        target_opcode=Op.CALLDATALOAD,
        code_generator=JumpLoopGenerator(
            attack_block=Op.CALLDATALOAD(Op.PUSH0),
            tx_kwargs={"data": calldata},
        ),
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 3 forks.