aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/app_test.go
diff options
context:
space:
mode:
authorHaoping Ku <haoping.ku@dexon.org>2018-10-19 11:43:46 +0800
committerGitHub <noreply@github.com>2018-10-19 11:43:46 +0800
commit6399946a1906190b140b546591a0f02e6199303c (patch)
treeea7c07b4d430a1ab9322f4cd17d31eec52170318 /core/test/app_test.go
parent6f672ebbd27a97815029050e4538f6d93d273771 (diff)
downloadtangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.tar
tangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.tar.gz
tangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.tar.bz2
tangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.tar.lz
tangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.tar.xz
tangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.tar.zst
tangerine-consensus-6399946a1906190b140b546591a0f02e6199303c.zip
core: total-ordering: change early flag to mode (#227)
* core: total-ordering: change early flag to mode
Diffstat (limited to 'core/test/app_test.go')
-rw-r--r--core/test/app_test.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/core/test/app_test.go b/core/test/app_test.go
index a70fc82..8f2aae5 100644
--- a/core/test/app_test.go
+++ b/core/test/app_test.go
@@ -22,6 +22,7 @@ import (
"time"
"github.com/dexon-foundation/dexon-consensus-core/common"
+ "github.com/dexon-foundation/dexon-consensus-core/core"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
"github.com/stretchr/testify/suite"
)
@@ -38,7 +39,7 @@ func (s *AppTestSuite) SetupSuite() {
common.NewRandomHash(),
common.NewRandomHash(),
},
- Early: false,
+ Mode: core.TotalOrderingModeNormal,
}
s.to2 = &AppTotalOrderRecord{
BlockHashes: common.Hashes{
@@ -46,13 +47,13 @@ func (s *AppTestSuite) SetupSuite() {
common.NewRandomHash(),
common.NewRandomHash(),
},
- Early: false,
+ Mode: core.TotalOrderingModeNormal,
}
s.to3 = &AppTotalOrderRecord{
BlockHashes: common.Hashes{
common.NewRandomHash(),
},
- Early: false,
+ Mode: core.TotalOrderingModeNormal,
}
}
@@ -62,7 +63,7 @@ func (s *AppTestSuite) setupAppByTotalOrderDeliver(
for _, h := range to.BlockHashes {
app.StronglyAcked(h)
}
- app.TotalOrderingDelivered(to.BlockHashes, to.Early)
+ app.TotalOrderingDelivered(to.BlockHashes, to.Mode)
for _, h := range to.BlockHashes {
// To make it simpler, use the index of hash sequence
// as the time.
@@ -98,7 +99,7 @@ func (s *AppTestSuite) TestCompare() {
s.setupAppByTotalOrderDeliver(app2, s.to2)
hash := common.NewRandomHash()
app2.StronglyAcked(hash)
- app2.TotalOrderingDelivered(common.Hashes{hash}, false)
+ app2.TotalOrderingDelivered(common.Hashes{hash}, core.TotalOrderingModeNormal)
s.deliverBlockWithTimeFromSequenceLength(app2, hash)
req.Equal(ErrMismatchBlockHashSequence, app1.Compare(app2))
// An App with different consensus time for the same block.
@@ -108,7 +109,7 @@ func (s *AppTestSuite) TestCompare() {
for _, h := range s.to3.BlockHashes {
app3.StronglyAcked(h)
}
- app3.TotalOrderingDelivered(s.to3.BlockHashes, s.to3.Early)
+ app3.TotalOrderingDelivered(s.to3.BlockHashes, s.to3.Mode)
wrongTime := time.Time{}.Add(
time.Duration(len(app3.DeliverSequence)) * time.Second)
wrongTime = wrongTime.Add(1 * time.Second)
@@ -139,7 +140,7 @@ func (s *AppTestSuite) TestVerify() {
for _, h := range s.to2.BlockHashes {
app2.StronglyAcked(h)
}
- app2.TotalOrderingDelivered(s.to2.BlockHashes, s.to2.Early)
+ app2.TotalOrderingDelivered(s.to2.BlockHashes, s.to2.Mode)
s.deliverBlock(app2, s.to2.BlockHashes[0], time.Time{})
req.Equal(ErrConsensusTimestampOutOfOrder, app2.Verify())
// A delivered block is not found in total ordering delivers.
@@ -155,10 +156,10 @@ func (s *AppTestSuite) TestVerify() {
for _, h := range s.to2.BlockHashes {
app4.StronglyAcked(h)
}
- app4.TotalOrderingDelivered(s.to2.BlockHashes, s.to2.Early)
+ app4.TotalOrderingDelivered(s.to2.BlockHashes, s.to2.Mode)
hash = common.NewRandomHash()
app4.StronglyAcked(hash)
- app4.TotalOrderingDelivered(common.Hashes{hash}, false)
+ app4.TotalOrderingDelivered(common.Hashes{hash}, core.TotalOrderingModeNormal)
s.deliverBlockWithTimeFromSequenceLength(app4, hash)
// Witness ack on unknown block.
app5 := NewApp()