mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
fix test by closing logger file
Was expecting lumberjack.Rotate() to close the file
This commit is contained in:
parent
cba97ef430
commit
4708a19319
2 changed files with 5 additions and 7 deletions
|
|
@ -528,10 +528,8 @@ func testSupplyTracer(t *testing.T, genesis *core.Genesis, gen func(*core.BlockG
|
||||||
engine = beacon.New(ethash.NewFaker())
|
engine = beacon.New(ethash.NewFaker())
|
||||||
)
|
)
|
||||||
|
|
||||||
tmpDir := t.TempDir()
|
traceOutputPath := filepath.ToSlash(t.TempDir())
|
||||||
traceOutputPath := filepath.ToSlash(tmpDir)
|
|
||||||
traceOutputFilename := path.Join(traceOutputPath, "supply.jsonl")
|
traceOutputFilename := path.Join(traceOutputPath, "supply.jsonl")
|
||||||
t.Cleanup(func() { os.RemoveAll(tmpDir) })
|
|
||||||
|
|
||||||
// Load supply tracer
|
// Load supply tracer
|
||||||
tracer, err := tracers.LiveDirectory.New("supply", json.RawMessage(fmt.Sprintf(`{"path":"%s"}`, traceOutputPath)))
|
tracer, err := tracers.LiveDirectory.New("supply", json.RawMessage(fmt.Sprintf(`{"path":"%s"}`, traceOutputPath)))
|
||||||
|
|
@ -555,7 +553,6 @@ func testSupplyTracer(t *testing.T, genesis *core.Genesis, gen func(*core.BlockG
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check and compare the results
|
// Check and compare the results
|
||||||
// TODO: replace file to pass results
|
|
||||||
file, err := os.OpenFile(traceOutputFilename, os.O_RDONLY, 0666)
|
file, err := os.OpenFile(traceOutputFilename, os.O_RDONLY, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, chain, fmt.Errorf("failed to open output file: %v", err)
|
return nil, chain, fmt.Errorf("failed to open output file: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -67,15 +67,16 @@ func newSupply(cfg json.RawMessage) (*tracing.Hooks, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store traces in a rotating file
|
// Store traces in a rotating file
|
||||||
loggerOutput := &lumberjack.Logger{
|
loggerOutputFile := &lumberjack.Logger{
|
||||||
Filename: filepath.Join(config.Path, "supply.jsonl"),
|
Filename: filepath.Join(config.Path, "supply.jsonl"),
|
||||||
}
|
}
|
||||||
|
defer loggerOutputFile.Close()
|
||||||
|
|
||||||
if config.MaxSize > 0 {
|
if config.MaxSize > 0 {
|
||||||
loggerOutput.MaxSize = config.MaxSize
|
loggerOutputFile.MaxSize = config.MaxSize
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := log.New(loggerOutput, "", 0)
|
logger := log.New(loggerOutputFile, "", 0)
|
||||||
|
|
||||||
supplyInfo := newSupplyInfo()
|
supplyInfo := newSupplyInfo()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue