Skip to content

test_dupn_stack_underflow()

Documentation for tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py::test_dupn_stack_underflow@83970623.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py::test_dupn_stack_underflow --fork Osaka

Test case out of bounds DUPN immediate.

Source code in tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@pytest.mark.parametrize(
    "stack_height,max_stack_height",
    [
        [0, 0],
        [0, 1],
        [1, 1],
        [1, 2],
        [2**8 - 1, 2**8 - 1],
        [2**8 - 1, 2**8],
    ],
)
@pytest.mark.valid_from(EOF_FORK_NAME)
def test_dupn_stack_underflow(
    stack_height: int,
    max_stack_height: int,
    eof_test: EOFTestFiller,
):
    """Test case out of bounds DUPN immediate."""
    eof_code = Container(
        sections=[
            Section.Code(
                code=sum(Op.PUSH2[v] for v in range(0, stack_height))
                + Op.DUPN[stack_height]
                + Op.STOP,
                max_stack_height=max_stack_height,
            )
        ],
    )
    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 max_stack_height
...fork_Osaka-eof_test-stack_height_0-max_stack_height_0 0 0
...fork_Osaka-eof_test-stack_height_0-max_stack_height_1 0 1
...fork_Osaka-eof_test-stack_height_1-max_stack_height_1 1 1
...fork_Osaka-eof_test-stack_height_1-max_stack_height_2 1 2
...fork_Osaka-eof_test-stack_height_255-max_stack_height_255 255 255
...fork_Osaka-eof_test-stack_height_255-max_stack_height_256 255 256