From a587cfddbbcc64871d09c6ede5ca13db6ae76070 Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Sat, 18 Dec 2021 03:26:30 +0100 Subject: [PATCH] Bring back block ID check in ensureProposalWithTimout --- internal/consensus/common_test.go | 8 ++++++-- internal/consensus/pbts_test.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 37709a15d..3c0c72757 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -682,11 +682,11 @@ func ensureRelock(t *testing.T, relockCh <-chan tmpubsub.Message, height int64, } func ensureProposal(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32, propID types.BlockID) { - ensureProposalWithTimeout(t, proposalCh, height, round, propID, ensureTimeout) + ensureProposalWithTimeout(t, proposalCh, height, round, &propID, ensureTimeout) } // nolint: lll -func ensureProposalWithTimeout(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32, propID types.BlockID, timeout time.Duration) { +func ensureProposalWithTimeout(t *testing.T, proposalCh <-chan tmpubsub.Message, height int64, round int32, propID *types.BlockID, timeout time.Duration) { t.Helper() msg := ensureMessageBeforeTimeout(t, proposalCh, timeout) proposalEvent, ok := msg.Data().(types.EventDataCompleteProposal) @@ -700,7 +700,11 @@ func ensureProposalWithTimeout(t *testing.T, proposalCh <-chan tmpubsub.Message, if proposalEvent.Round != round { t.Fatalf("expected round %v, got %v", round, proposalEvent.Round) } + if propID != nil && !proposalEvent.BlockID.Equals(*propID) { + t.Fatalf("Proposed block does not match expected block (%v != %v)", proposalEvent.BlockID, *propID) + } } + func ensurePrecommit(t *testing.T, voteCh <-chan tmpubsub.Message, height int64, round int32) { t.Helper() ensureVote(t, voteCh, height, round, tmproto.PrecommitType) diff --git a/internal/consensus/pbts_test.go b/internal/consensus/pbts_test.go index 103318239..18d04fff0 100644 --- a/internal/consensus/pbts_test.go +++ b/internal/consensus/pbts_test.go @@ -149,7 +149,7 @@ func (p *pbtsTestHarness) observedValidatorProposerHeight(previousBlockTime time ensureNewRound(p.t, p.roundCh, p.currentHeight, p.currentRound) timeout := time.Until(previousBlockTime.Add(ensureTimeout)) - ensureProposalWithTimeout(p.t, p.ensureProposalCh, p.currentHeight, p.currentRound, types.BlockID{}, timeout) + ensureProposalWithTimeout(p.t, p.ensureProposalCh, p.currentHeight, p.currentRound, nil, timeout) rs := p.observedState.GetRoundState() bid := types.BlockID{Hash: rs.ProposalBlock.Hash(), PartSetHeader: rs.ProposalBlockParts.Header()} @@ -300,7 +300,7 @@ func (p *pbtsTestHarness) run() resultSet { r2 := p.height2() p.intermediateHeights() r5 := p.height5() - p.observedState.Stop() + _ = p.observedState.Stop() return resultSet{ genesisHeight: r1, height2: r2,