Skip to content

test_worst_returndatasize_zero()

Documentation for tests/zkevm/test_worst_compute.py::test_worst_returndatasize_zero@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/zkevm/test_worst_compute.py::test_worst_returndatasize_zero --fork Prague

Test running a block with as many RETURNDATASIZE opcodes as possible with a zero buffer.

Source code in tests/zkevm/test_worst_compute.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
@pytest.mark.valid_from("Cancun")
def test_worst_returndatasize_zero(state_test: StateTestFiller, pre: Alloc, fork: Fork):
    """Test running a block with as many RETURNDATASIZE opcodes as possible with a zero buffer."""
    env = Environment()
    max_code_size = fork.max_code_size()

    dummy_contract_call = Bytecode()

    code_prefix = dummy_contract_call + Op.JUMPDEST
    iter_loop = Op.POP(Op.RETURNDATASIZE)
    code_suffix = Op.JUMP(len(code_prefix) - 1)
    code_iter_len = (max_code_size - len(code_prefix) - len(code_suffix)) // len(iter_loop)
    code = code_prefix + iter_loop * code_iter_len + code_suffix
    assert len(code) <= max_code_size

    tx = Transaction(
        to=pre.deploy_contract(code=bytes(code)),
        gas_limit=env.gas_limit,
        sender=pre.fund_eoa(),
    )

    state_test(
        env=env,
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Cancun-state_test
...fork_Cancun-blockchain_test_from_state_test
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test