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@9c2813ee.

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
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
@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,
        gas_limit=100_000,
        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.