Skip to content

test_vector_dupn_invalid_0x5f()

Documentation for tests/amsterdam/eip8024_dupn_swapn_exchange/test_eip_vectors.py::test_vector_dupn_invalid_0x5f@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

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

Test vector: e65f [INVALID_DUPN, PUSH0].

DUPN with immediate 0x5f (95) 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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
def test_vector_dupn_invalid_0x5f(
    pre: Alloc,
    state_test: StateTestFiller,
) -> None:
    """
    Test vector: e65f [INVALID_DUPN, PUSH0].

    DUPN with immediate 0x5f (95) 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(235):
        code += Op.PUSH1(i % 256)

    # DUPN with invalid immediate 0x5f - should abort
    # Hex: e6 5f
    code += Op.DUPN[b"\x5f"]

    # This should never execute
    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.