aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/trie_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-24 19:11:00 +0800
committerobscuren <geffobscura@gmail.com>2014-02-24 19:11:00 +0800
commit1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0 (patch)
tree20a96e133bf40c54c963e90fdd49f5987597a355 /ethutil/trie_test.go
parent377c9951033d4f8d157221fd36d15c39ae17cddc (diff)
downloadgo-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.tar
go-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.tar.gz
go-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.tar.bz2
go-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.tar.lz
go-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.tar.xz
go-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.tar.zst
go-tangerine-1a98bbf1c858ed4bafcc7ffa146a30e40ef919b0.zip
Added a trie iterator
Diffstat (limited to 'ethutil/trie_test.go')
-rw-r--r--ethutil/trie_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go
index 9d2c8e19f..c3a8f224d 100644
--- a/ethutil/trie_test.go
+++ b/ethutil/trie_test.go
@@ -1,6 +1,7 @@
package ethutil
import (
+ "fmt"
"reflect"
"testing"
)
@@ -21,6 +22,10 @@ func (db *MemDatabase) Put(key []byte, value []byte) {
func (db *MemDatabase) Get(key []byte) ([]byte, error) {
return db.db[string(key)], nil
}
+func (db *MemDatabase) Delete(key []byte) error {
+ delete(db.db, string(key))
+ return nil
+}
func (db *MemDatabase) Print() {}
func (db *MemDatabase) Close() {}
func (db *MemDatabase) LastKnownTD() []byte { return nil }
@@ -148,3 +153,22 @@ func TestTrieDeleteWithValue(t *testing.T) {
}
}
+
+func TestTrieIterator(t *testing.T) {
+ _, trie := New()
+ trie.Update("c", LONG_WORD)
+ trie.Update("ca", LONG_WORD)
+ trie.Update("cat", LONG_WORD)
+
+ it := trie.NewIterator()
+ fmt.Println("purging")
+ fmt.Println("len =", it.Purge())
+ /*
+ for it.Next() {
+ k := it.Key()
+ v := it.Value()
+
+ fmt.Println(k, v)
+ }
+ */
+}