diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-10-11 19:33:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 19:33:25 +0800 |
commit | 490fa1e9ce2b661e4c8b612bd53f20123346353b (patch) | |
tree | 2ef4a4fabb1e21d46ef3e47538dadfeecdf2cf4d /core/test | |
parent | f3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c (diff) | |
download | tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.gz tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.bz2 tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.lz tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.xz tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.zst tangerine-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.zip |
core: change interface (#193)
* Extract types.FinalizationResult
* Change interface:
- Application.BlockConfirmed returns whole block.
- Application.BlockDelivered returns partial result.
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/app.go | 11 | ||||
-rw-r--r-- | core/test/app_test.go | 5 | ||||
-rw-r--r-- | core/test/stopper_test.go | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/core/test/app.go b/core/test/app.go index bf14d1b..60bc26f 100644 --- a/core/test/app.go +++ b/core/test/app.go @@ -114,7 +114,7 @@ func (app *App) VerifyBlock(block *types.Block) bool { } // BlockConfirmed implements Application interface. -func (app *App) BlockConfirmed(_ common.Hash) { +func (app *App) BlockConfirmed(_ types.Block) { } // StronglyAcked implements Application interface. @@ -145,15 +145,16 @@ func (app *App) TotalOrderingDelivered(blockHashes common.Hashes, early bool) { } // BlockDelivered implements Application interface. -func (app *App) BlockDelivered(block types.Block) { +func (app *App) BlockDelivered( + blockHash common.Hash, result types.FinalizationResult) { app.deliveredLock.Lock() defer app.deliveredLock.Unlock() - app.Delivered[block.Hash] = &AppDeliveredRecord{ - ConsensusTime: block.ConsensusTimestamp, + app.Delivered[blockHash] = &AppDeliveredRecord{ + ConsensusTime: result.Timestamp, When: time.Now().UTC(), } - app.DeliverSequence = append(app.DeliverSequence, block.Hash) + app.DeliverSequence = append(app.DeliverSequence, blockHash) } // Compare performs these checks against another App instance diff --git a/core/test/app_test.go b/core/test/app_test.go index 21d4e24..a70fc82 100644 --- a/core/test/app_test.go +++ b/core/test/app_test.go @@ -80,9 +80,8 @@ func (s *AppTestSuite) deliverBlockWithTimeFromSequenceLength( func (s *AppTestSuite) deliverBlock( app *App, hash common.Hash, timestamp time.Time) { - app.BlockDelivered(types.Block{ - Hash: hash, - ConsensusTimestamp: timestamp, + app.BlockDelivered(hash, types.FinalizationResult{ + Timestamp: timestamp, }) } diff --git a/core/test/stopper_test.go b/core/test/stopper_test.go index df207ec..e9954b0 100644 --- a/core/test/stopper_test.go +++ b/core/test/stopper_test.go @@ -61,9 +61,9 @@ func (s *StopperTestSuite) TestStopByConfirmedBlocks() { } app.TotalOrderingDelivered(hashes, false) for _, h := range hashes { - app.BlockDelivered(types.Block{ - Hash: h, - ConsensusTimestamp: time.Time{}}) + app.BlockDelivered(h, types.FinalizationResult{ + Timestamp: time.Time{}, + }) } } } |