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@9c2813ee.

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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
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,
        gas_limit=500_000,
        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.