aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/utils.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-09-28 12:32:50 +0800
committerGitHub <noreply@github.com>2018-09-28 12:32:50 +0800
commit5fc0efa940c7663a33d0fc501807a2627d2cb573 (patch)
tree932ef05c2d091bdbe6bc38f0391d45993cc1f42c /core/test/utils.go
parent189a17a6586cd30ac355bd1165c44da6a2a08569 (diff)
downloaddexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.tar
dexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.tar.gz
dexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.tar.bz2
dexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.tar.lz
dexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.tar.xz
dexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.tar.zst
dexon-consensus-5fc0efa940c7663a33d0fc501807a2627d2cb573.zip
core: hide types.NodeID from full node. (#147)
* Refine core.Governance interface - Remove types.NodeID from interface declaration. - All parameter should be round based. * Add core.NodeSetCache * Agreement accepts map of nodeID directly. * test.Transport.Peers method return public keys.
Diffstat (limited to 'core/test/utils.go')
-rw-r--r--core/test/utils.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/test/utils.go b/core/test/utils.go
index 887ef14..2fc21ce 100644
--- a/core/test/utils.go
+++ b/core/test/utils.go
@@ -24,6 +24,8 @@ import (
"time"
"github.com/dexon-foundation/dexon-consensus-core/common"
+ "github.com/dexon-foundation/dexon-consensus-core/core/crypto"
+ "github.com/dexon-foundation/dexon-consensus-core/core/crypto/ecdsa"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
)
@@ -43,6 +45,18 @@ func GenerateRandomNodeIDs(nodeCount int) (nIDs types.NodeIDs) {
return
}
+// GenerateRandomPrivateKeys generate a set of private keys.
+func GenerateRandomPrivateKeys(nodeCount int) (prvKeys []crypto.PrivateKey) {
+ for i := 0; i < nodeCount; i++ {
+ prvKey, err := ecdsa.NewPrivateKey()
+ if err != nil {
+ panic(err)
+ }
+ prvKeys = append(prvKeys, prvKey)
+ }
+ return
+}
+
// CalcLatencyStatistics calculates average and deviation from a slice
// of latencies.
func CalcLatencyStatistics(latencies []time.Duration) (avg, dev time.Duration) {