aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/agreement.go3
-rw-r--r--core/agreement_test.go12
2 files changed, 14 insertions, 1 deletions
diff --git a/core/agreement.go b/core/agreement.go
index 1870a50..10ba354 100644
--- a/core/agreement.go
+++ b/core/agreement.go
@@ -468,6 +468,7 @@ func (a *agreement) processVote(vote *types.Vote) error {
a.data.lockIter = vote.Period
}
a.fastForward <- vote.Period
+ close(a.doneChan)
return nil
}
}
@@ -493,6 +494,7 @@ func (a *agreement) processVote(vote *types.Vote) error {
a.data.recv.PullBlocks(hashes)
}
a.fastForward <- vote.Period + 1
+ close(a.doneChan)
return nil
}
return nil
@@ -513,7 +515,6 @@ func (a *agreement) done() <-chan struct{} {
}
a.data.setPeriod(period)
a.state = newPreCommitState(a.data)
- close(a.doneChan)
a.doneChan = make(chan struct{})
return closedchan
default:
diff --git a/core/agreement_test.go b/core/agreement_test.go
index f49fd7d..4ddff8d 100644
--- a/core/agreement_test.go
+++ b/core/agreement_test.go
@@ -404,6 +404,7 @@ func (s *AgreementTestSuite) TestFastForwardCond2() {
return true, nil
})
a.data.period = 1
+ done := a.done()
hash := common.NewRandomHash()
for nID := range a.notarySet {
vote := s.prepareVote(nID, types.VotePreCom, hash, uint64(2))
@@ -414,6 +415,11 @@ func (s *AgreementTestSuite) TestFastForwardCond2() {
}
select {
+ case <-done:
+ default:
+ s.FailNow("Expecting fast forward for pending done() call.")
+ }
+ select {
case <-a.done():
default:
s.FailNow("Expecting fast forward.")
@@ -443,6 +449,7 @@ func (s *AgreementTestSuite) TestFastForwardCond3() {
return true, nil
})
a.data.period = 1
+ done := a.done()
for nID := range a.notarySet {
vote := s.prepareVote(nID, types.VoteCom, common.NewRandomHash(), uint64(2))
votes = append(votes, vote)
@@ -453,6 +460,11 @@ func (s *AgreementTestSuite) TestFastForwardCond3() {
}
select {
+ case <-done:
+ default:
+ s.FailNow("Expecting fast forward for pending done() call.")
+ }
+ select {
case <-a.done():
default:
s.FailNow("Expecting fast forward.")