MCPcopy Create free account
hub / github.com/CPChain/chain / withTrace

Function withTrace

tests/state_test.go:65–89  ·  view source on GitHub ↗
(t *testing.T, gasLimit uint64, test func(vm.Config) error)

Source from the content-addressed store, hash-verified

63const traceErrorLimit = 400000
64
65func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
66 err := test(vm.Config{})
67 if err == nil {
68 return
69 }
70 t.Error(err)
71 if gasLimit > traceErrorLimit {
72 t.Log("gas limit too high for EVM trace")
73 return
74 }
75 tracer := vm.NewStructLogger(nil)
76 err2 := test(vm.Config{Debug: true, Tracer: tracer})
77 if !reflect.DeepEqual(err, err2) {
78 t.Errorf("different error for second run: %v", err2)
79 }
80 buf := new(bytes.Buffer)
81 vm.WriteTrace(buf, tracer.StructLogs())
82 if buf.Len() == 0 {
83 t.Log("no EVM operation logs generated")
84 } else {
85 t.Log("EVM operation log:\n" + buf.String())
86 }
87 t.Logf("EVM output: 0x%x", tracer.Output())
88 t.Logf("EVM error: %v", tracer.Error())
89}

Callers 2

TestVMFunction · 0.85
TestStateFunction · 0.85

Calls 6

StructLogsMethod · 0.95
OutputMethod · 0.95
ErrorMethod · 0.95
ErrorMethod · 0.65
LenMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected