aboutsummaryrefslogtreecommitdiffstats
path: root/dex/nodetable_test.go
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-17 18:02:52 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:23:39 +0800
commit977d2e13c1616fa21705960c6765ccd33141141d (patch)
treef3fe55f788b0ca0ee1cf39bd456190c6b4e51ce4 /dex/nodetable_test.go
parent29cb2039698ec0dd7cbb0a45693d3967f24aa84f (diff)
downloadgo-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.tar
go-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.tar.gz
go-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.tar.bz2
go-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.tar.lz
go-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.tar.xz
go-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.tar.zst
go-tangerine-977d2e13c1616fa21705960c6765ccd33141141d.zip
dex: polish network related function
Diffstat (limited to 'dex/nodetable_test.go')
-rw-r--r--dex/nodetable_test.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/dex/nodetable_test.go b/dex/nodetable_test.go
index 5b3f7de57..2e44eabe5 100644
--- a/dex/nodetable_test.go
+++ b/dex/nodetable_test.go
@@ -1,11 +1,13 @@
package dex
import (
- "math/rand"
+ "crypto/ecdsa"
"testing"
"time"
"github.com/dexon-foundation/dexon/common"
+ "github.com/dexon-foundation/dexon/crypto"
+ "github.com/dexon-foundation/dexon/p2p/discover"
"github.com/dexon-foundation/dexon/p2p/enode"
)
@@ -85,9 +87,14 @@ func TestNodeTable(t *testing.T) {
}
}
-func randomID() (id enode.ID) {
- for i := range id {
- id[i] = byte(rand.Intn(255))
+func randomID() enode.ID {
+ var err error
+ var privkey *ecdsa.PrivateKey
+ for {
+ privkey, err = crypto.GenerateKey()
+ if err == nil {
+ break
+ }
}
- return id
+ return discover.PubkeyID(&(privkey.PublicKey))
}