diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-09-25 14:10:16 +0800 |
---|---|---|
committer | Wei-Ning Huang <aitjcize@gmail.com> | 2018-09-25 14:10:16 +0800 |
commit | 6c8d26d2e797e8420fc3de4b15e4c556f968aba0 (patch) | |
tree | 22beecc01da7a9ce5cac36135a89010d6d4ed4f2 /core/test/app_test.go | |
parent | ca935bdbac190766f29fb73433a82ee5806bc8f9 (diff) | |
download | tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.gz tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.bz2 tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.lz tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.xz tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.tar.zst tangerine-consensus-6c8d26d2e797e8420fc3de4b15e4c556f968aba0.zip |
core: add debug (#133)
* Split interface
* Rename nonblocking-application to nonblocking
Parts needs nonblocking gets more.
* Implement core.nonBlocking based on interface split
* Fix: the witness parent hash could be parent on compaction chain.
* Rename Application.DeliverBlock to BlockDeliver
To sync with naming of other methods.
* Change methods' fingerprint
- BlockConfirmed provides block hash only.
- BlockDeliver provde a whole block.
Diffstat (limited to 'core/test/app_test.go')
-rw-r--r-- | core/test/app_test.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/core/test/app_test.go b/core/test/app_test.go index 0003852..649ccbe 100644 --- a/core/test/app_test.go +++ b/core/test/app_test.go @@ -73,9 +73,18 @@ func (s *AppTestSuite) setupAppByTotalOrderDeliver( func (s *AppTestSuite) deliverBlockWithTimeFromSequenceLength( app *App, hash common.Hash) { - app.DeliverBlock( - hash, - time.Time{}.Add(time.Duration(len(app.DeliverSequence))*time.Second)) + s.deliverBlock(app, hash, time.Time{}.Add( + time.Duration(len(app.DeliverSequence))*time.Second)) +} + +func (s *AppTestSuite) deliverBlock( + app *App, hash common.Hash, timestamp time.Time) { + + app.BlockDeliver(types.Block{ + Hash: hash, + Witness: types.Witness{ + Timestamp: timestamp, + }}) } func (s *AppTestSuite) TestCompare() { @@ -105,7 +114,7 @@ func (s *AppTestSuite) TestCompare() { wrongTime := time.Time{}.Add( time.Duration(len(app3.DeliverSequence)) * time.Second) wrongTime = wrongTime.Add(1 * time.Second) - app3.DeliverBlock(s.to3.BlockHashes[0], wrongTime) + s.deliverBlock(app3, s.to3.BlockHashes[0], wrongTime) req.Equal(ErrMismatchConsensusTime, app1.Compare(app3)) req.Equal(ErrMismatchConsensusTime, app3.Compare(app1)) // An App without any delivered blocks. @@ -124,7 +133,7 @@ func (s *AppTestSuite) TestVerify() { s.setupAppByTotalOrderDeliver(app1, s.to3) req.Nil(app1.Verify()) // A delivered block without strongly ack - app1.DeliverBlock(common.NewRandomHash(), time.Time{}) + s.deliverBlock(app1, common.NewRandomHash(), time.Time{}) req.Equal(ErrDeliveredBlockNotAcked, app1.Verify()) // The consensus time is out of order. app2 := NewApp() @@ -133,7 +142,7 @@ func (s *AppTestSuite) TestVerify() { app2.StronglyAcked(h) } app2.TotalOrderingDeliver(s.to2.BlockHashes, s.to2.Early) - app2.DeliverBlock(s.to2.BlockHashes[0], time.Time{}) + s.deliverBlock(app2, s.to2.BlockHashes[0], time.Time{}) req.Equal(ErrConsensusTimestampOutOfOrder, app2.Verify()) // A delivered block is not found in total ordering delivers. app3 := NewApp() |