Skip to content

test_rjumpv_into_returncontract()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_returncontract@49a16fac.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_returncontract --fork Osaka

EOF code containing RJUMPV with target RETURNCONTRACT immediate.

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
@pytest.mark.parametrize(
    "table_size,invalid_index",
    [
        pytest.param(1, 0, id="t1i0"),
        pytest.param(256, 0, id="t256i0"),
        pytest.param(256, 255, id="t256i255"),
    ],
)
def test_rjumpv_into_returncontract(
    eof_test: EOFTestFiller,
    table_size: int,
    invalid_index: int,
):
    """EOF code containing RJUMPV with target RETURNCONTRACT immediate."""
    invalid_destination = 1
    jump_table = [0 for _ in range(table_size)]
    jump_table[invalid_index] = invalid_destination
    eof_test(
        container=Container(
            sections=[
                Section.Code(
                    code=Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP,
                ),
                Section.Container(
                    container=Container(
                        sections=[
                            Section.Code(
                                code=Op.PUSH0 * 3 + Op.RJUMPV[jump_table] + Op.RETURNCONTRACT[0],
                            ),
                            Section.Container(
                                container=Container.Code(Op.STOP),
                            ),
                        ]
                    )
                ),
            ],
        ),
        expect_exception=EOFException.INVALID_RJUMP_DESTINATION,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) table_size invalid_index
...fork_Osaka-eof_test-t1i0 1 0
...fork_Osaka-eof_test-t256i0 256 0
...fork_Osaka-eof_test-t256i255 256 255