From 81bd9ad812b74f0b47ddf13932fd9f74011319d1 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Sat, 19 Feb 2022 13:26:31 -0500 Subject: [PATCH] consensus: improve cleanup of wal tests (#7878) --- internal/consensus/wal_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/consensus/wal_test.go b/internal/consensus/wal_test.go index d9c05810d..a2c76676c 100644 --- a/internal/consensus/wal_test.go +++ b/internal/consensus/wal_test.go @@ -151,6 +151,7 @@ func TestWALSearchForEndHeight(t *testing.T) { wal, err := NewWAL(ctx, logger, walFile) require.NoError(t, err) + t.Cleanup(func() { wal.Stop(); wal.Wait() }) h := int64(3) gr, found, err := wal.SearchForEndHeight(h, &WALSearchOptions{}) @@ -165,6 +166,8 @@ func TestWALSearchForEndHeight(t *testing.T) { rs, ok := msg.Msg.(tmtypes.EventDataRoundState) assert.True(t, ok, "expected message of type EventDataRoundState") assert.Equal(t, rs.Height, h+1, "wrong height") + + t.Cleanup(leaktest.Check(t)) } func TestWALPeriodicSync(t *testing.T) { @@ -188,10 +191,7 @@ func TestWALPeriodicSync(t *testing.T) { assert.NotZero(t, wal.Group().Buffered()) require.NoError(t, wal.Start(ctx)) - t.Cleanup(func() { - wal.Stop() - wal.Wait() - }) + t.Cleanup(func() { wal.Stop(); wal.Wait() }) time.Sleep(walTestFlushInterval + (10 * time.Millisecond)) @@ -206,4 +206,6 @@ func TestWALPeriodicSync(t *testing.T) { if gr != nil { gr.Close() } + + t.Cleanup(leaktest.Check(t)) }