diff options
Diffstat (limited to 'ethutil')
-rw-r--r-- | ethutil/trie_test.go | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go index c89f2fbb7..15dbc5567 100644 --- a/ethutil/trie_test.go +++ b/ethutil/trie_test.go @@ -1,7 +1,12 @@ package ethutil import ( + "bytes" + "encoding/json" "fmt" + "io" + "io/ioutil" + "net/http" "reflect" "testing" ) @@ -171,14 +176,34 @@ func TestTriePurge(t *testing.T) { } } +type TestItem struct { + Name string + Inputs [][]string + Expectations string +} + func TestTrieIt(t *testing.T) { - _, trie := New() - trie.Update("c", LONG_WORD) - trie.Update("ca", LONG_WORD) - trie.Update("cat", LONG_WORD) + //_, trie := New() + resp, err := http.Get("https://raw.githubusercontent.com/ethereum/tests/master/trietest.json") + if err != nil { + t.Fail() + } - it := trie.NewIterator() - it.Each(func(key string, node *Value) { - fmt.Println(key, ":", node.Str()) - }) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Fail() + } + + dec := json.NewDecoder(bytes.NewReader(body)) + for { + var test TestItem + if err := dec.Decode(&test); err == io.EOF { + break + } else if err != nil { + t.Error("Fail something", err) + break + } + fmt.Println(test) + } } |