Skip to content

Commit ec7f64b

Browse files
committed
fix test
Signed-off-by: Hagar Meir <[email protected]>
1 parent 8100cbe commit ec7f64b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

internal/bft/view_test.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,10 @@ func TestTwoSequences(t *testing.T) {
462462
assert.NoError(t, err)
463463
log := basicLog.Sugar()
464464
comm := &mocks.Comm{}
465-
comm.On("Broadcast", mock.Anything)
465+
commWG := sync.WaitGroup{}
466+
comm.On("Broadcast", mock.Anything).Run(func(args mock.Arguments) {
467+
commWG.Done()
468+
})
466469
decider := &mocks.Decider{}
467470
deciderWG := sync.WaitGroup{}
468471
decidedProposal := make(chan types.Proposal, 1)
@@ -496,16 +499,20 @@ func TestTwoSequences(t *testing.T) {
496499
}
497500
end := view.Start()
498501

502+
commWG.Add(1)
499503
view.HandleMessage(1, prePrepare)
504+
commWG.Wait()
500505

501506
prepareNext := proto.Clone(prepare).(*protos.Message)
502507
prepareNextGet := prepareNext.GetPrepare()
503508
prepareNextGet.Seq = 1
504509

510+
commWG.Add(1)
505511
view.HandleMessage(1, prepare)
506512
view.HandleMessage(1, prepareNext)
507513
view.HandleMessage(2, prepare)
508514
view.HandleMessage(2, prepareNext)
515+
commWG.Wait()
509516

510517
commit1Next := proto.Clone(commit1).(*protos.Message)
511518
commit1NextGet := commit1Next.GetCommit()
@@ -525,7 +532,9 @@ func TestTwoSequences(t *testing.T) {
525532
prePrepareNextGet := prePrepareNext.GetPrePrepare()
526533
prePrepareNextGet.Seq = 1
527534

535+
commWG.Add(2)
528536
view.HandleMessage(1, prePrepareNext)
537+
commWG.Wait()
529538

530539
deciderWG.Wait()
531540
dProp := <-decidedProposal

0 commit comments

Comments
 (0)