Skip to content

test_create_out_of_gas_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_create_out_of_gas_no_log@b47f0253.

Generate fixtures for these test cases for Amsterdam with:

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

Test that CREATE running out of gas does NOT emit transfer log.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
@pytest.mark.parametrize(
    "initcode",
    [
        pytest.param(
            # OOG before return
            Op.MSTORE(offset=0xFFFFFF, value=0) + Op.RETURN(0, 0),
            id="create_out_of_gas_memory_expansion",
        ),
        pytest.param(
            # Invalid opcode
            Op.INVALID + Op.RETURN(0, 0),
            id="invalid_opcode",
        ),
        pytest.param(
            # OOG during code deposit payment (200 gas/byte for returned code)
            # Returns 1000 bytes which costs 200,000 gas for code deposit
            Op.RETURN(0, 1000),
            id="create_out_of_gas_code_deposit",
        ),
    ],
)
def test_create_out_of_gas_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    fork: Fork,
    initcode: Bytecode,
) -> None:
    """Test that CREATE running out of gas does NOT emit transfer log."""
    tx_value = 1000
    gas_limit = 100_000
    if fork.is_eip_enabled(8037):
        gas_limit = 500_000
    create_value = 500
    contract_code = Op.CALLDATACOPY(
        dest_offset=0,
        offset=0,
        size=Op.CALLDATASIZE,
    ) + Op.CREATE(value=create_value, offset=0, size=Op.CALLDATASIZE)
    contract = pre.deploy_contract(contract_code)

    tx = Transaction(
        sender=sender,
        to=contract,
        data=initcode,
        value=tx_value,
        gas_limit=gas_limit,
        expected_receipt=TransactionReceipt(
            logs=[transfer_log(sender, contract, tx_value)]
        ),
    )
    state_test(env=env, pre=pre, post={}, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.