Skip to content

test_worst_jumpdests()

Documentation for tests/benchmark/test_worst_compute.py::test_worst_jumpdests@v5.0.0.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_compute.py::test_worst_jumpdests --fork Osaka

Test running a JUMPDEST-intensive contract.

Source code in tests/benchmark/test_worst_compute.py
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
@pytest.mark.valid_from("Cancun")
@pytest.mark.slow
def test_worst_jumpdests(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    gas_benchmark_value: int,
):
    """Test running a JUMPDEST-intensive contract."""
    max_code_size = fork.max_code_size()

    # Create and deploy a contract with many JUMPDESTs
    code_suffix = Op.JUMP(Op.PUSH0)
    code_body = Op.JUMPDEST * (max_code_size - len(code_suffix))
    code = code_body + code_suffix
    jumpdests_address = pre.deploy_contract(code=code)

    tx = Transaction(
        to=jumpdests_address,
        gas_limit=gas_benchmark_value,
        sender=pre.fund_eoa(),
    )

    state_test(
        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