diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-25 17:50:53 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-25 17:50:53 +0800 |
commit | b30b9ab8cb13ddbc68a4912c9f06116c0f59bc27 (patch) | |
tree | 13edf727b9172273315174ebfc759010a3aec8fb | |
parent | 0afdedb01a8e4203129175dc9dcc213a55906a66 (diff) | |
download | dexon-b30b9ab8cb13ddbc68a4912c9f06116c0f59bc27.tar.gz dexon-b30b9ab8cb13ddbc68a4912c9f06116c0f59bc27.tar.zst dexon-b30b9ab8cb13ddbc68a4912c9f06116c0f59bc27.zip |
Fixed a minor issue where a string is expected but returns slice
-rw-r--r-- | ethutil/trie.go | 4 | ||||
-rw-r--r-- | ethutil/trie_test.go | 19 |
2 files changed, 10 insertions, 13 deletions
diff --git a/ethutil/trie.go b/ethutil/trie.go index 83527d364..a17dc37ad 100644 --- a/ethutil/trie.go +++ b/ethutil/trie.go @@ -439,7 +439,7 @@ func (it *TrieIterator) workNode(currentNode *Value) { if currentNode.Len() == 2 { k := CompactDecode(currentNode.Get(0).Str()) - if currentNode.Get(1).IsSlice() { + if currentNode.Get(1).Str() == "" { it.workNode(currentNode.Get(1)) } else { if k[len(k)-1] == 16 { @@ -454,7 +454,7 @@ func (it *TrieIterator) workNode(currentNode *Value) { if i == 16 && currentNode.Get(i).Len() != 0 { it.values = append(it.values, currentNode.Get(i).Str()) } else { - if currentNode.Get(i).IsSlice() { + if currentNode.Get(i).Str() == "" { it.workNode(currentNode.Get(i)) } else { val := currentNode.Get(i).Str() diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go index c3a8f224d..645c5a225 100644 --- a/ethutil/trie_test.go +++ b/ethutil/trie_test.go @@ -1,7 +1,6 @@ package ethutil import ( - "fmt" "reflect" "testing" ) @@ -160,15 +159,13 @@ func TestTrieIterator(t *testing.T) { trie.Update("ca", LONG_WORD) trie.Update("cat", LONG_WORD) + lenBefore := len(trie.cache.nodes) it := trie.NewIterator() - fmt.Println("purging") - fmt.Println("len =", it.Purge()) - /* - for it.Next() { - k := it.Key() - v := it.Value() - - fmt.Println(k, v) - } - */ + if num := it.Purge(); num != 3 { + t.Errorf("Expected purge to return 3, got %d", num) + } + + if lenBefore == len(trie.cache.nodes) { + t.Errorf("Expected cached nodes to be deleted") + } } |