@@ -31,12 +31,13 @@ import (
31
31
"github.com/ethereum/go-ethereum/crypto"
32
32
"github.com/ethereum/go-ethereum/trie"
33
33
"golang.org/x/exp/slices"
34
+ "strings"
34
35
)
35
36
36
37
var dumper = spew.ConfigState {Indent : " " }
37
38
38
- func accountRangeTest (t * testing.T , trie * state.Trie , statedb * state.StateDB , start common.Hash , requestedNum int , expectedNum int ) state.IteratorDump {
39
- result := statedb .IteratorDump (& state.DumpConfig {
39
+ func accountRangeTest (t * testing.T , trie * state.Trie , statedb * state.StateDB , start common.Hash , requestedNum int , expectedNum int ) state.Dump {
40
+ result := statedb .RawDump (& state.DumpConfig {
40
41
SkipCode : true ,
41
42
SkipStorage : true ,
42
43
OnlyWithAddresses : false ,
@@ -47,12 +48,12 @@ func accountRangeTest(t *testing.T, trie *state.Trie, statedb *state.StateDB, st
47
48
if len (result .Accounts ) != expectedNum {
48
49
t .Fatalf ("expected %d results, got %d" , expectedNum , len (result .Accounts ))
49
50
}
50
- for address := range result .Accounts {
51
- if address == (common .Address {}) {
52
- t .Fatalf ("empty address returned" )
51
+ for addr , acc := range result .Accounts {
52
+ if strings . HasSuffix ( addr , "pre" ) || acc .Address == nil {
53
+ t .Fatalf ("account without prestate ( address) returned: %v" , addr )
53
54
}
54
- if ! statedb .Exist (address ) {
55
- t .Fatalf ("account not found in state %s" , address .Hex ())
55
+ if ! statedb .Exist (* acc . Address ) {
56
+ t .Fatalf ("account not found in state %s" , acc . Address .Hex ())
56
57
}
57
58
}
58
59
return result
@@ -92,16 +93,16 @@ func TestAccountRange(t *testing.T) {
92
93
secondResult := accountRangeTest (t , & trie , sdb , common .BytesToHash (firstResult .Next ), AccountRangeMaxResults , AccountRangeMaxResults )
93
94
94
95
hList := make ([]common.Hash , 0 )
95
- for addr1 := range firstResult .Accounts {
96
- // If address is empty , then it makes no sense to compare
96
+ for addr1 , acc := range firstResult .Accounts {
97
+ // If address is non-available , then it makes no sense to compare
97
98
// them as they might be two different accounts.
98
- if addr1 == (common. Address {}) {
99
+ if acc . Address == nil {
99
100
continue
100
101
}
101
102
if _ , duplicate := secondResult .Accounts [addr1 ]; duplicate {
102
103
t .Fatalf ("pagination test failed: results should not overlap" )
103
104
}
104
- hList = append (hList , crypto .Keccak256Hash (addr1 .Bytes ()))
105
+ hList = append (hList , crypto .Keccak256Hash (acc . Address .Bytes ()))
105
106
}
106
107
// Test to see if it's possible to recover from the middle of the previous
107
108
// set and get an even split between the first and second sets.
@@ -140,7 +141,7 @@ func TestEmptyAccountRange(t *testing.T) {
140
141
st .Commit (0 , true )
141
142
st , _ = state .New (types .EmptyRootHash , statedb , nil )
142
143
143
- results := st .IteratorDump (& state.DumpConfig {
144
+ results := st .RawDump (& state.DumpConfig {
144
145
SkipCode : true ,
145
146
SkipStorage : true ,
146
147
OnlyWithAddresses : true ,
0 commit comments