aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/trie_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-15 06:56:09 +0800
committerobscuren <geffobscura@gmail.com>2014-02-15 06:56:09 +0800
commitf6d1bfe45bf3709d7bad40bf563b5c09228622e3 (patch)
treedf48311a5a494c66c74dcd51f1056cc699f01507 /ethutil/trie_test.go
parentc2fb9f06ad018d01ce335c82b3542de16045a32d (diff)
downloadgo-tangerine-f6d1bfe45bf3709d7bad40bf563b5c09228622e3.tar.gz
go-tangerine-f6d1bfe45bf3709d7bad40bf563b5c09228622e3.tar.zst
go-tangerine-f6d1bfe45bf3709d7bad40bf563b5c09228622e3.zip
The great merge
Diffstat (limited to 'ethutil/trie_test.go')
-rw-r--r--ethutil/trie_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go
new file mode 100644
index 000000000..b87d35e1a
--- /dev/null
+++ b/ethutil/trie_test.go
@@ -0,0 +1,40 @@
+package ethutil
+
+import (
+ _ "encoding/hex"
+ _ "fmt"
+ "testing"
+)
+
+type MemDatabase struct {
+ db map[string][]byte
+}
+
+func NewMemDatabase() (*MemDatabase, error) {
+ db := &MemDatabase{db: make(map[string][]byte)}
+ return db, nil
+}
+func (db *MemDatabase) Put(key []byte, value []byte) {
+ db.db[string(key)] = value
+}
+func (db *MemDatabase) Get(key []byte) ([]byte, error) {
+ return db.db[string(key)], nil
+}
+func (db *MemDatabase) Print() {}
+func (db *MemDatabase) Close() {}
+func (db *MemDatabase) LastKnownTD() []byte { return nil }
+
+func TestTrieSync(t *testing.T) {
+ db, _ := NewMemDatabase()
+ trie := NewTrie(db, "")
+
+ trie.Update("dog", "kindofalongsentencewhichshouldbeencodedinitsentirety")
+ if len(db.db) != 0 {
+ t.Error("Expected no data in database")
+ }
+
+ trie.Sync()
+ if len(db.db) == 0 {
+ t.Error("Expected data to be persisted")
+ }
+}