Skip to content

test_create_insufficient_balance_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_create_insufficient_balance_no_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_insufficient_balance_no_log --fork Amsterdam

Test that CREATE with insufficient balance does NOT emit transfer log.

Contract receives 1, tries to CREATE with 1000 value - CREATE fails (returns 0) but doesn't halt, so tx-level log remains.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
def test_create_insufficient_balance_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
) -> None:
    """
    Test that CREATE with insufficient balance does NOT emit transfer log.

    Contract receives 1, tries to CREATE with 1000 value - CREATE fails
    (returns 0) but doesn't halt, so tx-level log remains.
    """
    initcode = Op.RETURN(0, 0)
    initcode_len = len(initcode)
    contract_code = Op.MSTORE(
        0, Op.PUSH32(bytes(initcode).rjust(32, b"\x00"))
    ) + Op.SSTORE(0, Op.CREATE(1000, 32 - initcode_len, initcode_len))
    contract = pre.deploy_contract(contract_code, balance=0)

    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 1 parametrized test case across 1 fork.