Skip to content

test_calldatasize()

Documentation for tests/benchmark/compute/instruction/test_call_context.py::test_calldatasize@20373115.

Generate fixtures for these test cases for Amsterdam with:

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

Benchmark CALLDATASIZE instruction.

Source code in tests/benchmark/compute/instruction/test_call_context.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@pytest.mark.repricing(zero_data=True)
@pytest.mark.parametrize("calldata_size", [0, 32, 256, 1024])
@pytest.mark.parametrize("zero_data", [True, False])
def test_calldatasize(
    benchmark_test: BenchmarkTestFiller, calldata_size: int, zero_data: bool
) -> None:
    """Benchmark CALLDATASIZE instruction."""
    calldata = (
        b"\x00" * calldata_size
        if zero_data
        else Bytes([i % 256 for i in range(calldata_size)])
    )

    benchmark_test(
        target_opcode=Op.CALLDATASIZE,
        code_generator=ExtCallGenerator(
            attack_block=Op.CALLDATASIZE,
            tx_kwargs={"data": calldata},
        ),
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 3 forks.