Skip to content

test_rjumpv_into_rjumpi()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_rjumpi@21fb11c8.

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

EOF1I4200_0038 (Invalid) EOF code containing RJUMPV with target RJUMPI immediate.

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
@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(
    "data_portion_end",
    [True, False],
    ids=["data_portion_end", "data_portion_start"],
)
def test_rjumpv_into_rjumpi(
    eof_test: EOFTestFiller,
    table_size: int,
    invalid_index: int,
    data_portion_end: bool,
):
    """EOF1I4200_0038 (Invalid) EOF code containing RJUMPV with target RJUMPI immediate."""
    invalid_destination = 5 if data_portion_end else 4
    jump_table = [0 for _ in range(table_size)]
    jump_table[invalid_index] = invalid_destination
    if table_size > 1:
        valid_index = 0
        if valid_index == invalid_index:
            valid_index += 1
        jump_table[valid_index] = 1
    eof_test(
        container=Container(
            sections=[
                Section.Code(
                    code=Op.PUSH1(1)
                    + Op.RJUMPV[jump_table]
                    + Op.STOP
                    + Op.PUSH1(1)
                    + Op.RJUMPI[0]
                    + 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) data_portion_end table_size invalid_index
...fork_Osaka-eof_test-data_portion_end-t1i0 True 1 0
...fork_Osaka-eof_test-data_portion_end-t256i0 True 256 0
...fork_Osaka-eof_test-data_portion_end-t256i255 True 256 255
...fork_Osaka-eof_test-data_portion_start-t1i0 False 1 0
...fork_Osaka-eof_test-data_portion_start-t256i0 False 256 0
...fork_Osaka-eof_test-data_portion_start-t256i255 False 256 255