diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-09-20 16:08:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 16:08:08 +0800 |
commit | a4b6b9e6a28a4d8fc49ee76c191454a819265713 (patch) | |
tree | 716e5724b182b8dccb01a49faec4c163f1fafdb0 /core/compaction-chain_test.go | |
parent | 2f1e71d9d298d1f6ade8d17a1db7a657b0223872 (diff) | |
download | tangerine-consensus-a4b6b9e6a28a4d8fc49ee76c191454a819265713.tar.gz tangerine-consensus-a4b6b9e6a28a4d8fc49ee76c191454a819265713.tar.zst tangerine-consensus-a4b6b9e6a28a4d8fc49ee76c191454a819265713.zip |
core: refactor witness data processing flow (#124)
Since witness data need to include data from application after it
processed a block (e.g. stateRoot). We should make the process of
witness data asynchronous.
An interface `BlockProcessedChan()` is added to the application
interface to return a channel for notifying the consensus core when a
block is processed. The notification object includes a byte slice
(witenss data) which will be include in the final witness data object.
Diffstat (limited to 'core/compaction-chain_test.go')
-rw-r--r-- | core/compaction-chain_test.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/core/compaction-chain_test.go b/core/compaction-chain_test.go index 5c08798..3603fb6 100644 --- a/core/compaction-chain_test.go +++ b/core/compaction-chain_test.go @@ -93,20 +93,20 @@ func (s *CompactionChainTestSuite) TestProcessBlock() { func (s *CompactionChainTestSuite) TestPrepareWitnessAck() { cc := s.newCompactionChain() - blocks := s.generateBlocks(10, cc) + blocks := s.generateBlocks(2, cc) prv, err := eth.NewPrivateKey() s.Require().Nil(err) - for _, block := range blocks { - witnessAck, err := cc.prepareWitnessAck(prv) - s.Require().Nil(err) - if cc.prevBlock != nil { - s.True(verifyWitnessSignature( - prv.PublicKey(), - cc.prevBlock, - witnessAck.Signature)) - s.Equal(witnessAck.WitnessBlockHash, cc.prevBlock.Hash) - } - cc.prevBlock = block + + block := blocks[1] + witnessAck, err := cc.prepareWitnessAck(block, prv) + s.Require().Nil(err) + if cc.prevBlock != nil { + verified, _ := verifyWitnessSignature( + prv.PublicKey(), + cc.prevBlock, + witnessAck.Signature) + s.True(verified) + s.Equal(witnessAck.WitnessBlockHash, block.Hash) } } @@ -123,9 +123,9 @@ func (s *CompactionChainTestSuite) TestProcessWitnessAck() { witnessAcks2 := []*types.WitnessAck{} for _, block := range blocks { cc.prevBlock = block - witnessAck1, err := cc.prepareWitnessAck(prv1) + witnessAck1, err := cc.prepareWitnessAck(block, prv1) s.Require().Nil(err) - witnessAck2, err := cc.prepareWitnessAck(prv2) + witnessAck2, err := cc.prepareWitnessAck(block, prv2) s.Require().Nil(err) witnessAcks1 = append(witnessAcks1, witnessAck1) witnessAcks2 = append(witnessAcks2, witnessAck2) |