diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-31 12:51:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-31 12:51:54 +0800 |
commit | eccdddbff92c1588e628f874d73ae557351c76f7 (patch) | |
tree | 799e888f2223e53d88391b15f507226208ef349c /core/agreement_test.go | |
parent | 43a5264814bf318e6bd133fb0df51351f0811ddb (diff) | |
download | tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.tar tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.tar.gz tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.tar.bz2 tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.tar.lz tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.tar.xz tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.tar.zst tangerine-consensus-eccdddbff92c1588e628f874d73ae557351c76f7.zip |
core: Add a repeat vote state. (#280)
Diffstat (limited to 'core/agreement_test.go')
-rw-r--r-- | core/agreement_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/agreement_test.go b/core/agreement_test.go index e4e05cd..0e3814e 100644 --- a/core/agreement_test.go +++ b/core/agreement_test.go @@ -183,6 +183,49 @@ func (s *AgreementTestSuite) TestSimpleConfirm() { s.Equal(blockHash, confirmBlock) } +func (s *AgreementTestSuite) TestPartitionOnCommitVote() { + a := s.newAgreement(4) + // InitialState + a.nextState() + // PreCommitState + s.Require().Len(s.blockChan, 1) + blockHash := <-s.blockChan + block, exist := s.block[blockHash] + s.Require().True(exist) + s.Require().NoError(a.processBlock(block)) + s.Require().Len(s.voteChan, 1) + vote := <-s.voteChan + s.Equal(types.VoteInit, vote.Type) + s.Equal(blockHash, vote.BlockHash) + a.nextState() + // CommitState + s.Require().Len(s.voteChan, 1) + vote = <-s.voteChan + s.Equal(types.VotePreCom, vote.Type) + s.Equal(blockHash, vote.BlockHash) + for nID := range s.auths { + v := s.copyVote(vote, nID) + s.Require().NoError(a.processVote(v)) + } + a.nextState() + // ForwardState + s.Require().Len(s.voteChan, 1) + vote = <-s.voteChan + s.Equal(types.VoteCom, vote.Type) + s.Equal(blockHash, vote.BlockHash) + s.Equal(blockHash, a.data.lockValue) + s.Equal(uint64(1), a.data.lockRound) + // RepeateVoteState + a.nextState() + // The agreement does not receive others commit vote, it will keep re-sending. + for i := 0; i < 5; i++ { + a.nextState() + s.Require().Len(s.voteChan, 1) + proposedVote := <-s.voteChan + s.Equal(vote, proposedVote) + } +} + func (s *AgreementTestSuite) TestFastForwardCond1() { votes := 0 a := s.newAgreement(4) |