Skip to content

test_selfdestruct_to_self_pre_existing_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py::test_selfdestruct_to_self_pre_existing_no_log@9c2813ee.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py::test_selfdestruct_to_self_pre_existing_no_log --fork Amsterdam

Test that selfdestruct-to-self emits NO log for pre-existing contracts.

Burn log only emitted when created and destroyed in same tx.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_burn_logs.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def test_selfdestruct_to_self_pre_existing_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
) -> None:
    """
    Test that selfdestruct-to-self emits NO log for pre-existing contracts.

    Burn log only emitted when created and destroyed in same tx.
    """
    contract_balance = 2000

    contract_code = Op.SELFDESTRUCT(Op.ADDRESS)
    contract = pre.deploy_contract(contract_code, balance=contract_balance)

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

    # Contract keeps its balance (not destroyed since not created in same tx)
    state_test(
        env=env,
        pre=pre,
        post={contract: Account(balance=contract_balance)},
        tx=tx,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.