From 8b3c88c088505b4d28d7f57935a2d75d3fddaf1d Mon Sep 17 00:00:00 2001 From: katsumata <12413150+winor30@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:29:27 +0900 Subject: [PATCH] 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> --- eth/tracers/api_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 5fca3addc4..ec5d7bda3b 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -1516,6 +1516,11 @@ func TestStandardTraceBadBlockToFile(t *testing.T) { t.Parallel() files, err := api.StandardTraceBadBlockToFile(context.Background(), tc.badBlockHash, tc.config) + t.Cleanup(func() { + for _, fileName := range files { + os.Remove(fileName) + } + }) // Check error expectations 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) } } - - // Clean up - os.Remove(fileName) } }) }