Skip to content

test_rjumpv_into_push_1()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_push_1@83970623.

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

EOF1I4200_0039 (Invalid) EOF code containing RJUMPV with target PUSH1 immediate.

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
@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"),
    ],
)
@pytest.mark.parametrize("jump", [JumpDirection.FORWARD, JumpDirection.BACKWARD])
def test_rjumpv_into_push_1(
    eof_test: EOFTestFiller,
    jump: JumpDirection,
    table_size: int,
    invalid_index: int,
):
    """EOF1I4200_0039 (Invalid) EOF code containing RJUMPV with target PUSH1 immediate."""
    if jump == JumpDirection.FORWARD:
        invalid_destination = 2
        jump_table = [0 for _ in range(table_size)]
        jump_table[invalid_index] = invalid_destination
        code = (
            Op.PUSH1(1)
            + Op.RJUMPV[jump_table]
            + Op.STOP
            + Op.PUSH1(1)
            + Op.PUSH1(1)
            + Op.SSTORE
            + Op.STOP
        )
    else:
        invalid_destination = -(2 * table_size) - 3
        jump_table = [0 for _ in range(table_size)]
        jump_table[invalid_index] = invalid_destination
        code = Op.PUSH1(1) + Op.RJUMPV[jump_table] + Op.STOP
    eof_test(
        container=Container(
            sections=[Section.Code(code=code)],
        ),
        expect_exception=EOFException.INVALID_RJUMP_DESTINATION,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) jump table_size invalid_index
...fork_Osaka-eof_test-jump_JumpDirection.FORWARD-t1i0 JumpDirection.FORWARD 1 0
...fork_Osaka-eof_test-jump_JumpDirection.FORWARD-t256i0 JumpDirection.FORWARD 256 0
...fork_Osaka-eof_test-jump_JumpDirection.FORWARD-t256i255 JumpDirection.FORWARD 256 255
...fork_Osaka-eof_test-jump_JumpDirection.BACKWARD-t1i0 JumpDirection.BACKWARD 1 0
...fork_Osaka-eof_test-jump_JumpDirection.BACKWARD-t256i0 JumpDirection.BACKWARD 256 0
...fork_Osaka-eof_test-jump_JumpDirection.BACKWARD-t256i255 JumpDirection.BACKWARD 256 255