Skip to content

test_call_to_delegated_account_with_value()

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

Generate fixtures for these test cases for Amsterdam with:

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

Test CALL opcode to 7702 delegated account with value.

Unlike simple tx transfer, CALL to delegated account executes the delegated code. The transfer log should show the EOA as recipient.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
def test_call_to_delegated_account_with_value(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
) -> None:
    """
    Test CALL opcode to 7702 delegated account with value.

    Unlike simple tx transfer, CALL to delegated account executes the
    delegated code. The transfer log should show the EOA as recipient.
    """
    delegation_target = pre.deploy_contract(code=Op.STOP)
    delegated_eoa = pre.fund_eoa(amount=0, delegation=delegation_target)

    caller_code = Op.CALL(gas=50_000, address=delegated_eoa, value=100)
    caller = pre.deploy_contract(caller_code, balance=100)

    tx = Transaction(
        sender=sender,
        to=caller,
        value=0,
        expected_receipt=TransactionReceipt(
            logs=[transfer_log(caller, delegated_eoa, 100)]
        ),
    )

    post = {delegated_eoa: Account(balance=100)}
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.