Skip to content

test_callvalue_from_call()

Documentation for tests/benchmark/compute/instruction/test_call_context.py::test_callvalue_from_call@7b8124a7.

Generate fixtures for these test cases for Osaka with:

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

Benchmark CALLVALUE instruction from call.

Source code in tests/benchmark/compute/instruction/test_call_context.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@pytest.mark.parametrize("non_zero_value", [True, False])
def test_callvalue_from_call(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    non_zero_value: bool,
    fork: Fork,
) -> None:
    """
    Benchmark CALLVALUE instruction from call.
    """
    code_address = pre.deploy_contract(
        code=Op.CALLVALUE * fork.max_stack_height()
    )
    benchmark_test(
        code_generator=JumpLoopGenerator(
            attack_block=Op.POP(
                Op.CALL(
                    address=code_address,
                    value=int(non_zero_value),
                    args_offset=Op.PUSH0,
                    args_size=Op.PUSH0,
                    ret_offset=Op.PUSH0,
                    ret_size=Op.PUSH0,
                )
            ),
            tx_kwargs={"value": 10**18},
        ),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 2 forks.