mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
eth/tracers: add cleanup for temporary files in bad block trace tests
This commit adds a cleanup function to remove temporary files created during the `TestStandardTraceBadBlockToFile` test. The cleanup is performed using `t.Cleanup` to ensure that files are deleted after the test execution, improving resource management and preventing potential file clutter. Signed-off-by: katsumata <12413150+winor30@users.noreply.github.com>
This commit is contained in:
parent
297c4e7fd1
commit
8b3c88c088
1 changed files with 5 additions and 3 deletions
|
|
@ -1516,6 +1516,11 @@ func TestStandardTraceBadBlockToFile(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
files, err := api.StandardTraceBadBlockToFile(context.Background(), tc.badBlockHash, tc.config)
|
files, err := api.StandardTraceBadBlockToFile(context.Background(), tc.badBlockHash, tc.config)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
for _, fileName := range files {
|
||||||
|
os.Remove(fileName)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Check error expectations
|
// Check error expectations
|
||||||
if tc.expectError {
|
if tc.expectError {
|
||||||
|
|
@ -1552,9 +1557,6 @@ func TestStandardTraceBadBlockToFile(t *testing.T) {
|
||||||
t.Fatalf("Trace file %d content mismatch.\nExpected:\n%s\nGot:\n%s", i, tc.expectedTraces[i], traceContent)
|
t.Fatalf("Trace file %d content mismatch.\nExpected:\n%s\nGot:\n%s", i, tc.expectedTraces[i], traceContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
|
||||||
os.Remove(fileName)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue