From 3a6cf0a4a00399dda0b9ac2b5c5e39a6909559d2 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 27 Mar 2024 16:22:32 +0100 Subject: [PATCH] Revert "allow test to use different file for tracer output" This reverts commit bc983e2afd5f8520dc2448b4ddf989cc102e5973. --- eth/tracers/internal/tracetest/supply_test.go | 13 +++++-------- eth/tracers/live/supply.go | 11 +++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/eth/tracers/internal/tracetest/supply_test.go b/eth/tracers/internal/tracetest/supply_test.go index 5578d8ddb0..d9834d398e 100644 --- a/eth/tracers/internal/tracetest/supply_test.go +++ b/eth/tracers/internal/tracetest/supply_test.go @@ -22,6 +22,7 @@ import ( "fmt" "math/big" "os" + "path" "path/filepath" "reflect" "testing" @@ -517,15 +518,11 @@ func testSupplyTracer(genesis *core.Genesis, gen func(*core.BlockGen)) ([]live.S ) traceOutputPath := filepath.ToSlash(os.TempDir()) - traceOutputFile, err := os.CreateTemp(traceOutputPath, "supply-*.jsonl") - traceOutputFilename := filepath.Base(traceOutputFile.Name()) - if err != nil { - return nil, nil, fmt.Errorf("failed to create temp file for supply logs: %v", err) - } - defer os.Remove(traceOutputFile.Name()) + traceOutputFilename := path.Join(traceOutputPath, "supply.jsonl") + defer os.Remove(traceOutputFilename) // Load supply tracer - tracer, err := tracers.LiveDirectory.New("supply", json.RawMessage(fmt.Sprintf(`{"path":"%s","filename":"%s"}`, traceOutputPath, traceOutputFilename))) + tracer, err := tracers.LiveDirectory.New("supply", json.RawMessage(fmt.Sprintf(`{"path":"%s"}`, traceOutputPath))) if err != nil { return nil, nil, fmt.Errorf("failed to create call tracer: %v", err) } @@ -547,7 +544,7 @@ func testSupplyTracer(genesis *core.Genesis, gen func(*core.BlockGen)) ([]live.S // Check and compare the results // TODO: replace file to pass results - file, err := os.OpenFile(traceOutputFile.Name(), os.O_RDONLY, 0666) + file, err := os.OpenFile(traceOutputFilename, os.O_RDONLY, 0666) if err != nil { return nil, chain, fmt.Errorf("failed to open output file: %v", err) } diff --git a/eth/tracers/live/supply.go b/eth/tracers/live/supply.go index 3b5fa9d987..bc17c01eb3 100644 --- a/eth/tracers/live/supply.go +++ b/eth/tracers/live/supply.go @@ -50,9 +50,8 @@ type Supply struct { } type supplyTracerConfig struct { - Path string `json:"path"` // Path to the directory where the tracer logs will be stored - Filename string `json:"filename"` // Filename of the tracer log file. Defaults to "supply.jsonl". - MaxSize int `json:"maxsize"` // MaxSize is the maximum size in megabytes of the tracer log file before it gets rotated. It defaults to 100 megabytes. + Path string `json:"path"` // Path to the directory where the tracer logs will be stored + MaxSize int `json:"maxSize"` // MaxSize is the maximum size in megabytes of the tracer log file before it gets rotated. It defaults to 100 megabytes. } func newSupply(cfg json.RawMessage) (*tracing.Hooks, error) { @@ -67,13 +66,9 @@ func newSupply(cfg json.RawMessage) (*tracing.Hooks, error) { return nil, errors.New("supply tracer output path is required") } - if config.Filename == "" { - config.Filename = "supply.jsonl" - } - // Store traces in a rotating file loggerOutput := &lumberjack.Logger{ - Filename: filepath.Join(config.Path, config.Filename), + Filename: filepath.Join(config.Path, "supply.jsonl"), } if config.MaxSize > 0 {