Skip to content

test_swapn_stack_underflow()

Documentation for tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_swapn.py::test_swapn_stack_underflow@3719e927.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_swapn.py::test_swapn_stack_underflow --fork Osaka

Test case out of bounds SWAPN (underflow).

Source code in tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_swapn.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
@pytest.mark.parametrize(
    "stack_height",
    [
        0,
        1,
        21,
        2**8 - 1,
    ],
)
def test_swapn_stack_underflow(
    stack_height: int,
    eof_test: EOFTestFiller,
):
    """Test case out of bounds SWAPN (underflow)."""
    eof_code = Container(
        sections=[
            Section.Code(
                code=sum(Op.PUSH2[v] for v in range(0, stack_height))
                + Op.SWAPN[stack_height]
                + Op.STOP,
                # This is also tested in test_all_opcodes_stack_underflow()
                # so make it differ by the declared stack height.
                max_stack_height=stack_height + 1,
            )
        ],
    )
    eof_test(
        container=eof_code,
        expect_exception=EOFException.STACK_UNDERFLOW,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) stack_height
...fork_Osaka-eof_test-stack_height_0 0
...fork_Osaka-eof_test-stack_height_1 1
...fork_Osaka-eof_test-stack_height_21 21
...fork_Osaka-eof_test-stack_height_255 255
...fork_Osaka-state_test_from_eof_test-stack_height_0 0
...fork_Osaka-state_test_from_eof_test-stack_height_1 1
...fork_Osaka-state_test_from_eof_test-stack_height_21 21
...fork_Osaka-state_test_from_eof_test-stack_height_255 255
...fork_Osaka-blockchain_test_from_eof_test-stack_height_0 0
...fork_Osaka-blockchain_test_from_eof_test-stack_height_1 1
...fork_Osaka-blockchain_test_from_eof_test-stack_height_21 21
...fork_Osaka-blockchain_test_from_eof_test-stack_height_255 255