consensus: improve cleanup of wal tests (#7878)

This commit is contained in:
Sam Kleinman
2022-02-19 13:26:31 -05:00
committed by GitHub
parent 4425e62e9e
commit 81bd9ad812

View File

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