go-ethereum/test_runner_test.go

32 lines
620 B
Go
Raw Normal View History

2014-01-01 08:49:38 -06:00
package main
import (
2014-01-11 08:27:08 -06:00
"encoding/hex"
_ "fmt"
"testing"
2014-01-01 08:49:38 -06:00
)
var testsource = `{"Inputs":{
"doe": "reindeer",
"dog": "puppy",
"dogglesworth": "cat"
},
"Expectation":"e378927bfc1bd4f01a2e8d9f59bd18db8a208bb493ac0b00f93ce51d4d2af76c"
}`
func TestTestRunner(t *testing.T) {
2014-01-11 08:27:08 -06:00
db, _ := NewMemDatabase()
trie := NewTrie(db, "")
2014-01-01 08:49:38 -06:00
2014-01-11 08:27:08 -06:00
runner := NewTestRunner(t)
runner.RunFromString(testsource, func(source *TestSource) {
for key, value := range source.Inputs {
trie.Update(key, value)
}
2014-01-01 08:49:38 -06:00
2014-01-11 08:27:08 -06:00
if hex.EncodeToString([]byte(trie.root)) != source.Expectation {
t.Error("trie root did not match")
}
})
2014-01-01 08:49:38 -06:00
}