1
1
"""Tests for EIP-7928 using the consistent data class pattern."""
2
2
3
+ from typing import Dict
4
+
3
5
import pytest
4
6
7
+ from ethereum_test_base_types import Address
5
8
from ethereum_test_tools import (
6
9
Account ,
7
10
Alloc ,
@@ -335,13 +338,12 @@ def test_bal_self_destruct(
335
338
factory = pre .deploy_contract (code = factory_bytecode )
336
339
kaboom_same_tx = compute_create_address (address = factory , nonce = 1 )
337
340
338
- # Pre fund the accounts in pre state
341
+ # Determine which account will be self-destructed
342
+ self_destructed_account = kaboom_same_tx if self_destruct_in_same_tx else kaboom
343
+
339
344
if pre_funded :
340
345
expected_recipient_balance += pre_fund_amount
341
- if self_destruct_in_same_tx :
342
- pre .fund_address (address = kaboom_same_tx , amount = pre_fund_amount )
343
- else :
344
- pre .fund_address (address = kaboom , amount = pre_fund_amount )
346
+ pre .fund_address (address = self_destructed_account , amount = pre_fund_amount )
345
347
346
348
tx = Transaction (
347
349
sender = alice ,
@@ -351,9 +353,6 @@ def test_bal_self_destruct(
351
353
gas_price = 0xA ,
352
354
)
353
355
354
- # Determine which account was destructed
355
- self_destructed_account = kaboom_same_tx if self_destruct_in_same_tx else kaboom
356
-
357
356
block = Block (
358
357
txs = [tx ],
359
358
expected_block_access_list = BlockAccessListExpectation (
@@ -370,16 +369,25 @@ def test_bal_self_destruct(
370
369
balance_changes = [BalBalanceChange (tx_index = 1 , post_balance = 0 )]
371
370
if pre_funded
372
371
else [],
373
- storage_reads = [0x01 , 0x42 ], # Accessed slots to be recorded as reads
374
- storage_changes = [],
372
+ # Accessed slots for same-tx are recorded as reads (0x02)
373
+ storage_reads = [0x01 , 0x02 ] if self_destruct_in_same_tx else [0x01 ],
374
+ # Storage changes are recorded for non-same-tx
375
+ # self-destructs
376
+ storage_changes = [
377
+ BalStorageSlot (
378
+ slot = 0x02 , slot_changes = [BalStorageChange (tx_index = 1 , post_value = 0x42 )]
379
+ )
380
+ ]
381
+ if not self_destruct_in_same_tx
382
+ else [],
375
383
code_changes = [], # should not be present
376
384
nonce_changes = [], # should not be present
377
385
),
378
386
}
379
387
),
380
388
)
381
389
382
- post = {
390
+ post : Dict [ Address , Account ] = {
383
391
alice : Account (nonce = 1 ),
384
392
bob : Account (balance = expected_recipient_balance ),
385
393
}
0 commit comments