Skip to content

Commit e8ffcda

Browse files
committed
cmd/devp2p/internal/ethtest: rebase updates
1 parent 54e523d commit e8ffcda

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

cmd/devp2p/internal/ethtest/chain.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ func (c *Chain) AccountsInHashOrder() []state.DumpAccount {
103103
addr := addr
104104
list[i] = acc
105105
list[i].Address = &addr
106-
if len(acc.SecureKey) != 32 {
106+
if len(acc.AddressHash) != 32 {
107107
panic(fmt.Errorf("missing/invalid SecureKey in dump account %v", addr))
108108
}
109109
i++
110110
}
111111
slices.SortFunc(list, func(x, y state.DumpAccount) int {
112-
return bytes.Compare(x.SecureKey, y.SecureKey)
112+
return bytes.Compare(x.AddressHash, y.AddressHash)
113113
})
114114
return list
115115
}
@@ -317,7 +317,16 @@ func readState(file string) (map[common.Address]state.DumpAccount, error) {
317317
if err := json.Unmarshal(f, &dump); err != nil {
318318
return nil, fmt.Errorf("unable to unmarshal state: %v", err)
319319
}
320-
return dump.Accounts, nil
320+
321+
state := make(map[common.Address]state.DumpAccount)
322+
for key, acct := range dump.Accounts {
323+
var addr common.Address
324+
if err := addr.UnmarshalText([]byte(key)); err != nil {
325+
return nil, fmt.Errorf("invalid address %q", key)
326+
}
327+
state[addr] = acct
328+
}
329+
return state, nil
321330
}
322331

323332
func readAccounts(file string) (map[common.Address]*senderInfo, error) {

cmd/devp2p/internal/ethtest/snap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func (s *Suite) TestSnapGetAccountRange(t *utesting.T) {
7575
// test values derived from chain/ account dump
7676
root = s.chain.Head().Root()
7777
headstate = s.chain.AccountsInHashOrder()
78-
firstKey = common.BytesToHash(headstate[0].SecureKey)
79-
secondKey = common.BytesToHash(headstate[1].SecureKey)
78+
firstKey = common.BytesToHash(headstate[0].AddressHash)
79+
secondKey = common.BytesToHash(headstate[1].AddressHash)
8080
storageRoot = findNonEmptyStorageRoot(headstate)
8181
)
8282

@@ -333,7 +333,7 @@ type stRangesTest struct {
333333
func (s *Suite) TestSnapGetStorageRanges(t *utesting.T) {
334334
var (
335335
acct = common.HexToAddress("0x8bebc8ba651aee624937e7d897853ac30c95a067")
336-
acctHash = common.BytesToHash(s.chain.state[acct].SecureKey)
336+
acctHash = common.BytesToHash(s.chain.state[acct].AddressHash)
337337
ffHash = common.MaxHash
338338
zero = common.Hash{}
339339
blockroot = s.chain.Head().Root()
@@ -597,7 +597,7 @@ func (s *Suite) TestSnapTrieNodes(t *utesting.T) {
597597
var (
598598
// This is the known address of the snap storage testing contract.
599599
storageAcct = common.HexToAddress("0x8bebc8ba651aee624937e7d897853ac30c95a067")
600-
storageAcctHash = common.BytesToHash(s.chain.state[storageAcct].SecureKey)
600+
storageAcctHash = common.BytesToHash(s.chain.state[storageAcct].AddressHash)
601601
// This is the known address of an existing account.
602602
key = common.FromHex("0xa87387b50b481431c6ccdb9ae99a54d4dcdd4a3eff75d7b17b4818f7bbfc21e9")
603603
empty = types.EmptyCodeHash

0 commit comments

Comments
 (0)