Skip to content

test_dupn_stack_overflow()

Documentation for tests/prague/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py::test_dupn_stack_overflow@verkle@v0.0.6.

Generate fixtures for these test cases for Pragueeip7692 with:

Pragueeip7692 only:

fill -v tests/prague/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py::test_dupn_stack_overflow --fork=PragueEIP7692 --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Pragueeip7692:

fill -v tests/prague/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py::test_dupn_stack_overflow --until=PragueEIP7692

Test case where DUPN produces an stack overflow.

Source code in tests/prague/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_dupn.py
 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
112
113
114
115
@pytest.mark.parametrize(
    "dupn_operand,max_stack_height,expect_exception",
    [
        [0, MAX_OPERAND_STACK_HEIGHT, EOFException.INVALID_MAX_STACK_HEIGHT],
        [0, MAX_OPERAND_STACK_HEIGHT + 1, EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT],
        [2**8 - 1, MAX_OPERAND_STACK_HEIGHT, EOFException.INVALID_MAX_STACK_HEIGHT],
        [2**8 - 1, MAX_OPERAND_STACK_HEIGHT + 1, EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT],
    ],
)
@pytest.mark.valid_from(EOF_FORK_NAME)
def test_dupn_stack_overflow(
    dupn_operand: int,
    max_stack_height: int,
    expect_exception: EOFException,
    eof_test: EOFTestFiller,
):
    """
    Test case where DUPN produces an stack overflow.
    """
    eof_code = Container(
        sections=[
            Section.Code(
                code=sum(Op.PUSH2[v] for v in range(0, MAX_OPERAND_STACK_HEIGHT))
                + Op.DUPN[dupn_operand]
                + Op.STOP,
                max_stack_height=max_stack_height,
            )
        ],
    )
    eof_test(
        data=eof_code,
        expect_exception=expect_exception,
    )

Parametrized Test Cases

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

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID dupn_operand max_stack_height expect_exception
dupn_operand_0-max_stack_height_1023-expect_exception_EOFException.INVALID_MAX_STACK_HEIGHT 0 1023 EOFException.INVALID_MAX_STACK_HEIGHT
dupn_operand_0-max_stack_height_1024-expect_exception_EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT 0 1024 EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT
dupn_operand_255-max_stack_height_1023-expect_exception_EOFException.INVALID_MAX_STACK_HEIGHT 255 1023 EOFException.INVALID_MAX_STACK_HEIGHT
dupn_operand_255-max_stack_height_1024-expect_exception_EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT 255 1024 EOFException.MAX_STACK_HEIGHT_ABOVE_LIMIT