Fixed a minor issue where a string is expected but returns slice

This commit is contained in:
obscuren 2014-02-25 10:50:53 +01:00
parent 0afdedb01a
commit b30b9ab8cb
2 changed files with 9 additions and 12 deletions

View File

@ -439,7 +439,7 @@ func (it *TrieIterator) workNode(currentNode *Value) {
if currentNode.Len() == 2 { if currentNode.Len() == 2 {
k := CompactDecode(currentNode.Get(0).Str()) k := CompactDecode(currentNode.Get(0).Str())
if currentNode.Get(1).IsSlice() { if currentNode.Get(1).Str() == "" {
it.workNode(currentNode.Get(1)) it.workNode(currentNode.Get(1))
} else { } else {
if k[len(k)-1] == 16 { if k[len(k)-1] == 16 {
@ -454,7 +454,7 @@ func (it *TrieIterator) workNode(currentNode *Value) {
if i == 16 && currentNode.Get(i).Len() != 0 { if i == 16 && currentNode.Get(i).Len() != 0 {
it.values = append(it.values, currentNode.Get(i).Str()) it.values = append(it.values, currentNode.Get(i).Str())
} else { } else {
if currentNode.Get(i).IsSlice() { if currentNode.Get(i).Str() == "" {
it.workNode(currentNode.Get(i)) it.workNode(currentNode.Get(i))
} else { } else {
val := currentNode.Get(i).Str() val := currentNode.Get(i).Str()

View File

@ -1,7 +1,6 @@
package ethutil package ethutil
import ( import (
"fmt"
"reflect" "reflect"
"testing" "testing"
) )
@ -160,15 +159,13 @@ func TestTrieIterator(t *testing.T) {
trie.Update("ca", LONG_WORD) trie.Update("ca", LONG_WORD)
trie.Update("cat", LONG_WORD) trie.Update("cat", LONG_WORD)
lenBefore := len(trie.cache.nodes)
it := trie.NewIterator() it := trie.NewIterator()
fmt.Println("purging") if num := it.Purge(); num != 3 {
fmt.Println("len =", it.Purge()) t.Errorf("Expected purge to return 3, got %d", num)
/* }
for it.Next() {
k := it.Key()
v := it.Value()
fmt.Println(k, v) if lenBefore == len(trie.cache.nodes) {
t.Errorf("Expected cached nodes to be deleted")
} }
*/
} }