diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-09 14:12:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-09 14:12:15 +0800 |
commit | d28cc2c0cf87061fed9356509a28a307b9f55943 (patch) | |
tree | 09ac5ccd9ec721072f2c653e8201c1487e9e265c /core/types/block_test.go | |
parent | 7326f9722771633f3d137944c814544888a7a87f (diff) | |
download | dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.gz dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.bz2 dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.lz dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.xz dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.tar.zst dexon-consensus-d28cc2c0cf87061fed9356509a28a307b9f55943.zip |
core: Add Block.IsGenesis() and set Block.ParentHash to 0 in genesis block. (#37)
Diffstat (limited to 'core/types/block_test.go')
-rw-r--r-- | core/types/block_test.go | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/core/types/block_test.go b/core/types/block_test.go index 8297508..2087373 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -1,15 +1,15 @@ // Copyright 2018 The dexon-consensus-core Authors // This file is part of the dexon-consensus-core library. // -// The dexon-consensus-core library is free software: you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as +// The dexon-consensus-core library is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation, either version 3 of the License, // or (at your option) any later version. // -// The dexon-consensus-core library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. +// The dexon-consensus-core library is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with the dexon-consensus-core library. If not, see @@ -62,6 +62,24 @@ func (s *BlockTestSuite) TestSortByHeight() { s.Equal(blocks[3].Hash, b3.Hash) } +func (s *BlockTestSuite) TestGenesisBlock() { + b0 := &Block{ + Height: 0, + ParentHash: common.Hash{}, + } + s.True(b0.IsGenesis()) + b1 := &Block{ + Height: 1, + ParentHash: common.Hash{}, + } + s.False(b1.IsGenesis()) + b2 := &Block{ + Height: 0, + ParentHash: common.NewRandomHash(), + } + s.False(b2.IsGenesis()) +} + func TestBlock(t *testing.T) { suite.Run(t, new(BlockTestSuite)) } |