aboutsummaryrefslogtreecommitdiffstats
path: root/core/configuration-chain_test.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-03-23 23:41:04 +0800
committerJimmy Hu <jimmy.hu@dexon.org>2019-03-23 23:41:04 +0800
commitd077a35470cf4b6e7c82bd4b03a1f2b87b0f9add (patch)
tree8bf24cbb04def6851a474bdc941e19bd8ce9c2e7 /core/configuration-chain_test.go
parentfb9bbdf2a34aa45c0f032b996f72cafd7bccfa80 (diff)
downloaddexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.tar
dexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.tar.gz
dexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.tar.bz2
dexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.tar.lz
dexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.tar.xz
dexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.tar.zst
dexon-consensus-d077a35470cf4b6e7c82bd4b03a1f2b87b0f9add.zip
core: refine DKG aborting (#512)
* Avoid aborting the DKG protocol registered later Although that DKG protocol would be registered after 1/2 round, both of them are triggered in separated go routine and we shouldn't assuem their execution order. * Capitalize logs * Add test * Return aborted when not running * Log DKG aborting result * Remove duplicated DKG abort
Diffstat (limited to 'core/configuration-chain_test.go')
-rw-r--r--core/configuration-chain_test.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/core/configuration-chain_test.go b/core/configuration-chain_test.go
index 0efafd2..7c73f41 100644
--- a/core/configuration-chain_test.go
+++ b/core/configuration-chain_test.go
@@ -607,6 +607,7 @@ func (s *ConfigurationChainTestSuite) TestDKGAbort() {
s.pubKeys, 100*time.Millisecond, &common.NullLogger{}, true,
), ConfigRoundShift)
s.Require().NoError(err)
+ gov.CatchUpWithRound(round + 1)
cache := utils.NewNodeSetCache(gov)
dbInst, err := db.NewMemBackedDB()
s.Require().NoError(err)
@@ -640,10 +641,44 @@ func (s *ConfigurationChainTestSuite) TestDKGAbort() {
// The third register shouldn't be blocked, too
randHash = common.NewRandomHash()
gov.ProposeCRS(round+1, randHash[:])
+ randHash = common.NewRandomHash()
+ gov.ResetDKG(randHash[:])
+ <-called
+ cc.registerDKG(context.Background(), round+1, reset+1, k)
+ err = <-errs
+ s.Require().EqualError(ErrDKGAborted, err.Error())
+ go func() {
+ called <- struct{}{}
+ errs <- cc.runDKG(round+1, reset+1)
+ }()
<-called
- cc.registerDKG(context.Background(), round+1, reset, k)
+ // Abort with older round, shouldn't be aborted.
+ aborted := cc.abortDKG(context.Background(), round, reset+1)
+ s.Require().False(aborted)
+ select {
+ case err = <-errs:
+ // Should not aborted yet.
+ s.Require().False(true)
+ default:
+ }
+ // Abort with older reset, shouldn't be aborted.
+ aborted = cc.abortDKG(context.Background(), round+1, reset)
+ s.Require().False(aborted)
+ select {
+ case err = <-errs:
+ // Should not aborted yet.
+ s.Require().False(true)
+ default:
+ }
+ // Abort with same round/reset, should be aborted.
+ aborted = cc.abortDKG(context.Background(), round+1, reset+1)
+ s.Require().True(aborted)
err = <-errs
s.Require().EqualError(ErrDKGAborted, err.Error())
+ // Abort while not running yet, should return "aborted".
+ cc.registerDKG(context.Background(), round+1, reset+1, k)
+ aborted = cc.abortDKG(context.Background(), round+1, reset+1)
+ s.Require().True(aborted)
}
func TestConfigurationChain(t *testing.T) {