aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/table_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-06-10 21:15:35 +0800
committerFelix Lange <fjl@twurst.com>2015-06-10 21:18:01 +0800
commita8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a (patch)
tree0cf1b8ec34d327821c256b9301c036875c2d5497 /p2p/discover/table_test.go
parent261a8077c410c50999d662bd1ca871b7ef414909 (diff)
downloadgo-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.tar
go-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.tar.gz
go-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.tar.bz2
go-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.tar.lz
go-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.tar.xz
go-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.tar.zst
go-tangerine-a8e4cb6dfe9dbaf3f5bf19807406577ee116cc2a.zip
p2p/discover: use separate rand.Source instances in tests
rand.Source isn't safe for concurrent use.
Diffstat (limited to 'p2p/discover/table_test.go')
-rw-r--r--p2p/discover/table_test.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/p2p/discover/table_test.go b/p2p/discover/table_test.go
index da398d137..829899916 100644
--- a/p2p/discover/table_test.go
+++ b/p2p/discover/table_test.go
@@ -9,6 +9,7 @@ import (
"reflect"
"testing"
"testing/quick"
+ "time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
@@ -74,7 +75,7 @@ func TestBucket_bumpNoDuplicates(t *testing.T) {
t.Parallel()
cfg := &quick.Config{
MaxCount: 1000,
- Rand: quickrand,
+ Rand: rand.New(rand.NewSource(time.Now().Unix())),
Values: func(args []reflect.Value, rand *rand.Rand) {
// generate a random list of nodes. this will be the content of the bucket.
n := rand.Intn(bucketSize-1) + 1
@@ -205,7 +206,7 @@ func TestTable_closest(t *testing.T) {
}
return true
}
- if err := quick.Check(test, quickcfg); err != nil {
+ if err := quick.Check(test, quickcfg()); err != nil {
t.Error(err)
}
}
@@ -213,7 +214,7 @@ func TestTable_closest(t *testing.T) {
func TestTable_ReadRandomNodesGetAll(t *testing.T) {
cfg := &quick.Config{
MaxCount: 200,
- Rand: quickrand,
+ Rand: rand.New(rand.NewSource(time.Now().Unix())),
Values: func(args []reflect.Value, rand *rand.Rand) {
args[0] = reflect.ValueOf(make([]*Node, rand.Intn(1000)))
},
@@ -221,7 +222,7 @@ func TestTable_ReadRandomNodesGetAll(t *testing.T) {
test := func(buf []*Node) bool {
tab := newTable(nil, NodeID{}, &net.UDPAddr{}, "")
for i := 0; i < len(buf); i++ {
- ld := quickrand.Intn(len(tab.buckets))
+ ld := cfg.Rand.Intn(len(tab.buckets))
tab.add([]*Node{nodeAtDistance(tab.self.sha, ld)})
}
gotN := tab.ReadRandomNodes(buf)