added output test

This commit is contained in:
obscuren 2014-11-18 12:18:27 +01:00
parent 34f29d57b6
commit e08aba5dd9
3 changed files with 22 additions and 2 deletions

View File

@ -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 {

View File

@ -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)
}

View File

@ -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)
}