aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/governance.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-03 14:04:01 +0800
committerGitHub <noreply@github.com>2018-10-03 14:04:01 +0800
commit4d2cd087071d4892afae383dae98dcbdb8431e9b (patch)
treef046d3f6ddffce64f4f082a33db571056621b020 /core/test/governance.go
parenteb1fa8a1f9e8ba3cab764ecfe06336e63d798184 (diff)
downloaddexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.tar
dexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.tar.gz
dexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.tar.bz2
dexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.tar.lz
dexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.tar.xz
dexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.tar.zst
dexon-consensus-4d2cd087071d4892afae383dae98dcbdb8431e9b.zip
core: Add unit test for DKG CRS in consensus (#163)
Diffstat (limited to 'core/test/governance.go')
-rw-r--r--core/test/governance.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/test/governance.go b/core/test/governance.go
index 473c331..5c7ae02 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -18,6 +18,7 @@
package test
import (
+ "encoding/json"
"fmt"
"sync"
"time"
@@ -106,11 +107,15 @@ func (g *Governance) Configuration(_ uint64) *types.Config {
// CRS returns the CRS for a given round.
func (g *Governance) CRS(round uint64) common.Hash {
+ g.lock.RLock()
+ defer g.lock.RUnlock()
return g.crs[round]
}
// ProposeCRS propose a CRS.
func (g *Governance) ProposeCRS(round uint64, signedCRS []byte) {
+ g.lock.Lock()
+ defer g.lock.Unlock()
g.crs[round] = crypto.Keccak256Hash(signedCRS)
}
@@ -165,5 +170,12 @@ func (g *Governance) DKGMasterPublicKeys(
if !exist {
return []*types.DKGMasterPublicKey{}
}
- return masterPublicKeys
+ mpks := make([]*types.DKGMasterPublicKey, 0, len(masterPublicKeys))
+ for _, mpk := range masterPublicKeys {
+ bytes, _ := json.Marshal(mpk)
+ mpkCopy := types.NewDKGMasterPublicKey()
+ json.Unmarshal(bytes, mpkCopy)
+ mpks = append(mpks, mpkCopy)
+ }
+ return mpks
}