Skip to content

test_rjumpi_condition_backwards()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_condition_backwards@21fb11c8.

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_backwards --fork Osaka

Test RJUMPI contract switching based on external input.

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@pytest.mark.parametrize(
    "calldata",
    [pytest.param(b"\x00", id="False"), pytest.param(b"\x01", id="True")],
)
def test_rjumpi_condition_backwards(
    state_test: StateTestFiller,
    pre: Alloc,
    calldata: bytes,
):
    """Test RJUMPI contract switching based on external input."""
    env = Environment()
    sender = pre.fund_eoa(10**18)
    contract_address = pre.deploy_contract(
        code=Container.Code(
            Op.PUSH1(1)
            + Op.RJUMPI[6]
            + Op.SSTORE(slot_conditional_result, value_calldata_true)
            + Op.STOP
            + Op.PUSH0
            + Op.CALLDATALOAD
            + Op.RJUMPI[-11]
            + Op.SSTORE(slot_conditional_result, value_calldata_false)
            + 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-state_test-False 00
...fork_Osaka-state_test-True 01
...fork_Osaka-blockchain_test_from_state_test-False 00
...fork_Osaka-blockchain_test_from_state_test-True 01