Skip to content

test_jumpf_incompatible_outputs()

Documentation for tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_stack.py::test_jumpf_incompatible_outputs@008e492e.

Generate fixtures for these test cases for Osaka with:

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

Tests JUMPF into a section with incorrect number of outputs.

Source code in tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_stack.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
@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, None, 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, None, id="same_output"),
        pytest.param(0, 0, 1, None, id="more_output"),
    ],
)
def test_jumpf_incompatible_outputs(
    eof_test: EOFTestFiller,
    target_inputs: int,
    target_outputs: int,
    stack_height: int,
    expected_exception: EOFException,
):
    """Tests JUMPF into a section with incorrect number of outputs."""
    current_section_outputs = 1
    if (current_section_outputs + target_inputs - target_outputs) != stack_height:
        assert expected_exception is not None
    eof_test(
        container=Container(
            sections=[
                Section.Code(Op.CALLF(1) + Op.STOP, max_stack_height=1),
                Section.Code(
                    Op.PUSH0 * stack_height + Op.JUMPF(2),
                    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 None
...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 None
...fork_Osaka-eof_test-more_output 0 0 1 None