eth/tracers: use tracerTestEnv

Signed-off-by: jsvisa <delweng@gmail.com>
pull/29450/head
jsvisa 6 months ago
parent 01d1bf9212
commit 027be581c8
  1. 5
      eth/tracers/internal/tracetest/calltrace_test.go
  2. 5
      eth/tracers/internal/tracetest/flat_calltrace_test.go
  3. 11
      eth/tracers/internal/tracetest/prestate_test.go
  4. 9
      eth/tracers/internal/tracetest/util.go

@ -65,10 +65,7 @@ type callTrace struct {
// callTracerTest defines a single test to check the call tracer against. // callTracerTest defines a single test to check the call tracer against.
type callTracerTest struct { type callTracerTest struct {
Genesis *core.Genesis `json:"genesis"` tracerTestEnv
Context *traceContext `json:"context"`
Input string `json:"input"`
TracerConfig json.RawMessage `json:"tracerConfig"`
Result *callTrace `json:"result"` Result *callTrace `json:"result"`
} }

@ -61,10 +61,7 @@ type flatCallTraceResult struct {
// flatCallTracerTest defines a single test to check the call tracer against. // flatCallTracerTest defines a single test to check the call tracer against.
type flatCallTracerTest struct { type flatCallTracerTest struct {
Genesis *core.Genesis `json:"genesis"` tracerTestEnv
Context *traceContext `json:"context"`
Input string `json:"input"`
TracerConfig json.RawMessage `json:"tracerConfig"`
Result []flatCallTrace `json:"result"` Result []flatCallTrace `json:"result"`
} }

@ -43,12 +43,9 @@ type account struct {
Storage map[common.Hash]common.Hash `json:"storage"` Storage map[common.Hash]common.Hash `json:"storage"`
} }
// testcase defines a single test to check the stateDiff tracer against. // prestateTracerTest defines a single test to check the stateDiff tracer against.
type testcase struct { type prestateTracerTest struct {
Genesis *core.Genesis `json:"genesis"` tracerTestEnv
Context *traceContext `json:"context"`
Input string `json:"input"`
TracerConfig json.RawMessage `json:"tracerConfig"`
Result interface{} `json:"result"` Result interface{} `json:"result"`
} }
@ -78,7 +75,7 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
test = new(testcase) test = new(prestateTracerTest)
tx = new(types.Transaction) tx = new(types.Transaction)
) )
// Call tracer test found, read if from disk // Call tracer test found, read if from disk

@ -1,6 +1,7 @@
package tracetest package tracetest
import ( import (
"encoding/json"
"math/big" "math/big"
"strings" "strings"
"unicode" "unicode"
@ -54,3 +55,11 @@ func (c *traceContext) toBlockContext(genesis *core.Genesis) vm.BlockContext {
} }
return context 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"`
}

Loading…
Cancel
Save