| 63 | const traceErrorLimit = 400000 |
| 64 | |
| 65 | func 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 | } |