Skip to content

test_vector_exchange_invalid_0x52()

Documentation for tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py::test_vector_exchange_invalid_0x52@2119b382.

Generate fixtures for these test cases for Amsterdam with:

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

Test vector: e852 [INVALID_EXCHANGE, MSTORE].

EXCHANGE with immediate 0x52 (82 decimal) is in the invalid range (82-127). Execution should abort with exceptional halt.

Source code in tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
def test_vector_exchange_invalid_0x52(
    pre: Alloc,
    state_test: StateTestFiller,
) -> None:
    """
    Test vector: e852 [INVALID_EXCHANGE, MSTORE].

    EXCHANGE with immediate 0x52 (82 decimal) is in the invalid
    range (82-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(30):
        code += Op.PUSH1(i)

    # EXCHANGE with invalid immediate 0x52 - should abort
    # Hex: e8 52
    code += Op.EXCHANGE[b"\x52"]

    # This would be MSTORE if we got here (0x52 = MSTORE opcode)
    code += Op.MSTORE
    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)

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