diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-18 19:18:27 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-18 19:18:27 +0800 |
commit | e08aba5dd9f1e481aab18c6c062c97e0e400f75b (patch) | |
tree | 491d0f51f80d99d52cf5266d5d4c2f656f4155e7 | |
parent | 34f29d57b6790a38019a8bcef51a6e91d2945cbe (diff) | |
download | dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.tar dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.tar.gz dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.tar.bz2 dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.tar.lz dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.tar.xz dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.tar.zst dexon-e08aba5dd9f1e481aab18c6c062c97e0e400f75b.zip |
added output test
-rw-r--r-- | ptrie/trie.go | 2 | ||||
-rw-r--r-- | ptrie/trie_test.go | 19 | ||||
-rw-r--r-- | trie/trie_test.go | 3 |
3 files changed, 22 insertions, 2 deletions
diff --git a/ptrie/trie.go b/ptrie/trie.go index 3e642b334..207aad91e 100644 --- a/ptrie/trie.go +++ b/ptrie/trie.go @@ -45,6 +45,8 @@ func New(root []byte, backend Backend) *Trie { return trie } +// Legacy support +func (self *Trie) Root() []byte { return self.Hash() } func (self *Trie) Hash() []byte { var hash []byte if self.root != nil { diff --git a/ptrie/trie_test.go b/ptrie/trie_test.go index 29380d3f0..8b98f4408 100644 --- a/ptrie/trie_test.go +++ b/ptrie/trie_test.go @@ -132,7 +132,24 @@ func BenchmarkUpdate(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - trie.UpdateString(fmt.Sprintf("aaaaaaaaaaaaaaa%d", j), "value") + trie.UpdateString(fmt.Sprintf("aaaaaaaaa%d", base, i), "value") } trie.Hash() } + +// Not actual test +func TestOutput(t *testing.T) { + base := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + trie := NewEmpty() + for i := 0; i < 50; i++ { + trie.UpdateString(fmt.Sprintf("%s%d", base, i), "valueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") + } + trie.Hash() + fmt.Println("############################## FULL ################################") + fmt.Println(trie.root) + + trie2 := New(trie.roothash, trie.backend) + trie2.GetString(base + "20") + fmt.Println("############################## SMALL ################################") + fmt.Println(trie2.root) +} diff --git a/trie/trie_test.go b/trie/trie_test.go index d00671c6a..9a21fd805 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -497,6 +497,7 @@ func BenchmarkUpdate(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - trie.Update(fmt.Sprintf("aaaaaaaaaaaaaaa%d", j), "value") + trie.Update(fmt.Sprintf("aaaaaaaaaaaaaaa%d", i), "value") } + fmt.Println(trie.root) } |