aboutsummaryrefslogtreecommitdiffstats
path: root/core/test
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-04 14:56:00 +0800
committerGitHub <noreply@github.com>2018-10-04 14:56:00 +0800
commit149e918f4fc78632483bf549dd8f5ffe55366e18 (patch)
treefeabcb67103d76cc829ea81a1d57735e71db23d8 /core/test
parent519cc8a734a510f44463b8dd175b7505f0308a22 (diff)
downloaddexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.tar
dexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.tar.gz
dexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.tar.bz2
dexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.tar.lz
dexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.tar.xz
dexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.tar.zst
dexon-consensus-149e918f4fc78632483bf549dd8f5ffe55366e18.zip
core: Check Witness height. Add ConsensusTime and ConsensusHeight to block. (#170)
Diffstat (limited to 'core/test')
-rw-r--r--core/test/app.go15
-rw-r--r--core/test/app_test.go7
-rw-r--r--core/test/stopper_test.go4
3 files changed, 16 insertions, 10 deletions
diff --git a/core/test/app.go b/core/test/app.go
index 3ec670c..bf14d1b 100644
--- a/core/test/app.go
+++ b/core/test/app.go
@@ -96,9 +96,16 @@ func NewApp() *App {
}
}
-// PrepareBlock implements Application interface.
-func (app *App) PrepareBlock(position types.Position) ([]byte, []byte) {
- return []byte{}, []byte{}
+// PreparePayload implements Application interface.
+func (app *App) PreparePayload(position types.Position) []byte {
+ return []byte{}
+}
+
+// PrepareWitness implements Application interface.
+func (app *App) PrepareWitness(height uint64) types.Witness {
+ return types.Witness{
+ Height: height,
+ }
}
// VerifyBlock implements Application.
@@ -143,7 +150,7 @@ func (app *App) BlockDelivered(block types.Block) {
defer app.deliveredLock.Unlock()
app.Delivered[block.Hash] = &AppDeliveredRecord{
- ConsensusTime: block.Witness.Timestamp,
+ ConsensusTime: block.ConsensusTimestamp,
When: time.Now().UTC(),
}
app.DeliverSequence = append(app.DeliverSequence, block.Hash)
diff --git a/core/test/app_test.go b/core/test/app_test.go
index baea838..21d4e24 100644
--- a/core/test/app_test.go
+++ b/core/test/app_test.go
@@ -81,10 +81,9 @@ func (s *AppTestSuite) deliverBlock(
app *App, hash common.Hash, timestamp time.Time) {
app.BlockDelivered(types.Block{
- Hash: hash,
- Witness: types.Witness{
- Timestamp: timestamp,
- }})
+ Hash: hash,
+ ConsensusTimestamp: timestamp,
+ })
}
func (s *AppTestSuite) TestCompare() {
diff --git a/core/test/stopper_test.go b/core/test/stopper_test.go
index de1c1a5..df207ec 100644
--- a/core/test/stopper_test.go
+++ b/core/test/stopper_test.go
@@ -62,8 +62,8 @@ func (s *StopperTestSuite) TestStopByConfirmedBlocks() {
app.TotalOrderingDelivered(hashes, false)
for _, h := range hashes {
app.BlockDelivered(types.Block{
- Hash: h,
- Witness: types.Witness{Timestamp: time.Time{}}})
+ Hash: h,
+ ConsensusTimestamp: time.Time{}})
}
}
}