diff options
author | Mission Liao <mission.liao@dexon.org> | 2019-04-01 12:25:09 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-01 12:25:09 +0800 |
commit | ecc5e12b1ac4826e302607769f5b831ab4c27046 (patch) | |
tree | e01fbf5d796c555f1d343e14023c282ad83bcba8 /core/agreement_test.go | |
parent | 46f00c345dc0993cf888523e482ae0ff385c4391 (diff) | |
download | tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.gz tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.bz2 tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.lz tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.xz tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.tar.zst tangerine-consensus-ecc5e12b1ac4826e302607769f5b831ab4c27046.zip |
core: clean TODOs (#539)
* core: fix block timestamp (#529)
* Remove TODO
dMoment is still required when the block timestamp of
the genesis block is still need to be verified.
* Refine timestamp when preparing blocks
* Add timestamp checking in sanity check
* Revert code to patch position when preparing
* Remove TODOs that seems meaningless now
* Remove TODOs related to refactoring
* core: remove finalization (#531)
- Remove types.FinalizationResult, randomness
field would be moved to `types.Block` directly.
- Add a placeholder for types.Block.Randomness
field for blocks proposed from
round < DKGDelayRound. (refer to core.NoRand)
- Make the height of the genesis block starts
from 1. (refer to types.GenesisHeight)
- The fullnode's behavior of
core.Governance.GetRoundHeight is (assume
round-length is 100):
- round: 0 -> 0 (we need to workaround this)
- round: 1 -> 101
- round: 2 -> 201
- test.Governance already simulate this
behavior, and the workaround is wrapped at
utils.GetRoundHeight.
* core: fix issues (#536)
fixing code in these condition:
- assigning position without initializing them
and expected it's for genesis
- compare height with 0
Diffstat (limited to 'core/agreement_test.go')
-rw-r--r-- | core/agreement_test.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/agreement_test.go b/core/agreement_test.go index cb4b2a9..33e398c 100644 --- a/core/agreement_test.go +++ b/core/agreement_test.go @@ -39,6 +39,7 @@ func (r *agreementTestReceiver) VerifyPartialSignature(*types.Vote) bool { } func (r *agreementTestReceiver) ProposeVote(vote *types.Vote) { + vote.Position = r.s.agreementID r.s.voteChan <- vote } @@ -81,6 +82,7 @@ func (s *AgreementTestSuite) proposeBlock( nID types.NodeID, crs common.Hash) *types.Block { block := &types.Block{ ProposerID: nID, + Position: types.Position{Height: types.GenesisHeight}, Hash: common.NewRandomHash(), } s.block[block.Hash] = block @@ -103,6 +105,7 @@ type AgreementTestSuite struct { block map[common.Hash]*types.Block pulledBlocks map[common.Hash]struct{} agreement []*agreement + agreementID types.Position } func (s *AgreementTestSuite) SetupTest() { @@ -119,6 +122,7 @@ func (s *AgreementTestSuite) SetupTest() { s.forkBlockChan = make(chan common.Hash, 100) s.block = make(map[common.Hash]*types.Block) s.pulledBlocks = make(map[common.Hash]struct{}) + s.agreementID = types.Position{Height: types.GenesisHeight} } func (s *AgreementTestSuite) newAgreement( @@ -153,8 +157,8 @@ func (s *AgreementTestSuite) newAgreement( s.signers[s.ID], logger, ) - agreement.restart(notarySet, types.Position{}, - leaderNode, common.NewRandomHash()) + agreement.restart(notarySet, s.agreementID, leaderNode, + common.NewRandomHash()) s.agreement = append(s.agreement, agreement) return agreement, leaderNode } @@ -171,6 +175,7 @@ func (s *AgreementTestSuite) prepareVote( period uint64) ( vote *types.Vote) { vote = types.NewVote(voteType, blockHash, period) + vote.Position = types.Position{Height: types.GenesisHeight} s.Require().NoError(s.signers[nID].SignVote(vote)) return } @@ -576,11 +581,9 @@ func (s *AgreementTestSuite) TestConfirmWithBlock() { return true, nil }) block := &types.Block{ - Hash: common.NewRandomHash(), - Position: a.agreementID(), - Finalization: types.FinalizationResult{ - Randomness: []byte{0x1, 0x2, 0x3, 0x4}, - }, + Hash: common.NewRandomHash(), + Position: a.agreementID(), + Randomness: []byte{0x1, 0x2, 0x3, 0x4}, } a.processFinalizedBlock(block) s.Require().Len(s.confirmChan, 1) |