mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 15:07:24 +00:00
consensus: use buffered channel in TestStateFullRound1 (#7668)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user