Revert "allow test to use different file for tracer output"

This reverts commit bc983e2afd.
This commit is contained in:
Sina Mahmoodi 2024-03-27 16:22:32 +01:00
parent bc983e2afd
commit 3a6cf0a4a0
2 changed files with 8 additions and 16 deletions

View file

@ -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)
}

View file

@ -51,8 +51,7 @@ 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.
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 {