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 /blockdb | |
parent | 9491ddae81640e04f8aed38e2cddeb64cc62d55b (diff) | |
download | dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.gz dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.bz2 dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.lz dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.xz dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.zst dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.zip |
core: Add a new structure `Position` and move `ShardID`, `ChainID` and `Height` from `Block` (#89)
Diffstat (limited to 'blockdb')
-rw-r--r-- | blockdb/level-db_test.go | 10 | ||||
-rw-r--r-- | blockdb/memory_test.go | 14 |
2 files changed, 17 insertions, 7 deletions
diff --git a/blockdb/level-db_test.go b/blockdb/level-db_test.go index f6c14c5..d1c8146 100644 --- a/blockdb/level-db_test.go +++ b/blockdb/level-db_test.go @@ -55,7 +55,9 @@ func (s *LevelDBTestSuite) TestBasicUsage() { block1 := types.Block{ ProposerID: validator1, Hash: hash1, - Height: 1, + Position: types.Position{ + Height: 1, + }, } err = db.Update(block1) s.Equal(ErrBlockDoesNotExist, err) @@ -102,7 +104,9 @@ func (s *LevelDBTestSuite) TestSyncIndex() { block := types.Block{ ProposerID: types.ValidatorID{Hash: common.NewRandomHash()}, Hash: common.NewRandomHash(), - Height: uint64(i), + Position: types.Position{ + Height: uint64(i), + }, } db.Put(block) blocks[i] = block @@ -121,7 +125,7 @@ func (s *LevelDBTestSuite) TestSyncIndex() { queried, err := db.Get(block.Hash) s.Nil(err) s.Equal(block.ProposerID, queried.ProposerID) - s.Equal(block.Height, queried.Height) + s.Equal(block.Position.Height, queried.Position.Height) } } diff --git a/blockdb/memory_test.go b/blockdb/memory_test.go index 9394c26..5c1261d 100644 --- a/blockdb/memory_test.go +++ b/blockdb/memory_test.go @@ -41,14 +41,18 @@ func (s *MemBackedBlockDBTestSuite) SetupSuite() { ProposerID: s.v0, ParentHash: genesisHash, Hash: genesisHash, - Height: 0, - Acks: make(map[common.Hash]struct{}), + Position: types.Position{ + Height: 0, + }, + Acks: make(map[common.Hash]struct{}), } s.b01 = &types.Block{ ProposerID: s.v0, ParentHash: s.b00.Hash, Hash: common.NewRandomHash(), - Height: 1, + Position: types.Position{ + Height: 1, + }, Acks: map[common.Hash]struct{}{ s.b00.Hash: struct{}{}, }, @@ -57,7 +61,9 @@ func (s *MemBackedBlockDBTestSuite) SetupSuite() { ProposerID: s.v0, ParentHash: s.b01.Hash, Hash: common.NewRandomHash(), - Height: 2, + Position: types.Position{ + Height: 2, + }, Acks: map[common.Hash]struct{}{ s.b01.Hash: struct{}{}, }, |