From ecc5e12b1ac4826e302607769f5b831ab4c27046 Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Mon, 1 Apr 2019 12:25:09 +0800 Subject: 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 --- core/consensus_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'core/consensus_test.go') diff --git a/core/consensus_test.go b/core/consensus_test.go index 19c43ad..f677d00 100644 --- a/core/consensus_test.go +++ b/core/consensus_test.go @@ -357,8 +357,8 @@ func (s *ConsensusTestSuite) TestInitialHeightEventTriggered() { pubKeys, time.Second, &common.NullLogger{}, true), ConfigRoundShift) gov.State().RequestChange(test.StateChangeRoundLength, uint64(100)) s.Require().NoError(err) - gov.NotifyRound(2, 200) - gov.NotifyRound(3, 300) + gov.NotifyRound(2, 201) + gov.NotifyRound(3, 301) hash := common.NewRandomHash() gov.ProposeCRS(2, hash[:]) hash = common.NewRandomHash() @@ -366,9 +366,8 @@ func (s *ConsensusTestSuite) TestInitialHeightEventTriggered() { s.Require().Equal(gov.DKGResetCount(2), uint64(1)) prvKey := prvKeys[0] initBlock := &types.Block{ - Hash: common.NewRandomHash(), - Position: types.Position{Round: 1, Height: 199}, - Finalization: types.FinalizationResult{Height: 200}, + Hash: common.NewRandomHash(), + Position: types.Position{Round: 1, Height: 200}, } dbInst, err := db.NewMemBackedDB() s.Require().NoError(err) @@ -392,7 +391,7 @@ func (s *ConsensusTestSuite) TestInitialHeightEventTriggered() { // Here is the tricky part, check if block chain module can handle the // block with height == 200. s.Require().Equal(con.bcModule.configs[0].RoundID(), uint64(1)) - s.Require().Equal(con.bcModule.configs[0].RoundEndHeight(), uint64(300)) + s.Require().Equal(con.bcModule.configs[0].RoundEndHeight(), uint64(301)) } func TestConsensus(t *testing.T) { -- cgit