Official Go implementation of the Ethereum protocol
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TestSource struct {
|
|
|
|
Inputs map[string]string
|
|
|
|
Expectation string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestSource(source string) *TestSource {
|
|
|
|
s := &TestSource{}
|
|
|
|
err := json.Unmarshal([]byte(source), s)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
type TestRunner struct {
|
|
|
|
source *TestSource
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestRunner(t *testing.T) *TestRunner {
|
|
|
|
return &TestRunner{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (runner *TestRunner) RunFromString(input string, Cb func(*TestSource)) {
|
|
|
|
source := NewTestSource(input)
|
|
|
|
Cb(source)
|
|
|
|
}
|