consensus: remove panics from test helper functions (#6969)

This commit is contained in:
William Banfield
2022-01-13 22:04:52 -05:00
committed by William Banfield
parent ec59b1a1ae
commit 76c935e325
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -368,6 +368,7 @@ func validatePrevoteAndPrecommit(
votedBlockHash,
lockedBlockHash []byte,
) {
t.Helper()
// verify the prevote
validatePrevote(ctx, t, cs, thisRound, privVal, votedBlockHash)
// verify precommit
@@ -739,6 +740,7 @@ func randConsensusState(
appFunc func(t *testing.T, logger log.Logger) abci.Application,
configOpts ...func(*config.Config),
) ([]*State, cleanupFunc) {
t.Helper()
genDoc, privVals := factory.RandGenesisDoc(ctx, t, cfg, nValidators, false, 30)
css := make([]*State, nValidators)
@@ -802,6 +804,7 @@ func randConsensusNetWithPeers(
genDoc, privVals := factory.RandGenesisDoc(ctx, t, cfg, nValidators, false, testMinPower)
css := make([]*State, nPeers)
t.Helper()
logger := consensusLogger()
var peer0Config *config.Config
+2 -2
View File
@@ -1846,7 +1846,7 @@ func TestStateSlashingPrevotes(t *testing.T) {
voteCh := subscribeToVoter(ctx, t, cs1, cs1.privValidator.GetAddress())
// start round and wait for propose and prevote
startTestRound(cs1, cs1.Height, 0)
startTestRound(ctx, cs1, cs1.Height, 0)
<-newRoundCh
re := <-proposalCh
<-voteCh // prevote
@@ -1881,7 +1881,7 @@ func TestStateSlashingPrecommits(t *testing.T) {
voteCh := subscribeToVoter(ctx, t, cs1, cs1.privValidator.GetAddress())
// start round and wait for propose and prevote
startTestRound(cs1, cs1.Height, 0)
startTestRound(ctx, cs1, cs1.Height, 0)
<-newRoundCh
re := <-proposalCh
<-voteCh // prevote