Browse Source

consensus: test shutdown to avoid hangs (#7603)

pull/7614/head
Sam Kleinman 2 years ago
committed by GitHub
parent
commit
c0b56e207a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions
  1. +0
    -1
      internal/consensus/byzantine_test.go
  2. +2
    -0
      internal/consensus/replay_test.go
  3. +5
    -1
      internal/consensus/state_test.go
  4. +5
    -1
      internal/consensus/wal_test.go

+ 0
- 1
internal/consensus/byzantine_test.go View File

@ -255,7 +255,6 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
}
msg, err := s.Next(ctx)
assert.NoError(t, err)
if err != nil {
cancel()


+ 2
- 0
internal/consensus/replay_test.go View File

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


+ 5
- 1
internal/consensus/state_test.go View File

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


+ 5
- 1
internal/consensus/wal_test.go View File

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


Loading…
Cancel
Save