Skip to content

test_rjumpv_condition()

Documentation for tests/prague/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_condition@verkle@v0.0.6.

Generate fixtures for these test cases for Pragueeip7692 with:

Pragueeip7692 only:

fill -v tests/prague/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_condition --fork=PragueEIP7692 --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Pragueeip7692:

fill -v tests/prague/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_condition --until=PragueEIP7692

Test RJUMPV contract switching based on external input

Source code in tests/prague/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@pytest.mark.parametrize(
    "calldata",
    [
        pytest.param(0, id="c0"),
        pytest.param(1, id="c1"),
        pytest.param(3, id="c3"),
        pytest.param(255, id="c255"),
        pytest.param(256, id="c256"),
        pytest.param(2**256 - 1, id="c2^256-1"),
    ],
)
@pytest.mark.parametrize(
    "table_size",
    [
        pytest.param(1, id="t1"),
        pytest.param(3, id="t3"),
        pytest.param(256, id="t256"),
    ],
)
def test_rjumpv_condition(
    eof_state_test: EOFStateTestFiller,
    calldata: int,
    table_size: int,
):
    """Test RJUMPV contract switching based on external input"""
    value_fall_through = 0xFFFF
    value_base = 0x1000  # Force a `PUSH2` instruction to be used on all targets
    target_length = 7
    jump_table = [(i + 1) * target_length for i in range(table_size)]

    jump_targets = sum(
        (Op.SSTORE(slot_conditional_result, i + value_base) + Op.STOP) for i in range(table_size)
    )

    fall_through_case = Op.SSTORE(slot_conditional_result, value_fall_through) + Op.STOP

    eof_state_test(
        data=Container(
            sections=[
                Section.Code(
                    code=Op.PUSH0
                    + Op.CALLDATALOAD
                    + Op.RJUMPV[jump_table]
                    + fall_through_case
                    + jump_targets,
                )
            ]
        ),
        tx_data=calldata.to_bytes(32, "big"),
        container_post=Account(
            storage={
                slot_conditional_result: calldata + value_base
                if calldata < table_size
                else value_fall_through,
            }
        ),
    )

Parametrized Test Cases

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

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID table_size calldata
t1-c0 1 0
t1-c1 1 1
t1-c3 1 3
t1-c255 1 255
t1-c256 1 256
t1-c2^256-1 1 115792089237316195423570985008687907853269984665640564039457584007913129639935
t3-c0 3 0
t3-c1 3 1
t3-c3 3 3
t3-c255 3 255
t3-c256 3 256
t3-c2^256-1 3 115792089237316195423570985008687907853269984665640564039457584007913129639935
t256-c0 256 0
t256-c1 256 1
t256-c3 256 3
t256-c255 256 255
t256-c256 256 256
t256-c2^256-1 256 115792089237316195423570985008687907853269984665640564039457584007913129639935
t1-c0 1 0
t1-c1 1 1
t1-c3 1 3
t1-c255 1 255
t1-c256 1 256
t1-c2^256-1 1 115792089237316195423570985008687907853269984665640564039457584007913129639935
t3-c0 3 0
t3-c1 3 1
t3-c3 3 3
t3-c255 3 255
t3-c256 3 256
t3-c2^256-1 3 115792089237316195423570985008687907853269984665640564039457584007913129639935
t256-c0 256 0
t256-c1 256 1
t256-c3 256 3
t256-c255 256 255
t256-c256 256 256
t256-c2^256-1 256 115792089237316195423570985008687907853269984665640564039457584007913129639935
t1-c0 1 0
t1-c1 1 1
t1-c3 1 3
t1-c255 1 255
t1-c256 1 256
t1-c2^256-1 1 115792089237316195423570985008687907853269984665640564039457584007913129639935
t3-c0 3 0
t3-c1 3 1
t3-c3 3 3
t3-c255 3 255
t3-c256 3 256
t3-c2^256-1 3 115792089237316195423570985008687907853269984665640564039457584007913129639935
t256-c0 256 0
t256-c1 256 1
t256-c3 256 3
t256-c255 256 255
t256-c256 256 256
t256-c2^256-1 256 115792089237316195423570985008687907853269984665640564039457584007913129639935