Skip to content

test_worst_jumpdests()

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

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_compute.py::test_worst_jumpdests -m benchmark

Test running a JUMPDEST-intensive contract.

Source code in tests/benchmark/test_worst_compute.py
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
@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_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test