Skip to content

test_call_to_self_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_call_to_self_no_log@a9abd46e.

Generate fixtures for these test cases for Amsterdam with:

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

Test that CALL/CALLCODE with value to self emits no transfer log.

Uses CALLDATASIZE to detect recursion: external call has no calldata, recursive call passes 1 byte of calldata to signal stop.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
@pytest.mark.parametrize(
    "call_opcode",
    [
        pytest.param(Op.CALL, id="call"),
        pytest.param(Op.CALLCODE, id="callcode"),
    ],
)
def test_call_to_self_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    call_opcode: Op,
) -> None:
    """
    Test that CALL/CALLCODE with value to self emits no transfer log.

    Uses CALLDATASIZE to detect recursion: external call has no calldata,
    recursive call passes 1 byte of calldata to signal stop.
    """
    # CALLDATASIZE > 0 means recursive call, jump to end
    # Byte offsets: CALLDATASIZE(1) + PUSH1(2) + JUMPI(1) = 4
    # CALL with args_size=1: ~16 bytes, JUMPDEST at offset 20
    contract_code = (
        Op.CALLDATASIZE
        + Op.PUSH1(20)
        + Op.JUMPI
        + call_opcode(address=Op.ADDRESS, value=1, args_size=1)
        + Op.JUMPDEST
        + Op.STOP
    )
    contract = pre.deploy_contract(contract_code, balance=1)

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

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

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.