aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-03 19:15:58 +0800
committerobscuren <geffobscura@gmail.com>2015-03-03 19:15:58 +0800
commitbf5365b317ba5767feb28eef9abb83328bfea099 (patch)
treee94f168015064389e59fe46331fc70d32339e4eb
parentba0a758d8c7c574047d5d4ece9fde0b42a62fc6f (diff)
downloadgo-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.tar
go-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.tar.gz
go-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.tar.bz2
go-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.tar.lz
go-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.tar.xz
go-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.tar.zst
go-tangerine-bf5365b317ba5767feb28eef9abb83328bfea099.zip
Delet => Delete
-rw-r--r--trie/secure_trie.go2
-rw-r--r--trie/trie_test.go32
2 files changed, 33 insertions, 1 deletions
diff --git a/trie/secure_trie.go b/trie/secure_trie.go
index c6ef90351..f49547ed8 100644
--- a/trie/secure_trie.go
+++ b/trie/secure_trie.go
@@ -27,6 +27,6 @@ func (self *SecureTrie) GetString(key string) []byte {
func (self *SecureTrie) Delete(key []byte) Node {
return self.Trie.Delete(crypto.Sha3(key))
}
-func (self *SecureTrie) DeletString(key string) Node {
+func (self *SecureTrie) DeleteString(key string) Node {
return self.Delete([]byte(key))
}
diff --git a/trie/trie_test.go b/trie/trie_test.go
index 4b0243bcf..92e0df8e2 100644
--- a/trie/trie_test.go
+++ b/trie/trie_test.go
@@ -19,6 +19,10 @@ func NewEmpty() *Trie {
return New(nil, make(Db))
}
+func NewEmptySecure() *SecureTrie {
+ return NewSecure(nil, make(Db))
+}
+
func TestEmptyTrie(t *testing.T) {
trie := NewEmpty()
res := trie.Hash()
@@ -295,3 +299,31 @@ func TestLargeData(t *testing.T) {
}
}
}
+
+func TestSecureDelete(t *testing.T) {
+ trie := NewEmptySecure()
+
+ vals := []struct{ k, v string }{
+ {"do", "verb"},
+ {"ether", "wookiedoo"},
+ {"horse", "stallion"},
+ {"shaman", "horse"},
+ {"doge", "coin"},
+ {"ether", ""},
+ {"dog", "puppy"},
+ {"shaman", ""},
+ }
+ for _, val := range vals {
+ if val.v != "" {
+ trie.UpdateString(val.k, val.v)
+ } else {
+ trie.DeleteString(val.k)
+ }
+ }
+
+ hash := trie.Hash()
+ exp := ethutil.Hex2Bytes("29b235a58c3c25ab83010c327d5932bcf05324b7d6b1185e650798034783ca9d")
+ if !bytes.Equal(hash, exp) {
+ t.Errorf("expected %x got %x", exp, hash)
+ }
+}