Skip to content

test_eip_vector_swapn_invalid_immediate_reverts()

Documentation for tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py::test_eip_vector_swapn_invalid_immediate_reverts@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py::test_eip_vector_swapn_invalid_immediate_reverts --fork Amsterdam

EIP test vector: e75b reverts.

SWAPN with immediate 0x5b (91) is in the invalid range (90 < x < 128). This should cause an exceptional halt.

Source code in tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
def test_eip_vector_swapn_invalid_immediate_reverts(
    pre: Alloc,
    state_test: StateTestFiller,
) -> None:
    """
    EIP test vector: e75b reverts.

    SWAPN with immediate 0x5b (91) is in the invalid range (90 < x < 128).
    This should cause an exceptional halt.
    """
    sender = pre.fund_eoa()

    # Build the exact bytecode from the EIP: SWAPN[0x5b]
    # 0x5b = 91 which is in the forbidden range
    code = Bytecode(
        Op.SWAPN[b"\x5b"],
        popped_stack_items=0,
        pushed_stack_items=0,
        terminating=True,
    )
    assert bytes(code) == bytes.fromhex("e75b")

    contract_address = pre.deploy_contract(code=code)
    tx = Transaction(to=contract_address, sender=sender)

    # Transaction should fail, storage unchanged
    post = {contract_address: Account(storage={})}

    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.