Skip to content

test_jumpf_diff_max_stack_height()

Documentation for tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_stack.py::test_jumpf_diff_max_stack_height@83970623.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_stack.py::test_jumpf_diff_max_stack_height --fork Osaka

Tests jumpf with a different max stack height.

Source code in tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_stack.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
@pytest.mark.parametrize(
    ["target_inputs", "target_outputs", "stack_height", "expected_exception"],
    [
        pytest.param(1, 0, 1, EOFException.STACK_UNDERFLOW, id="less_stack"),
        pytest.param(2, 1, 2, EOFException.STACK_HIGHER_THAN_OUTPUTS, id="same_stack"),
        pytest.param(
            3, 2, 3, EOFException.JUMPF_DESTINATION_INCOMPATIBLE_OUTPUTS, id="more_stack"
        ),
        pytest.param(
            2, 2, 1, EOFException.JUMPF_DESTINATION_INCOMPATIBLE_OUTPUTS, id="less_output"
        ),
        pytest.param(1, 1, 1, EOFException.STACK_HIGHER_THAN_OUTPUTS, id="same_output"),
        pytest.param(0, 0, 1, EOFException.STACK_HIGHER_THAN_OUTPUTS, id="more_output"),
    ],
)
def test_jumpf_diff_max_stack_height(
    eof_test: EOFTestFiller,
    target_inputs: int,
    target_outputs: int,
    stack_height: int,
    expected_exception: EOFException,
):
    """Tests jumpf with a different max stack height."""
    current_section_outputs = 1
    eof_test(
        container=Container(
            sections=[
                Section.Code(Op.CALLF(1) + Op.STOP, max_stack_height=1),
                Section.Code(
                    (Op.PUSH0 * stack_height)  # (0, 0)
                    + Op.PUSH0  # (stack_height, stack_height)
                    + Op.RJUMPI[1]  # (stack_height + 1, stack_height + 1)
                    + Op.PUSH0  # (stack_height, stack_height)
                    + Op.JUMPF(2),  # (stack_height, stack_height + 1)
                    code_outputs=current_section_outputs,
                ),
                Section.Code(
                    Op.POP * (target_inputs - target_outputs) + Op.RETF,
                    code_inputs=target_inputs,
                    code_outputs=target_outputs,
                    max_stack_height=target_inputs,
                ),
            ]
        ),
        expect_exception=expected_exception,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) target_inputs target_outputs stack_height expected_exception
...fork_Osaka-eof_test-less_stack 1 0 1 EOFException.STACK_UNDERFLOW
...fork_Osaka-eof_test-same_stack 2 1 2 EOFException.STACK_HIGHER_THAN_OUTPUTS
...fork_Osaka-eof_test-more_stack 3 2 3 EOFException.JUMPF_DESTINATION_INCOMPATIBLE_OUTPUTS
...fork_Osaka-eof_test-less_output 2 2 1 EOFException.JUMPF_DESTINATION_INCOMPATIBLE_OUTPUTS
...fork_Osaka-eof_test-same_output 1 1 1 EOFException.STACK_HIGHER_THAN_OUTPUTS
...fork_Osaka-eof_test-more_output 0 0 1 EOFException.STACK_HIGHER_THAN_OUTPUTS