Browse Source

consensus: use buffered channel in TestStateFullRound1 (#7668)

pull/7705/head
William Banfield 3 years ago
committed by GitHub
parent
commit
61f3aa0848
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions
  1. +2
    -1
      internal/consensus/common_test.go
  2. +4
    -7
      internal/consensus/state_test.go

+ 2
- 1
internal/consensus/common_test.go View File

@ -594,7 +594,7 @@ func ensureNewTimeout(t *testing.T, timeoutCh <-chan tmpubsub.Message, height in
ensureNewEvent(t, timeoutCh, height, round, timeoutDuration)
}
func ensureNewProposal(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32) {
func ensureNewProposal(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32) types.BlockID {
t.Helper()
msg := ensureMessageBeforeTimeout(t, proposalCh, ensureTimeout)
proposalEvent, ok := msg.Data().(types.EventDataCompleteProposal)
@ -602,6 +602,7 @@ func ensureNewProposal(t *testing.T, proposalCh <-chan tmpubsub.Message, height
msg.Data())
require.Equal(t, height, proposalEvent.Height)
require.Equal(t, round, proposalEvent.Round)
return proposalEvent.BlockID
}
func ensureNewValidBlock(t *testing.T, validBlockCh <-chan tmpubsub.Message, height int64, round int32) {


+ 4
- 7
internal/consensus/state_test.go View File

@ -343,9 +343,7 @@ func TestStateFullRound1(t *testing.T) {
cs, vss := makeState(ctx, t, config, logger, 1)
height, round := cs.Height, cs.Round
pv, err := cs.privValidator.GetPubKey(ctx)
require.NoError(t, err)
voteCh := subscribeToVoter(ctx, t, cs, pv.Address())
voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote)
propCh := subscribe(ctx, t, cs.eventBus, types.EventQueryCompleteProposal)
newRoundCh := subscribe(ctx, t, cs.eventBus, types.EventQueryNewRound)
@ -354,17 +352,16 @@ func TestStateFullRound1(t *testing.T) {
ensureNewRound(t, newRoundCh, height, round)
ensureNewProposal(t, propCh, height, round)
propBlockHash := cs.GetRoundState().ProposalBlock.Hash()
propBlock := ensureNewProposal(t, propCh, height, round)
ensurePrevoteMatch(t, voteCh, height, round, propBlockHash) // wait for prevote
ensurePrevoteMatch(t, voteCh, height, round, propBlock.Hash) // wait for prevote
ensurePrecommit(t, voteCh, height, round) // wait for precommit
// we're going to roll right into new height
ensureNewRound(t, newRoundCh, height+1, 0)
validateLastPrecommit(ctx, t, cs, vss[0], propBlockHash)
validateLastPrecommit(ctx, t, cs, vss[0], propBlock.Hash)
}
// nil is proposed, so prevote and precommit nil


Loading…
Cancel
Save