From 5fc0efa940c7663a33d0fc501807a2627d2cb573 Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Fri, 28 Sep 2018 12:32:50 +0800 Subject: 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. --- core/test/utils.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/test/utils.go') 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) { -- cgit v1.2.3