Skip to content

test_failed_inner_operation_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_failed_inner_operation_no_log@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

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

Test that failed inner operations do NOT emit transfer logs.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
@pytest.mark.parametrize(
    "recipient_code,call_gas,call_value,recipient_balance,contract_balance",
    [
        pytest.param(Op.REVERT(0, 0), Op.GAS, 500, 0, 500, id="call_reverted"),
        pytest.param(Op.JUMP(0), 100, 500, 0, 500, id="call_out_of_gas"),
        pytest.param(
            # OOG with memory expansion - tries to access large memory offset
            Op.MSTORE(0xFFFFFF, 0) + Op.STOP,
            1000,
            500,
            0,
            500,
            id="call_out_of_gas_memory_expansion",
        ),
        pytest.param(
            Op.SELFDESTRUCT(Address(0x1234)),
            100,
            0,
            2000,
            0,
            id="selfdestruct_out_of_gas",
        ),
        pytest.param(
            Op.STOP,
            Op.GAS,
            2000,
            0,
            0,
            id="call_insufficient_balance",
        ),
    ],
)
def test_failed_inner_operation_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    recipient_code: Bytecode,
    call_gas: int | Op,
    call_value: int,
    recipient_balance: int,
    contract_balance: int,
) -> None:
    """Test that failed inner operations do NOT emit transfer logs."""
    recipient = pre.deploy_contract(recipient_code, balance=recipient_balance)
    tx_value = 1000

    contract_code = Op.CALL(
        gas=call_gas,
        address=recipient,
        value=call_value,
    )
    contract = pre.deploy_contract(contract_code, balance=contract_balance)

    tx = Transaction(
        sender=sender,
        to=contract,
        value=tx_value,
        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 5 parametrized test cases across 1 fork.