Skip to content

test_vector_swapn_invalid_0x61()

Documentation for tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py::test_vector_swapn_invalid_0x61@9c2813ee.

Generate fixtures for these test cases for Amsterdam with:

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

Test vector: e7610000 [INVALID_SWAPN, PUSH2 0x0000].

SWAPN with immediate 0x61 (97) is in the invalid range (91-127). Execution should abort with exceptional halt.

Source code in tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
def test_vector_swapn_invalid_0x61(
    pre: Alloc,
    state_test: StateTestFiller,
) -> None:
    """
    Test vector: e7610000 [INVALID_SWAPN, PUSH2 0x0000].

    SWAPN with immediate 0x61 (97) is in the invalid range (91-127).
    Execution should abort with exceptional halt.
    """
    sender = pre.fund_eoa()

    # Push enough items on stack for any potential operation
    code = Bytecode()
    for i in range(236):
        code += Op.PUSH1(i % 256)

    # SWAPN with invalid immediate 0x61 - should abort
    # Hex: e7 61 00 00
    code += Op.SWAPN[b"\x61"]

    # These bytes would be PUSH2 0x0000 if we got here
    code += Op.PUSH2(0x0000)
    code += Op.PUSH1(0x42) + Op.PUSH1(0) + Op.SSTORE
    code += Op.STOP

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

    # 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.