aboutsummaryrefslogtreecommitdiffstats
path: root/trie/trie_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-08 00:03:22 +0800
committerobscuren <geffobscura@gmail.com>2015-02-08 00:03:22 +0800
commit99ebb869bf15e04db7b000fde2894387f2927bb6 (patch)
treed9c426542f0f6aa8c45eeedde5f8eaef4fbceb28 /trie/trie_test.go
parent44eafb15e0581ef37c3e3cfeccb703381acc2ae2 (diff)
downloaddexon-99ebb869bf15e04db7b000fde2894387f2927bb6.tar
dexon-99ebb869bf15e04db7b000fde2894387f2927bb6.tar.gz
dexon-99ebb869bf15e04db7b000fde2894387f2927bb6.tar.bz2
dexon-99ebb869bf15e04db7b000fde2894387f2927bb6.tar.lz
dexon-99ebb869bf15e04db7b000fde2894387f2927bb6.tar.xz
dexon-99ebb869bf15e04db7b000fde2894387f2927bb6.tar.zst
dexon-99ebb869bf15e04db7b000fde2894387f2927bb6.zip
Fixed iterator
Diffstat (limited to 'trie/trie_test.go')
-rw-r--r--trie/trie_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/trie/trie_test.go b/trie/trie_test.go
index ffb78d4f2..4b185f355 100644
--- a/trie/trie_test.go
+++ b/trie/trie_test.go
@@ -257,3 +257,42 @@ func BenchmarkUpdate(b *testing.B) {
}
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)
+ }
+ }
+}