aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/utils.go
diff options
context:
space:
mode:
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) {