Skip to content

Commit 90298f9

Browse files
committed
✨ feat(tests): EIP-7928 SELFDESTRUCT test
1 parent 1779001 commit 90298f9

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,37 @@ def test_bal_code_changes(
284284
),
285285
},
286286
)
287+
288+
289+
@pytest.mark.valid_from("Amsterdam")
290+
def test_bal_self_destruct(pre: Alloc, blockchain_test: BlockchainTestFiller):
291+
"""Ensure BAL captures balance changes caused by `SELFDESTRUCT`."""
292+
alice = pre.fund_eoa()
293+
bob = pre.fund_eoa(amount=0)
294+
295+
kaboom = pre.deploy_contract(code=Op.SELFDESTRUCT(bob), balance=100)
296+
297+
tx = Transaction(sender=alice, to=kaboom, gas_limit=1_000_000)
298+
299+
block = Block(
300+
txs=[tx],
301+
expected_block_access_list=BlockAccessListExpectation(
302+
account_expectations={
303+
alice: BalAccountExpectation(
304+
nonce_changes=[BalNonceChange(tx_index=1, post_nonce=1)],
305+
),
306+
bob: BalAccountExpectation(
307+
balance_changes=[BalBalanceChange(tx_index=1, post_balance=100)]
308+
),
309+
kaboom: BalAccountExpectation(
310+
balance_changes=[BalBalanceChange(tx_index=1, post_balance=0)]
311+
),
312+
}
313+
),
314+
)
315+
316+
blockchain_test(
317+
pre=pre,
318+
blocks=[block],
319+
post={alice: Account(nonce=1), kaboom: Account(balance=0), bob: Account(balance=100)},
320+
)

tests/amsterdam/eip7928_block_level_access_lists/test_cases.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
| `test_bal_storage_writes` | Ensure BAL captures storage writes | Alice calls contract that writes to storage slot `0x01` | BAL MUST include storage changes with correct slot and value | ✅ Completed |
88
| `test_bal_storage_reads` | Ensure BAL captures storage reads | Alice calls contract that reads from storage slot `0x01` | BAL MUST include storage access for the read operation | ✅ Completed |
99
| `test_bal_code_changes` | Ensure BAL captures changes to account code | Alice deploys factory contract that creates new contract | BAL MUST include code changes for newly deployed contract | ✅ Completed |
10-
| `test_bal_2930_slot_listed_but_untouched` | Ensure 2930 access list alone doesn’t appear in BAL | Include `(KV, S=0x01)` in tx’s EIP-2930 access list; tx executes code that does **no** `SLOAD`/`SSTORE` to `S` (e.g., pure arithmetic/log). | BAL **MUST NOT** contain any entry for `(KV, S)` — neither reads nor writes — because the slot wasn’t touched. | 🟡 Planned |
10+
| `test_bal_self_destruct` | Ensure BAL captures balance changes caused by `SELFDESTRUCT` | Alice calls a contract (funded with 100 wei) that executes `SELFDESTRUCT` with Bob as its recipient | BAL MUST include Alice's nonce change (increment), the self-destructing contract's balance change (100 → 0), and Bob's balance change (0 → 100) | ✅ Completed |
11+
| `test_bal_2930_slot_listed_but_untouched` | Ensure 2930 access list alone doesn't appear in BAL | Include `(KV, S=0x01)` in tx's EIP-2930 access list; tx executes code that does **no** `SLOAD`/`SSTORE` to `S` (e.g., pure arithmetic/log). | BAL **MUST NOT** contain any entry for `(KV, S)` — neither reads nor writes — because the slot wasn't touched. | 🟡 Planned |
1112
| `test_bal_2930_slot_listed_and_modified` | Ensure BAL records writes only because the slot is touched | Same access list as above, but tx executes `SSTORE` to `S`. | BAL **MUST** include `storage_changes` for `(KV, S)` (and no separate read record for that slot if implementation deduplicates). Presence in the access list is irrelevant; inclusion is due to the actual write. | 🟡 Planned |
1213
| `test_bal_7702_delegated_create` | BAL tracks EIP-7702 delegation indicator write and contract creation | Alice sends a type-4 (7702) tx authorizing herself to delegate to `Deployer` code which executes `CREATE` | BAL MUST include for **Alice**: `code_changes` (delegation indicator), `nonce_changes` (increment from 7702 processing), and `balance_changes` (post-gas). For **Child**: `code_changes` (runtime bytecode) and `nonce_changes = 1`. | 🟡 Planned |
1314
| `test_bal_self_transfer` | BAL handles self-transfers correctly | Alice sends `1 ETH` to **Alice** | BAL MUST include **one** entry for Alice with `balance_changes` reflecting **gas only** (value cancels out) and a nonce change; Coinbase balance updated for fees; no separate recipient row. | 🟡 Planned |

0 commit comments

Comments
 (0)