From a57bf94bafea08b21fd7faf2bd500459be1ca4f5 Mon Sep 17 00:00:00 2001 From: tony Date: Wed, 4 Sep 2024 16:17:22 +0800 Subject: [PATCH] update the message for unspported tracer --- api/debug/debug.go | 6 +++++- api/debug/debug_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/debug/debug.go b/api/debug/debug.go index 85c084947..71cce12f9 100644 --- a/api/debug/debug.go +++ b/api/debug/debug.go @@ -241,7 +241,11 @@ func (d *Debug) createTracer(name string, config json.RawMessage) (tracers.Trace return tracers.DefaultDirectory.New(tracerName, config, false) } - return tracers.DefaultDirectory.New(tracerName, config, d.allowCustomTracer) + if d.allowCustomTracer { + return tracers.DefaultDirectory.New(tracerName, config, true) + } + + return nil, errors.New("tracer is not defined") } func (d *Debug) traceCall(ctx context.Context, tracer tracers.Tracer, header *block.Header, st *state.State, txCtx *xenv.TransactionContext, gas uint64, clause *tx.Clause) (interface{}, error) { diff --git a/api/debug/debug_test.go b/api/debug/debug_test.go index c747dc36d..60a2821a0 100644 --- a/api/debug/debug_test.go +++ b/api/debug/debug_test.go @@ -619,7 +619,7 @@ func TestCreateTracer(t *testing.T) { assert.Nil(t, err) assert.IsType(t, &logger.StructLogger{}, tr) _, err = debug.createTracer("{result:()=>{}, fault:()=>{}}", nil) - assert.EqualError(t, err, "unsupported tracer") + assert.EqualError(t, err, "tracer is not defined") tr, err = debug.createTracer("structLogger", nil) assert.Nil(t, err)