|
|
@ -257,3 +257,42 @@ func BenchmarkUpdate(b *testing.B) { |
|
|
|
} |
|
|
|
} |
|
|
|
trie.Hash() |
|
|
|
trie.Hash() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type kv struct { |
|
|
|
|
|
|
|
k, v []byte |
|
|
|
|
|
|
|
t bool |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestLargeData(t *testing.T) { |
|
|
|
|
|
|
|
trie := NewEmpty() |
|
|
|
|
|
|
|
vals := make(map[string]*kv) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i := byte(1); i < 255; i++ { |
|
|
|
|
|
|
|
value := &kv{ethutil.LeftPadBytes([]byte{i}, 32), []byte{i}, false} |
|
|
|
|
|
|
|
value2 := &kv{ethutil.LeftPadBytes([]byte{10, i}, 32), []byte{i}, false} |
|
|
|
|
|
|
|
trie.Update(value.k, value.v) |
|
|
|
|
|
|
|
trie.Update(value2.k, value2.v) |
|
|
|
|
|
|
|
vals[string(value.k)] = value |
|
|
|
|
|
|
|
vals[string(value2.k)] = value2 |
|
|
|
|
|
|
|
fmt.Println(value, "\n", value2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it := trie.Iterator() |
|
|
|
|
|
|
|
for it.Next() { |
|
|
|
|
|
|
|
vals[string(it.Key)].t = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var untouched []*kv |
|
|
|
|
|
|
|
for _, value := range vals { |
|
|
|
|
|
|
|
if !value.t { |
|
|
|
|
|
|
|
untouched = append(untouched, value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(untouched) > 0 { |
|
|
|
|
|
|
|
t.Errorf("Missed %d nodes", len(untouched)) |
|
|
|
|
|
|
|
for _, value := range untouched { |
|
|
|
|
|
|
|
t.Error(value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|