aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/trie_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethutil/trie_test.go')
-rw-r--r--ethutil/trie_test.go36
1 files changed, 34 insertions, 2 deletions
diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go
index fa60c8cfc..9d2c8e19f 100644
--- a/ethutil/trie_test.go
+++ b/ethutil/trie_test.go
@@ -1,8 +1,7 @@
package ethutil
import (
- _ "encoding/hex"
- _ "fmt"
+ "reflect"
"testing"
)
@@ -116,3 +115,36 @@ func TestTrieCmp(t *testing.T) {
t.Errorf("Expected tries not to be equal %x %x", trie1.Root, trie2.Root)
}
}
+
+func TestTrieDelete(t *testing.T) {
+ _, trie := New()
+ trie.Update("cat", LONG_WORD)
+ exp := trie.Root
+ trie.Update("dog", LONG_WORD)
+ trie.Delete("dog")
+ if !reflect.DeepEqual(exp, trie.Root) {
+ t.Errorf("Expected tries to be equal %x : %x", exp, trie.Root)
+ }
+
+ trie.Update("dog", LONG_WORD)
+ exp = trie.Root
+ trie.Update("dude", LONG_WORD)
+ trie.Delete("dude")
+ if !reflect.DeepEqual(exp, trie.Root) {
+ t.Errorf("Expected tries to be equal %x : %x", exp, trie.Root)
+ }
+}
+
+func TestTrieDeleteWithValue(t *testing.T) {
+ _, trie := New()
+ trie.Update("c", LONG_WORD)
+ exp := trie.Root
+ trie.Update("ca", LONG_WORD)
+ trie.Update("cat", LONG_WORD)
+ trie.Delete("ca")
+ trie.Delete("cat")
+ if !reflect.DeepEqual(exp, trie.Root) {
+ t.Errorf("Expected tries to be equal %x : %x", exp, trie.Root)
+ }
+
+}