diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-27 15:02:27 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-27 15:25:10 +0800 |
commit | f848ee5128563138b1757034ea7d387c77679728 (patch) | |
tree | ce9083e8ae66ea7234d36241a3b1cf8b65fca2a8 /core/agreement_test.go | |
parent | 495b3737414685d609f7b41355928c699189d6ad (diff) | |
download | dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.gz dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.bz2 dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.lz dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.xz dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.zst dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.zip |
core: Update BA to the latest version (#519)
* core: fastPreCom should not propose fastCom in RBA
* add test for fix
* core: update BA
* core: fix test
Diffstat (limited to 'core/agreement_test.go')
-rw-r--r-- | core/agreement_test.go | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/core/agreement_test.go b/core/agreement_test.go index 175249f..cb4b2a9 100644 --- a/core/agreement_test.go +++ b/core/agreement_test.go @@ -176,31 +176,43 @@ func (s *AgreementTestSuite) prepareVote( } func (s *AgreementTestSuite) TestSimpleConfirm() { - a, _ := s.newAgreement(4, -1, func(*types.Block) (bool, error) { + a, leaderNode := s.newAgreement(4, 0, func(*types.Block) (bool, error) { return true, nil }) + s.Require().Equal(s.ID, leaderNode) // FastState a.nextState() // FastVoteState - a.nextState() - // InitialState - a.nextState() - // PreCommitState s.Require().Len(s.blockChan, 1) blockHash := <-s.blockChan block, exist := s.block[blockHash] s.Require().True(exist) + s.Require().Equal(s.ID, block.ProposerID) s.Require().NoError(a.processBlock(block)) + // Wait some time for go routine in processBlock to finish. + time.Sleep(500 * time.Millisecond) s.Require().Len(s.voteChan, 1) - vote := <-s.voteChan - s.Equal(types.VoteInit, vote.Type) - s.Equal(blockHash, vote.BlockHash) + fastVote := <-s.voteChan + s.Equal(types.VoteFast, fastVote.Type) + s.Equal(blockHash, fastVote.BlockHash) + s.Require().Len(s.voteChan, 0) + a.nextState() + // InitialState + a.nextState() + // PreCommitState a.nextState() // CommitState s.Require().Len(s.voteChan, 1) - vote = <-s.voteChan + vote := <-s.voteChan s.Equal(types.VotePreCom, vote.Type) s.Equal(blockHash, vote.BlockHash) + // Fast-votes should be ignored. + for nID := range s.signers { + v := s.copyVote(fastVote, nID) + s.Require().NoError(a.processVote(v)) + } + s.Require().Len(s.voteChan, 0) + s.Equal(uint64(1), a.data.lockIter) for nID := range s.signers { v := s.copyVote(vote, nID) s.Require().NoError(a.processVote(v)) |