Skip to content

test_rjumpi_condition_forwards()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_condition_forwards@83970623.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_condition_forwards --fork Osaka

Test RJUMPI contract switching based on external input (forwards).

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py
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
@pytest.mark.parametrize(
    "calldata",
    [pytest.param(b"\x00", id="False"), pytest.param(b"\x01", id="True")],
)
def test_rjumpi_condition_forwards(
    state_test: StateTestFiller,
    pre: Alloc,
    calldata: bytes,
):
    """Test RJUMPI contract switching based on external input (forwards)."""
    env = Environment()
    sender = pre.fund_eoa(10**18)
    contract_address = pre.deploy_contract(
        code=Container.Code(
            Op.PUSH1(0)
            + Op.CALLDATALOAD
            + Op.RJUMPI[6]
            + Op.SSTORE(slot_conditional_result, value_calldata_false)
            + Op.STOP
            + Op.SSTORE(slot_conditional_result, value_calldata_true)
            + Op.STOP,
        )
    )
    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        data=calldata,
        sender=sender,
    )
    post = {
        contract_address: Account(
            storage={
                slot_conditional_result: value_calldata_false
                if calldata == b"\0"
                else value_calldata_true
            }
        )
    }
    state_test(env=env, tx=tx, pre=pre, post=post)

Parametrized Test Cases

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

Test ID (Abbreviated) calldata
...fork_Osaka-blockchain_test-False 00
...fork_Osaka-blockchain_test-True 01
...fork_Osaka-state_test-False 00
...fork_Osaka-state_test-True 01