mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-09 22:47:24 +00:00
consensus: test shutdown to avoid hangs (#7603)
This commit is contained in:
@@ -255,7 +255,6 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
|
||||
}
|
||||
|
||||
msg, err := s.Next(ctx)
|
||||
|
||||
assert.NoError(t, err)
|
||||
if err != nil {
|
||||
cancel()
|
||||
|
||||
@@ -201,6 +201,8 @@ LOOP:
|
||||
i++
|
||||
|
||||
select {
|
||||
case <-rctx.Done():
|
||||
t.Fatal("context canceled before test completed")
|
||||
case err := <-walPanicked:
|
||||
// make sure we can make blocks after a crash
|
||||
startNewStateAndWaitForBlock(ctx, t, consensusReplayConfig, cs.Height, blockDB, stateStore)
|
||||
|
||||
@@ -2131,7 +2131,11 @@ func subscribe(
|
||||
t.Errorf("Subscription for %v unexpectedly terminated: %v", q, err)
|
||||
return
|
||||
}
|
||||
ch <- next
|
||||
select {
|
||||
case ch <- next:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
return ch
|
||||
|
||||
@@ -3,6 +3,7 @@ package consensus
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"path/filepath"
|
||||
|
||||
"testing"
|
||||
@@ -15,6 +16,7 @@ import (
|
||||
"github.com/tendermint/tendermint/internal/consensus/types"
|
||||
"github.com/tendermint/tendermint/internal/libs/autofile"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
tmtime "github.com/tendermint/tendermint/libs/time"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
)
|
||||
@@ -185,7 +187,9 @@ func TestWALPeriodicSync(t *testing.T) {
|
||||
require.NoError(t, wal.Start(ctx))
|
||||
t.Cleanup(func() {
|
||||
if err := wal.Stop(); err != nil {
|
||||
t.Error(err)
|
||||
if !errors.Is(err, service.ErrAlreadyStopped) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
wal.Wait()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user