forked from cerc-io/plugeth
eth/tracers: refactor traceTx to separate out struct logging (#24326)
* eth/tracers: refactor traceTx to separate out struct logging review fix Update eth/tracers/api.go Co-authored-by: Martin Holst Swende <martin@swende.se> Mv ExecutionResult type to logger package review fix impl GetResult for StructLogger make formatLogs private confused exit and end.. account for intrinsicGas in structlogger, fix TraceCall test Add Stop method to logger Simplify traceTx Fix test rm logger from blockchain test account for refund in structLogger * use tx hooks in struct logger * minor * avoid executionResult in struct logger * revert blockchain test changes
This commit is contained in:
co-authored by
Martin Holst Swende
parent
0654014652
commit
fb3a081c7e
+21
-12
@@ -39,6 +39,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
@@ -213,11 +214,11 @@ func TestTraceCall(t *testing.T) {
|
||||
},
|
||||
config: nil,
|
||||
expectErr: nil,
|
||||
expect: ðapi.ExecutionResult{
|
||||
expect: &logger.ExecutionResult{
|
||||
Gas: params.TxGas,
|
||||
Failed: false,
|
||||
ReturnValue: "",
|
||||
StructLogs: []ethapi.StructLogRes{},
|
||||
StructLogs: []logger.StructLogRes{},
|
||||
},
|
||||
},
|
||||
// Standard JSON trace upon the head, plain transfer.
|
||||
@@ -230,11 +231,11 @@ func TestTraceCall(t *testing.T) {
|
||||
},
|
||||
config: nil,
|
||||
expectErr: nil,
|
||||
expect: ðapi.ExecutionResult{
|
||||
expect: &logger.ExecutionResult{
|
||||
Gas: params.TxGas,
|
||||
Failed: false,
|
||||
ReturnValue: "",
|
||||
StructLogs: []ethapi.StructLogRes{},
|
||||
StructLogs: []logger.StructLogRes{},
|
||||
},
|
||||
},
|
||||
// Standard JSON trace upon the non-existent block, error expects
|
||||
@@ -259,11 +260,11 @@ func TestTraceCall(t *testing.T) {
|
||||
},
|
||||
config: nil,
|
||||
expectErr: nil,
|
||||
expect: ðapi.ExecutionResult{
|
||||
expect: &logger.ExecutionResult{
|
||||
Gas: params.TxGas,
|
||||
Failed: false,
|
||||
ReturnValue: "",
|
||||
StructLogs: []ethapi.StructLogRes{},
|
||||
StructLogs: []logger.StructLogRes{},
|
||||
},
|
||||
},
|
||||
// Standard JSON trace upon the pending block
|
||||
@@ -276,11 +277,11 @@ func TestTraceCall(t *testing.T) {
|
||||
},
|
||||
config: nil,
|
||||
expectErr: nil,
|
||||
expect: ðapi.ExecutionResult{
|
||||
expect: &logger.ExecutionResult{
|
||||
Gas: params.TxGas,
|
||||
Failed: false,
|
||||
ReturnValue: "",
|
||||
StructLogs: []ethapi.StructLogRes{},
|
||||
StructLogs: []logger.StructLogRes{},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -299,8 +300,12 @@ func TestTraceCall(t *testing.T) {
|
||||
t.Errorf("Expect no error, get %v", err)
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(result, testspec.expect) {
|
||||
t.Errorf("Result mismatch, want %v, get %v", testspec.expect, result)
|
||||
var have *logger.ExecutionResult
|
||||
if err := json.Unmarshal(result.(json.RawMessage), &have); err != nil {
|
||||
t.Errorf("failed to unmarshal result %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(have, testspec.expect) {
|
||||
t.Errorf("Result mismatch, want %v, get %v", testspec.expect, have)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,11 +334,15 @@ func TestTraceTransaction(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Failed to trace transaction %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(result, ðapi.ExecutionResult{
|
||||
var have *logger.ExecutionResult
|
||||
if err := json.Unmarshal(result.(json.RawMessage), &have); err != nil {
|
||||
t.Errorf("failed to unmarshal result %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(have, &logger.ExecutionResult{
|
||||
Gas: params.TxGas,
|
||||
Failed: false,
|
||||
ReturnValue: "",
|
||||
StructLogs: []ethapi.StructLogRes{},
|
||||
StructLogs: []logger.StructLogRes{},
|
||||
}) {
|
||||
t.Error("Transaction tracing result is different")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user