Skip to content

test_worst_unop()

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

Generate fixtures for these test cases for Prague with:

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

Test running a block with as many unary instructions (takes one arg, produces one value) as possible.

Source code in tests/zkevm/test_worst_compute.py
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
@pytest.mark.valid_from("Cancun")
@pytest.mark.parametrize("opcode", [Op.ISZERO, Op.NOT])
def test_worst_unop(state_test: StateTestFiller, pre: Alloc, opcode: Op, fork: Fork):
    """
    Test running a block with as many unary instructions (takes one arg, produces one value)
    as possible.
    """
    env = Environment()
    max_code_size = fork.max_code_size()

    code_prefix = Op.JUMPDEST + Op.PUSH0  # Start with the arg 0.
    code_suffix = Op.POP + Op.PUSH0 + Op.JUMP
    code_body_len = max_code_size - len(code_prefix) - len(code_suffix)
    code_body = opcode * code_body_len
    code = code_prefix + code_body + code_suffix
    assert len(code) == max_code_size

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

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

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) opcode
...fork_Cancun-state_test-opcode_ISZERO ISZERO
...fork_Cancun-state_test-opcode_NOT NOT
...fork_Cancun-blockchain_test_from_state_test-opcode_ISZERO ISZERO
...fork_Cancun-blockchain_test_from_state_test-opcode_NOT NOT
...fork_Prague-state_test-opcode_ISZERO ISZERO
...fork_Prague-state_test-opcode_NOT NOT
...fork_Prague-blockchain_test_from_state_test-opcode_ISZERO ISZERO
...fork_Prague-blockchain_test_from_state_test-opcode_NOT NOT
...fork_Osaka-state_test-opcode_ISZERO ISZERO
...fork_Osaka-state_test-opcode_NOT NOT
...fork_Osaka-blockchain_test_from_state_test-opcode_ISZERO ISZERO
...fork_Osaka-blockchain_test_from_state_test-opcode_NOT NOT