diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-09-03 10:01:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-03 10:01:40 +0800 |
commit | c8d3092208f73ee991a123052a71b7dbf7fffc27 (patch) | |
tree | fdcb3b90b859531e042dbbdd6bcd7b0cca40e86a /core/test | |
parent | 9491ddae81640e04f8aed38e2cddeb64cc62d55b (diff) | |
download | tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.gz tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.bz2 tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.lz tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.xz tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.zst tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.zip |
core: Add a new structure `Position` and move `ShardID`, `ChainID` and `Height` from `Block` (#89)
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/app.go | 2 | ||||
-rw-r--r-- | core/test/blocks-generator.go | 6 | ||||
-rw-r--r-- | core/test/blocks-generator_test.go | 8 |
3 files changed, 9 insertions, 7 deletions
diff --git a/core/test/app.go b/core/test/app.go index 3ed65f7..60b74ac 100644 --- a/core/test/app.go +++ b/core/test/app.go @@ -103,7 +103,7 @@ func NewApp() *App { } // PreparePayloads implements Application interface. -func (app *App) PreparePayloads(shardID, chainID, height uint64) [][]byte { +func (app *App) PreparePayloads(position types.Position) [][]byte { return [][]byte{} } diff --git a/core/test/blocks-generator.go b/core/test/blocks-generator.go index 92271f7..18e4995 100644 --- a/core/test/blocks-generator.go +++ b/core/test/blocks-generator.go @@ -158,14 +158,16 @@ func (vs *validatorSetStatus) proposeBlock( newBlock := &types.Block{ ProposerID: proposerID, ParentHash: parentHash, - Height: uint64(len(status.blocks)), + Position: types.Position{ + Height: uint64(len(status.blocks)), + }, Acks: acks, Timestamps: ts, // TODO(mission.liao): Generate timestamp. } for i, vID := range vs.validatorIDs { if vID == proposerID { - newBlock.ChainID = uint64(i) + newBlock.Position.ChainID = uint32(i) } } var err error diff --git a/core/test/blocks-generator_test.go b/core/test/blocks-generator_test.go index 5c85fbd..b144100 100644 --- a/core/test/blocks-generator_test.go +++ b/core/test/blocks-generator_test.go @@ -74,7 +74,7 @@ func (s *BlocksGeneratorTestCase) TestGenerate() { // Check genesis block. genesisBlock := blocks[0] s.Equal(genesisBlock.ParentHash, common.Hash{}) - s.Equal(genesisBlock.Height, uint64(0)) + s.Equal(genesisBlock.Position.Height, uint64(0)) s.Empty(genesisBlock.Acks) // Check normal blocks. @@ -90,14 +90,14 @@ func (s *BlocksGeneratorTestCase) TestGenerate() { prevAckingHeight, exists := lastAckingHeights[ackedBlock.ProposerID] if exists { - s.True(prevAckingHeight < ackedBlock.Height) + s.True(prevAckingHeight < ackedBlock.Position.Height) } - lastAckingHeights[ackedBlock.ProposerID] = ackedBlock.Height + lastAckingHeights[ackedBlock.ProposerID] = ackedBlock.Position.Height // Block Height should always incremental by 1. // // Because we iterate blocks slice from 1, // we need to add 1 to the index. - s.Equal(block.Height, uint64(index+1)) + s.Equal(block.Position.Height, uint64(index+1)) } s.True(parentAcked) } |