Skip to content

test_worst_unop()

Documentation for tests/benchmark/test_worst_compute.py::test_worst_unop@0f7c73a7.

Generate fixtures for these test cases for Prague with:

fill -v tests/benchmark/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/benchmark/test_worst_compute.py
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
@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