Skip to content

test_exchange_all_invalid_immediates()

Documentation for tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_exchange.py::test_exchange_all_invalid_immediates@008e492e.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_exchange.py::test_exchange_all_invalid_immediates --fork Osaka

Test case for all invalid EXCHANGE immediates.

Source code in tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_exchange.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@pytest.mark.parametrize(
    "stack_height,x,y",
    [
        # 2 and 3 are the lowest valid values for x and y, which translates to a
        # zero immediate value.
        pytest.param(0, 2, 3, id="stack_height=0_n=1_m=1"),
        pytest.param(1, 2, 3, id="stack_height=1_n=1_m=1"),
        pytest.param(2, 2, 3, id="stack_height=2_n=1_m=1"),
        pytest.param(17, 2, 18, id="stack_height=17_n=1_m=16"),
        pytest.param(17, 17, 18, id="stack_height=17_n=16_m=1"),
        pytest.param(32, 17, 33, id="stack_height=32_n=16_m=16"),
    ],
)
@pytest.mark.valid_from(EOF_FORK_NAME)
def test_exchange_all_invalid_immediates(
    eof_test: EOFTestFiller,
    stack_height: int,
    x: int,
    y: int,
):
    """Test case for all invalid EXCHANGE immediates."""
    eof_code = Container(
        sections=[
            Section.Code(
                code=sum(Op.PUSH2[v] for v in range(stack_height))
                + Op.EXCHANGE[x, y]
                + Op.POP * stack_height
                + Op.STOP,
                max_stack_height=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 x y
...fork_Osaka-eof_test-stack_height=0_n=1_m=1 0 2 3
...fork_Osaka-eof_test-stack_height=1_n=1_m=1 1 2 3
...fork_Osaka-eof_test-stack_height=2_n=1_m=1 2 2 3
...fork_Osaka-eof_test-stack_height=17_n=1_m=16 17 2 18
...fork_Osaka-eof_test-stack_height=17_n=16_m=1 17 17 18
...fork_Osaka-eof_test-stack_height=32_n=16_m=16 32 17 33