aboutsummaryrefslogtreecommitdiffstats
path: root/test_runner_test.go
blob: 5c8461ad89baf920c5d5e823f13c4b25156cac80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
    "encoding/hex"
    _ "fmt"
    "github.com/ethereum/ethdb-go"
    "github.com/ethereum/ethutil-go"
    "testing"
)

var testsource = `
{
    "inputs":{
        "doe": "reindeer",
        "dog": "puppy",
        "dogglesworth": "cat"
    },
    "expectation":"e378927bfc1bd4f01a2e8d9f59bd18db8a208bb493ac0b00f93ce51d4d2af76c"
}`

func TestTestRunner(t *testing.T) {
    db, _ := ethdb.NewMemDatabase()
    trie := ethutil.NewTrie(db, "")

    runner := NewTestRunner(t)
    runner.RunFromString(testsource, func(source *TestSource) {
        for key, value := range source.Inputs {
            trie.Update(key, value)
        }
        if hex.EncodeToString(trie.Root.([]byte)) != source.Expectation {
            t.Error("trie root did not match")
        }
    })
}