aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-09-26 17:41:46 +0800
committerGitHub <noreply@github.com>2018-09-26 17:41:46 +0800
commitfb1a443ea8c527eebcb59bd8f8f52791ace6284b (patch)
tree12f81429ba1461d9b1ec2bbc4c0cd7e1a2ac2de2
parent7450e6ba7f7299d03b04a7e2a9b3bc5911b94cfe (diff)
downloaddexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.tar
dexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.tar.gz
dexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.tar.bz2
dexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.tar.lz
dexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.tar.xz
dexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.tar.zst
dexon-consensus-fb1a443ea8c527eebcb59bd8f8f52791ace6284b.zip
Fix racing (#142)
-rw-r--r--core/configuration-chain_test.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/configuration-chain_test.go b/core/configuration-chain_test.go
index 050fdf0..4c1e62d 100644
--- a/core/configuration-chain_test.go
+++ b/core/configuration-chain_test.go
@@ -155,7 +155,7 @@ func (s *ConfigurationChainTestSuite) TestConfigurationChain() {
recv := newTestCCReceiver(s)
for _, nID := range s.nIDs {
- gov, err := test.NewGovernance(0, 50*time.Millisecond)
+ gov, err := test.NewGovernance(0, 100*time.Millisecond)
s.Require().NoError(err)
cfgChains[nID] = newConfigurationChain(nID, recv, gov)
recv.nodes[nID] = cfgChains[nID]
@@ -193,11 +193,13 @@ func (s *ConfigurationChainTestSuite) TestConfigurationChain() {
}
tsigs := make([]crypto.Signature, 0, n)
- tsigChan := make(chan crypto.Signature)
+ errs := make(chan error, n)
+ tsigChan := make(chan crypto.Signature, n)
for _, cc := range cfgChains {
go func(cc *configurationChain) {
tsig, err := cc.runBlockTSig(round, hash)
- s.Require().NoError(err)
+ // Prevent racing by collecting errors and check ing main thread.
+ errs <- err
tsigChan <- tsig
}(cc)
for _, psig := range psigs {
@@ -206,6 +208,7 @@ func (s *ConfigurationChainTestSuite) TestConfigurationChain() {
}
}
for range cfgChains {
+ s.Require().NoError(<-errs)
tsig := <-tsigChan
for _, prevTsig := range tsigs {
s.Equal(prevTsig, tsig)