Updated test

This commit is contained in:
obscuren 2014-06-18 13:48:29 +02:00
parent 3bc57fe5b5
commit c4af1340fa

View File

@ -1,12 +1,7 @@
package ethutil package ethutil
import ( import (
"bytes"
"encoding/json"
"fmt" "fmt"
"io"
"io/ioutil"
"net/http"
"reflect" "reflect"
"testing" "testing"
) )
@ -176,34 +171,23 @@ func TestTriePurge(t *testing.T) {
} }
} }
type TestItem struct {
Name string
Inputs [][]string
Expectations string
}
func TestTrieIt(t *testing.T) { func TestTrieIt(t *testing.T) {
//_, trie := New() _, trie := New()
resp, err := http.Get("https://raw.githubusercontent.com/ethereum/tests/master/trietest.json")
if err != nil { data := [][]string{
t.Fail() {"do", "verb"},
{"ether", "wookiedoo"},
{"horse", "stallion"},
{"shaman", "horse"},
{"doge", "coin"},
{"ether", ""},
{"dog", "puppy"},
{"shaman", ""},
} }
defer resp.Body.Close() for _, item := range data {
body, err := ioutil.ReadAll(resp.Body) trie.Update(item[0], item[1])
if err != nil {
t.Fail()
} }
dec := json.NewDecoder(bytes.NewReader(body)) fmt.Printf("root %x", trie.Root)
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)
}
} }