diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index 06ccb0380f..84704a1313 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -65,11 +65,8 @@ type callTrace struct { // callTracerTest defines a single test to check the call tracer against. type callTracerTest struct { - Genesis *core.Genesis `json:"genesis"` - Context *traceContext `json:"context"` - Input string `json:"input"` - TracerConfig json.RawMessage `json:"tracerConfig"` - Result *callTrace `json:"result"` + tracerTestEnv + Result *callTrace `json:"result"` } // Iterates over all the input-output datasets in the tracer test harness and diff --git a/eth/tracers/internal/tracetest/flat_calltrace_test.go b/eth/tracers/internal/tracetest/flat_calltrace_test.go index 745561ee4b..c89e79d77e 100644 --- a/eth/tracers/internal/tracetest/flat_calltrace_test.go +++ b/eth/tracers/internal/tracetest/flat_calltrace_test.go @@ -61,11 +61,8 @@ type flatCallTraceResult struct { // flatCallTracerTest defines a single test to check the call tracer against. type flatCallTracerTest struct { - Genesis *core.Genesis `json:"genesis"` - Context *traceContext `json:"context"` - Input string `json:"input"` - TracerConfig json.RawMessage `json:"tracerConfig"` - Result []flatCallTrace `json:"result"` + tracerTestEnv + Result []flatCallTrace `json:"result"` } func flatCallTracerTestRunner(tracerName string, filename string, dirPath string, t testing.TB) error { diff --git a/eth/tracers/internal/tracetest/prestate_test.go b/eth/tracers/internal/tracetest/prestate_test.go index e8960b8195..481d95897e 100644 --- a/eth/tracers/internal/tracetest/prestate_test.go +++ b/eth/tracers/internal/tracetest/prestate_test.go @@ -43,13 +43,10 @@ type account struct { Storage map[common.Hash]common.Hash `json:"storage"` } -// testcase defines a single test to check the stateDiff tracer against. -type testcase struct { - Genesis *core.Genesis `json:"genesis"` - Context *traceContext `json:"context"` - Input string `json:"input"` - TracerConfig json.RawMessage `json:"tracerConfig"` - Result interface{} `json:"result"` +// prestateTracerTest defines a single test to check the stateDiff tracer against. +type prestateTracerTest struct { + tracerTestEnv + Result interface{} `json:"result"` } func TestPrestateTracerLegacy(t *testing.T) { @@ -78,7 +75,7 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) { t.Parallel() var ( - test = new(testcase) + test = new(prestateTracerTest) tx = new(types.Transaction) ) // Call tracer test found, read if from disk diff --git a/eth/tracers/internal/tracetest/util.go b/eth/tracers/internal/tracetest/util.go index 6aa15c209c..347286b468 100644 --- a/eth/tracers/internal/tracetest/util.go +++ b/eth/tracers/internal/tracetest/util.go @@ -1,6 +1,7 @@ package tracetest import ( + "encoding/json" "math/big" "strings" "unicode" @@ -54,3 +55,11 @@ func (c *traceContext) toBlockContext(genesis *core.Genesis) vm.BlockContext { } return context } + +// tracerTestEnv defines a tracer test required fields +type tracerTestEnv struct { + Genesis *core.Genesis `json:"genesis"` + Context *traceContext `json:"context"` + Input string `json:"input"` + TracerConfig json.RawMessage `json:"tracerConfig"` +}