Skip to content

Commit 8b3c88c

Browse files
committed
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 <[email protected]>
1 parent 297c4e7 commit 8b3c88c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

eth/tracers/api_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,11 @@ func TestStandardTraceBadBlockToFile(t *testing.T) {
15161516
t.Parallel()
15171517

15181518
files, err := api.StandardTraceBadBlockToFile(context.Background(), tc.badBlockHash, tc.config)
1519+
t.Cleanup(func() {
1520+
for _, fileName := range files {
1521+
os.Remove(fileName)
1522+
}
1523+
})
15191524

15201525
// Check error expectations
15211526
if tc.expectError {
@@ -1552,9 +1557,6 @@ func TestStandardTraceBadBlockToFile(t *testing.T) {
15521557
t.Fatalf("Trace file %d content mismatch.\nExpected:\n%s\nGot:\n%s", i, tc.expectedTraces[i], traceContent)
15531558
}
15541559
}
1555-
1556-
// Clean up
1557-
os.Remove(fileName)
15581560
}
15591561
})
15601562
}

0 commit comments

Comments
 (0)