diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-30 17:21:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 17:21:58 +0800 |
commit | 96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8 (patch) | |
tree | 418e2c43acf4f9c13289eaccf66f94ef46c9356b /core/crypto_test.go | |
parent | a4e0da981a3dfc8817d39be65cb5b24938b0761a (diff) | |
download | dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.gz dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.bz2 dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.lz dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.xz dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.zst dexon-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.zip |
core: Add PreparePayloads to Application and Remove blockConverter interface. (#84)
Diffstat (limited to 'core/crypto_test.go')
-rw-r--r-- | core/crypto_test.go | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/core/crypto_test.go b/core/crypto_test.go index 62f7daa..f4013be 100644 --- a/core/crypto_test.go +++ b/core/crypto_test.go @@ -34,22 +34,6 @@ type CryptoTestSuite struct { var myVID = types.ValidatorID{Hash: common.NewRandomHash()} -type simpleBlock struct { - block *types.Block -} - -func (sb *simpleBlock) Block() *types.Block { - return sb.block -} - -func (sb *simpleBlock) Payloads() [][]byte { - return [][]byte{} -} - -func (sb *simpleBlock) SetBlock(block *types.Block) { - *sb.block = *block -} - func (s *CryptoTestSuite) prepareBlock(prevBlock *types.Block) *types.Block { acks := make(map[common.Hash]struct{}) timestamps := make(map[types.ValidatorID]time.Time) @@ -84,7 +68,7 @@ func (s *CryptoTestSuite) prepareBlock(prevBlock *types.Block) *types.Block { func (s *CryptoTestSuite) newBlock(prevBlock *types.Block) *types.Block { block := s.prepareBlock(prevBlock) var err error - block.Hash, err = hashBlock(&simpleBlock{block: block}) + block.Hash, err = hashBlock(block) s.Require().Nil(err) return block } @@ -177,17 +161,17 @@ func (s *CryptoTestSuite) TestBlockSignature() { parentBlock, exist := blockMap[block.ParentHash] s.Require().True(exist) s.True(parentBlock.Height == block.Height-1) - hash, err := hashBlock(&simpleBlock{block: parentBlock}) + hash, err := hashBlock(parentBlock) s.Require().Nil(err) s.Equal(hash, block.ParentHash) } - s.True(verifyBlockSignature(pub, &simpleBlock{block: block}, block.Signature)) + s.True(verifyBlockSignature(pub, block, block.Signature)) } // Modify Block.Acks and verify signature again. for _, block := range blocks { block.Acks[common.NewRandomHash()] = struct{}{} s.False(verifyBlockSignature( - pub, &simpleBlock{block: block}, block.Signature)) + pub, block, block.Signature)) } } |