Skip to content

test_create_initcode_stop_emits_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_create_initcode_stop_emits_log@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_create_initcode_stop_emits_log --fork Amsterdam

Test that CREATE with initcode using STOP (no RETURN) emits transfer log.

When initcode runs STOP instead of RETURN, the contract is created with empty code. This is a successful CREATE, so transfer log should be emitted.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
def test_create_initcode_stop_emits_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
) -> None:
    """
    Test that CREATE with initcode using STOP (no RETURN) emits transfer log.

    When initcode runs STOP instead of RETURN, the contract is created with
    empty code. This is a successful CREATE, so transfer log should be emitted.
    """
    contract_code = Op.MSTORE(
        0, Op.PUSH32(bytes(Op.STOP).rjust(32, b"\x00"))
    ) + Op.CREATE(value=1, offset=31, size=1)
    contract = pre.deploy_contract(contract_code, balance=1)

    created_address = compute_create_address(address=contract, nonce=1)

    tx = Transaction(
        sender=sender,
        to=contract,
        value=0,
        expected_receipt=TransactionReceipt(
            logs=[transfer_log(contract, created_address, 1)]
        ),
    )

    post = {created_address: Account(balance=1, code=b"")}
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.