mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
disable stack printing in test, to avoid confusions
This commit is contained in:
parent
9153a01e1d
commit
f2d7d3906f
4 changed files with 11 additions and 6 deletions
|
|
@ -2181,7 +2181,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Failed to create tracer %q: %v", name, err)
|
Fatalf("Failed to create tracer %q: %v", name, err)
|
||||||
}
|
}
|
||||||
safeHooks, err := tracers.NewRecoverTracer(stack, t)
|
safeHooks, err := tracers.NewRecoverTracer(stack, t, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Failed to create safety wrapper for tracer %q: %v", name, err)
|
Fatalf("Failed to create safety wrapper for tracer %q: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create tracer %s: %v", config.VMTrace, err)
|
return nil, fmt.Errorf("failed to create tracer %s: %v", config.VMTrace, err)
|
||||||
}
|
}
|
||||||
safeHooks, err := tracers.NewRecoverTracer(stack, t)
|
safeHooks, err := tracers.NewRecoverTracer(stack, t, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create safety wrappers for %s tracer: %v", config.VMTrace, err)
|
return nil, fmt.Errorf("failed to create safety wrappers for %s tracer: %v", config.VMTrace, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,16 +35,19 @@ import (
|
||||||
type recoverTracer struct {
|
type recoverTracer struct {
|
||||||
node *node.Node
|
node *node.Node
|
||||||
child *tracing.Hooks
|
child *tracing.Hooks
|
||||||
|
|
||||||
|
// false in tests, to prevent stack printing and misatribution of a bug
|
||||||
|
printStack bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRecoverTracer instantiates a recoverTracer and returns a wrapped tracing.Hooks.
|
// NewRecoverTracer instantiates a recoverTracer and returns a wrapped tracing.Hooks.
|
||||||
// Only hook fields which are non-nil in the child are replaced with the corresponding
|
// Only hook fields which are non-nil in the child are replaced with the corresponding
|
||||||
// recoverTracer method.
|
// recoverTracer method.
|
||||||
func NewRecoverTracer(node *node.Node, child *tracing.Hooks) (*tracing.Hooks, error) {
|
func NewRecoverTracer(node *node.Node, child *tracing.Hooks, printStack bool) (*tracing.Hooks, error) {
|
||||||
if child == nil {
|
if child == nil {
|
||||||
return nil, fmt.Errorf("child tracer is nil")
|
return nil, fmt.Errorf("child tracer is nil")
|
||||||
}
|
}
|
||||||
rt := &recoverTracer{node: node, child: child}
|
rt := &recoverTracer{node, child, printStack}
|
||||||
return rt.wrapHooks()
|
return rt.wrapHooks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +93,9 @@ func (rt *recoverTracer) safeCall(name string, shutdown bool, fn func()) {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
log.Error(fmt.Sprintf("panic in child tracer during %s: %v", name, r))
|
log.Error(fmt.Sprintf("panic in child tracer during %s: %v", name, r))
|
||||||
if shutdown {
|
if shutdown {
|
||||||
debug.PrintStack()
|
if rt.printStack {
|
||||||
|
debug.PrintStack()
|
||||||
|
}
|
||||||
go rt.node.Close()
|
go rt.node.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ func TestSafeTracer(t *testing.T) {
|
||||||
faultyTracer := &tracing.Hooks{OnTxStart: func(*tracing.VMContext, *types.Transaction, common.Address) {
|
faultyTracer := &tracing.Hooks{OnTxStart: func(*tracing.VMContext, *types.Transaction, common.Address) {
|
||||||
panic("someone mispronounced clef")
|
panic("someone mispronounced clef")
|
||||||
}}
|
}}
|
||||||
safeHooks, err := NewRecoverTracer(nil, faultyTracer)
|
safeHooks, err := NewRecoverTracer(nil, faultyTracer, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue