Skip to content

test_call_opcodes_insufficient_balance_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_call_opcodes_insufficient_balance_no_log@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

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

Test CALL/CALLCODE with value exceeding caller balance.

The opcode returns 0 (does not revert), transfers nothing, and emits no transfer log.

Note CALLCODE never emits a transfer log regardless of balance — it's a self-transfer exempted by EIP-7708 — so for that opcode the meaningful assertion is that the return value is 0.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
@pytest.mark.with_all_call_opcodes(
    selector=lambda call_opcode: call_opcode in (Op.CALL, Op.CALLCODE)
)
def test_call_opcodes_insufficient_balance_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    call_opcode: Op,
) -> None:
    """
    Test CALL/CALLCODE with value exceeding caller balance.

    The opcode returns 0 (does not revert), transfers nothing, and emits
    no transfer log.

    Note CALLCODE never emits a transfer log regardless
    of balance — it's a self-transfer exempted by EIP-7708 — so for that
    opcode the meaningful assertion is that the return value is 0.
    """
    caller_balance = 1
    attempted_value = 100
    callee = pre.deploy_contract(Op.STOP)

    contract_code = Op.SSTORE(
        0, call_opcode(address=callee, value=attempted_value)
    )
    contract = pre.deploy_contract(contract_code, balance=caller_balance)

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

    post = {
        contract: Account(storage={0: 0}, balance=caller_balance),
        callee: Account(balance=0),
    }
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.