Skip to content

Commit ac1e471

Browse files
committed
fix(tests): Fix expectations for self-destruct tests
1 parent b290901 commit ac1e471

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""Tests for EIP-7928 using the consistent data class pattern."""
22

3+
from typing import Dict
4+
35
import pytest
46

7+
from ethereum_test_base_types import Address
58
from ethereum_test_tools import (
69
Account,
710
Alloc,
@@ -335,13 +338,12 @@ def test_bal_self_destruct(
335338
factory = pre.deploy_contract(code=factory_bytecode)
336339
kaboom_same_tx = compute_create_address(address=factory, nonce=1)
337340

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+
339344
if pre_funded:
340345
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)
345347

346348
tx = Transaction(
347349
sender=alice,
@@ -351,9 +353,6 @@ def test_bal_self_destruct(
351353
gas_price=0xA,
352354
)
353355

354-
# Determine which account was destructed
355-
self_destructed_account = kaboom_same_tx if self_destruct_in_same_tx else kaboom
356-
357356
block = Block(
358357
txs=[tx],
359358
expected_block_access_list=BlockAccessListExpectation(
@@ -370,16 +369,25 @@ def test_bal_self_destruct(
370369
balance_changes=[BalBalanceChange(tx_index=1, post_balance=0)]
371370
if pre_funded
372371
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 [],
375383
code_changes=[], # should not be present
376384
nonce_changes=[], # should not be present
377385
),
378386
}
379387
),
380388
)
381389

382-
post = {
390+
post: Dict[Address, Account] = {
383391
alice: Account(nonce=1),
384392
bob: Account(balance=expected_recipient_balance),
385393
}

0 commit comments

Comments
 (0)