Skip to content

test_delegatecall_inner_call_with_value()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_delegatecall_inner_call_with_value@2119b382.

Generate fixtures for these test cases for Amsterdam with:

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

Test DELEGATECALL to code that performs CALL with value.

Scenario: A DELEGATECALLs B, B does CALL with value to C. The CALL from B executes in A's context, so log shows A as sender.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
def test_delegatecall_inner_call_with_value(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
) -> None:
    """
    Test DELEGATECALL to code that performs CALL with value.

    Scenario: A DELEGATECALLs B, B does CALL with value to C.
    The CALL from B executes in A's context, so log shows A as sender.
    """
    recipient = pre.deploy_contract(Op.STOP)

    # B: code that CALLs recipient with value
    code_b = Op.CALL(address=recipient, value=1)
    contract_b = pre.deploy_contract(code_b)

    # A: DELEGATECALLs to B (executes B's code in A's context)
    code_a = Op.DELEGATECALL(address=contract_b)
    contract_a = pre.deploy_contract(code_a, balance=1)

    tx = Transaction(
        sender=sender,
        to=contract_a,
        value=0,
        expected_receipt=TransactionReceipt(
            logs=[
                # CALL from B executes in A's context, so A is the sender
                transfer_log(contract_a, recipient, 1),
            ]
        ),
    )

    post = {recipient: Account(balance=1)}
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.