diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-10-14 11:03:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-14 11:03:57 +0800 |
commit | 17449ca9402c7130d9587abc6f6764df6ad2e12e (patch) | |
tree | 2b64da64e088fc51bd33f424fdaab74a065a09ed /core/lattice-data_test.go | |
parent | bb800319674e8a0f22769ae4af668c66e9536b15 (diff) | |
download | tangerine-consensus-17449ca9402c7130d9587abc6f6764df6ad2e12e.tar.gz tangerine-consensus-17449ca9402c7130d9587abc6f6764df6ad2e12e.tar.zst tangerine-consensus-17449ca9402c7130d9587abc6f6764df6ad2e12e.zip |
core: blocks generation supports rounds (#196)
* Block proposing based on timestamp, instead of
count of blocks generated.
* Add method to find tips of each round in blockdb.
* Block proposing based on tips of last round found
on blockdb.
Diffstat (limited to 'core/lattice-data_test.go')
-rw-r--r-- | core/lattice-data_test.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/core/lattice-data_test.go b/core/lattice-data_test.go index cb7d892..4636b0f 100644 --- a/core/lattice-data_test.go +++ b/core/lattice-data_test.go @@ -351,13 +351,13 @@ func (s *LatticeDataTestSuite) TestSanityCheck() { func (s *LatticeDataTestSuite) TestRandomlyGeneratedBlocks() { var ( - chainNum uint32 = 19 - blockNum = 50 - repeat = 20 - delivered []*types.Block - err error - req = s.Require() - datum []*latticeData + chainNum uint32 = 19 + repeat = 20 + delivered []*types.Block + err error + req = s.Require() + datum []*latticeData + genesisTime = time.Now().UTC() ) if testing.Short() { chainNum = 7 @@ -371,13 +371,20 @@ func (s *LatticeDataTestSuite) TestRandomlyGeneratedBlocks() { maxBlockTimeInterval: 1000 * time.Second, roundInterval: 1000 * time.Second, } - genesisConfig.setRoundBeginTime(time.Now().UTC()) + genesisConfig.setRoundBeginTime(genesisTime) // Prepare a randomly generated blocks. db, err := blockdb.NewMemBackedBlockDB() req.NoError(err) - gen := test.NewBlocksGenerator(nil, hashBlock) - _, err = gen.Generate(chainNum, blockNum, nil, db) - req.NoError(err) + gen := test.NewBlocksGenerator(&test.BlocksGeneratorConfig{ + NumChains: genesisConfig.numChains, + MinBlockTimeInterval: genesisConfig.minBlockTimeInterval, + MaxBlockTimeInterval: genesisConfig.maxBlockTimeInterval, + }, nil, hashBlock) + req.NoError(gen.Generate( + 0, + genesisTime, + genesisTime.Add(genesisConfig.roundInterval), + db)) iter, err := db.GetAll() req.NoError(err) // Setup a revealer that would reveal blocks randomly but still form |