aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/governance.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-14 23:48:40 +0800
committerGitHub <noreply@github.com>2018-08-14 23:48:40 +0800
commitc4bfb69724f5fb777fbf5fc272dc65a0f9d1f368 (patch)
treeb6eb1a43c11f796cbcdd6267298d7f41ac4dad1b /core/test/governance.go
parent763404d4158c917297012cf06634eb1697b459d6 (diff)
downloadtangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.tar
tangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.tar.gz
tangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.tar.bz2
tangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.tar.lz
tangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.tar.xz
tangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.tar.zst
tangerine-consensus-c4bfb69724f5fb777fbf5fc272dc65a0f9d1f368.zip
core: Prepare Genesis block. (#54)
Diffstat (limited to 'core/test/governance.go')
-rw-r--r--core/test/governance.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/core/test/governance.go b/core/test/governance.go
index a7ae1b0..a4e86d1 100644
--- a/core/test/governance.go
+++ b/core/test/governance.go
@@ -18,8 +18,9 @@
package test
import (
- "github.com/dexon-foundation/dexon-consensus-core/common"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
+ "github.com/dexon-foundation/dexon-consensus-core/crypto"
+ "github.com/dexon-foundation/dexon-consensus-core/crypto/eth"
"github.com/shopspring/decimal"
)
@@ -27,18 +28,25 @@ import (
type Governance struct {
BlockProposingInterval int
Validators map[types.ValidatorID]decimal.Decimal
+ PrivateKeys map[types.ValidatorID]crypto.PrivateKey
}
// NewGovernance constructs a Governance instance.
-func NewGovernance(validatorCount, proposingInterval int) (g *Governance) {
-
+func NewGovernance(validatorCount, proposingInterval int) (
+ g *Governance, err error) {
g = &Governance{
BlockProposingInterval: proposingInterval,
Validators: make(map[types.ValidatorID]decimal.Decimal),
+ PrivateKeys: make(map[types.ValidatorID]crypto.PrivateKey),
}
for i := 0; i < validatorCount; i++ {
- g.Validators[types.ValidatorID{Hash: common.NewRandomHash()}] =
- decimal.NewFromFloat(0)
+ prv, err := eth.NewPrivateKey()
+ if err != nil {
+ return nil, err
+ }
+ vID := types.NewValidatorID(prv.PublicKey())
+ g.Validators[vID] = decimal.NewFromFloat(0)
+ g.PrivateKeys[vID] = prv
}
return
}