Skip to content

test_rjumpi_into_self()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py::test_rjumpi_into_self@bc691d13.

Generate fixtures for these test cases for Osaka with:

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

EOF code containing RJUMPI targeting itself (-3). This can never be valid because this is backward jump and RJUMPI consumes one stack item.

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpi.py
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
@pytest.mark.parametrize("stack_height_spread", [-1, 0, 1, 2])
def test_rjumpi_into_self(
    eof_test: EOFTestFiller,
    stack_height_spread: int,
):
    """
    EOF code containing RJUMPI targeting itself (-3).
    This can never be valid because this is backward jump and RJUMPI consumes one stack item.
    """
    # Create variadic stack height by the parametrized spread.
    stack_spread_code = Bytecode()
    if stack_height_spread >= 0:
        stack_spread_code = Op.RJUMPI[stack_height_spread](0) + Op.PUSH0 * stack_height_spread

    eof_test(
        container=Container(
            sections=[
                Section.Code(
                    code=stack_spread_code + Op.RJUMPI[-len(Op.RJUMPI[0])](0) + Op.STOP,
                )
            ],
        ),
        expect_exception=EOFException.STACK_HEIGHT_MISMATCH,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) stack_height_spread
...fork_Osaka-eof_test-stack_height_spread_-1 -1
...fork_Osaka-eof_test-stack_height_spread_0 0
...fork_Osaka-eof_test-stack_height_spread_1 1
...fork_Osaka-eof_test-stack_height_spread_2 2
...fork_Osaka-state_test_from_eof_test-stack_height_spread_-1 -1
...fork_Osaka-state_test_from_eof_test-stack_height_spread_0 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_1 1
...fork_Osaka-state_test_from_eof_test-stack_height_spread_2 2
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_-1 -1
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_0 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_1 1
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_2 2