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