Skip to content

test_rjumpv_into_self()

Documentation for tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py::test_rjumpv_into_self@bc691d13.

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

EOF code containing RJUMPV targeting itself. This can never be valid because this is backward jump and RJUMPV consumes one stack item.

Source code in tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjumpv.py
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
@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("stack_height_spread", [-1, 0, 1, 2])
def test_rjumpv_into_self(
    eof_test: EOFTestFiller,
    table_size: int,
    invalid_index: int,
    stack_height_spread: int,
):
    """
    EOF code containing RJUMPV targeting itself.
    This can never be valid because this is backward jump and RJUMPV 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

    jump_table = [0 for _ in range(table_size)]
    jump_table[invalid_index] = -len(Op.RJUMPV[jump_table])

    eof_test(
        container=Container(
            sections=[
                Section.Code(
                    code=stack_spread_code + Op.RJUMPV[jump_table](0) + Op.STOP,
                    # max stack increase is computed correctly
                )
            ],
        ),
        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 table_size invalid_index
...fork_Osaka-eof_test-stack_height_spread_-1-t1i0 -1 1 0
...fork_Osaka-eof_test-stack_height_spread_-1-t256i0 -1 256 0
...fork_Osaka-eof_test-stack_height_spread_-1-t256i255 -1 256 255
...fork_Osaka-eof_test-stack_height_spread_0-t1i0 0 1 0
...fork_Osaka-eof_test-stack_height_spread_0-t256i0 0 256 0
...fork_Osaka-eof_test-stack_height_spread_0-t256i255 0 256 255
...fork_Osaka-eof_test-stack_height_spread_1-t1i0 1 1 0
...fork_Osaka-eof_test-stack_height_spread_1-t256i0 1 256 0
...fork_Osaka-eof_test-stack_height_spread_1-t256i255 1 256 255
...fork_Osaka-eof_test-stack_height_spread_2-t1i0 2 1 0
...fork_Osaka-eof_test-stack_height_spread_2-t256i0 2 256 0
...fork_Osaka-eof_test-stack_height_spread_2-t256i255 2 256 255
...fork_Osaka-state_test_from_eof_test-stack_height_spread_-1-t1i0 -1 1 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_-1-t256i0 -1 256 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_-1-t256i255 -1 256 255
...fork_Osaka-state_test_from_eof_test-stack_height_spread_0-t1i0 0 1 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_0-t256i0 0 256 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_0-t256i255 0 256 255
...fork_Osaka-state_test_from_eof_test-stack_height_spread_1-t1i0 1 1 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_1-t256i0 1 256 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_1-t256i255 1 256 255
...fork_Osaka-state_test_from_eof_test-stack_height_spread_2-t1i0 2 1 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_2-t256i0 2 256 0
...fork_Osaka-state_test_from_eof_test-stack_height_spread_2-t256i255 2 256 255
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_-1-t1i0 -1 1 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_-1-t256i0 -1 256 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_-1-t256i255 -1 256 255
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_0-t1i0 0 1 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_0-t256i0 0 256 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_0-t256i255 0 256 255
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_1-t1i0 1 1 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_1-t256i0 1 256 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_1-t256i255 1 256 255
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_2-t1i0 2 1 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_2-t256i0 2 256 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_spread_2-t256i255 2 256 255