Skip to content

test_failed_create_with_value_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_failed_create_with_value_no_log@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

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

Test that failed CREATE with value does NOT emit transfer log.

When initcode fails (REVERT, INVALID), the value transfer is reverted and no log should be emitted for the CREATE.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
@pytest.mark.parametrize(
    "initcode",
    [
        pytest.param(Op.REVERT(0, 0), id="initcode_reverts"),
        pytest.param(Op.INVALID, id="initcode_invalid"),
    ],
)
def test_failed_create_with_value_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    initcode: Bytecode,
) -> None:
    """
    Test that failed CREATE with value does NOT emit transfer log.

    When initcode fails (REVERT, INVALID), the value transfer is reverted
    and no log should be emitted for the CREATE.
    """
    initcode_len = len(initcode)
    contract_code = Op.MSTORE(
        0, Op.PUSH32(bytes(initcode).rjust(32, b"\x00"))
    ) + Op.SSTORE(0, Op.CREATE(1, 32 - initcode_len, initcode_len))
    contract = pre.deploy_contract(contract_code, balance=1)

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

    state_test(env=env, pre=pre, post={}, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.