Skip to content

test_transfer_to_special_address()

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

Generate fixtures for these test cases for Amsterdam with:

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

Test that transfers to special addresses emit transfer logs.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
@pytest.mark.parametrize(
    "address_type",
    [
        pytest.param("ecrecover", id="precompile_ecrecover"),
        pytest.param("sha256", id="precompile_sha256"),
        pytest.param("system", id="system_address"),
        pytest.param("coinbase", id="coinbase_address"),
    ],
)
def test_transfer_to_special_address(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    address_type: str,
) -> None:
    """Test that transfers to special addresses emit transfer logs."""
    transfer_amount = 1000

    # Resolve target address based on type
    # Note: blake2f (0x09) excluded as it requires specific input format
    address_map = {
        "ecrecover": Address(0x01),
        "sha256": Address(0x02),
        "system": Spec.SYSTEM_ADDRESS,
    }

    if address_type == "coinbase":
        target = env.fee_recipient
        # Don't check exact balance - coinbase also receives gas fees
        post = {}
    else:
        target = address_map[address_type]
        post = {target: Account(balance=transfer_amount)}

    tx = Transaction(
        sender=sender,
        to=target,
        value=transfer_amount,
        expected_receipt=TransactionReceipt(
            logs=[transfer_log(sender, target, transfer_amount)]
        ),
    )

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

Parametrized Test Cases

This test generates 4 parametrized test cases across 1 fork.