aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/filter_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-03-23 02:48:51 +0800
committerFelix Lange <fjl@twurst.com>2017-03-23 03:49:15 +0800
commitf1534f5797664856218c8347366488f37f1e7924 (patch)
tree6a5d4a7dcfd72489bd4f7df70f5188a636947c24 /whisper/whisperv5/filter_test.go
parent9a2720fb35c9802c6dd61f9a49c48620b2ba2ecb (diff)
downloaddexon-f1534f5797664856218c8347366488f37f1e7924.tar
dexon-f1534f5797664856218c8347366488f37f1e7924.tar.gz
dexon-f1534f5797664856218c8347366488f37f1e7924.tar.bz2
dexon-f1534f5797664856218c8347366488f37f1e7924.tar.lz
dexon-f1534f5797664856218c8347366488f37f1e7924.tar.xz
dexon-f1534f5797664856218c8347366488f37f1e7924.tar.zst
dexon-f1534f5797664856218c8347366488f37f1e7924.zip
trie, whisper/whisperv5: use math/rand Read function
Diffstat (limited to 'whisper/whisperv5/filter_test.go')
-rw-r--r--whisper/whisperv5/filter_test.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/whisper/whisperv5/filter_test.go b/whisper/whisperv5/filter_test.go
index d69fb40db..1cf85b8d7 100644
--- a/whisper/whisperv5/filter_test.go
+++ b/whisper/whisperv5/filter_test.go
@@ -18,7 +18,7 @@ package whisperv5
import (
"math/big"
- "math/rand"
+ mrand "math/rand"
"testing"
"time"
@@ -33,12 +33,12 @@ var seed int64
// reproduciblity independent of their sequence.
func InitSingleTest() {
seed = time.Now().Unix()
- rand.Seed(seed)
+ mrand.Seed(seed)
}
func InitDebugTest(i int64) {
seed = i
- rand.Seed(seed)
+ mrand.Seed(seed)
}
type FilterTestCase struct {
@@ -55,7 +55,7 @@ func generateFilter(t *testing.T, symmetric bool) (*Filter, error) {
const topicNum = 8
f.Topics = make([]TopicType, topicNum)
for i := 0; i < topicNum; i++ {
- randomize(f.Topics[i][:])
+ mrand.Read(f.Topics[i][:])
f.Topics[i][0] = 0x01
}
@@ -68,7 +68,7 @@ func generateFilter(t *testing.T, symmetric bool) (*Filter, error) {
if symmetric {
f.KeySym = make([]byte, 12)
- randomize(f.KeySym)
+ mrand.Read(f.KeySym)
f.SymKeyHash = crypto.Keccak256Hash(f.KeySym)
} else {
f.KeyAsym, err = crypto.GenerateKey()
@@ -87,7 +87,7 @@ func generateTestCases(t *testing.T, SizeTestFilters int) []FilterTestCase {
for i := 0; i < SizeTestFilters; i++ {
f, _ := generateFilter(t, true)
cases[i].f = f
- cases[i].alive = (rand.Int()&int(1) == 0)
+ cases[i].alive = (mrand.Int()&int(1) == 0)
}
return cases
}
@@ -147,7 +147,7 @@ func TestComparePubKey(t *testing.T) {
}
// generate key3 == key1
- rand.Seed(seed)
+ mrand.Seed(seed)
key3, err := crypto.GenerateKey()
if err != nil {
t.Fatalf("failed to generate third key with seed %d: %s.", seed, err)
@@ -193,7 +193,7 @@ func TestMatchEnvelope(t *testing.T) {
}
// encrypt symmetrically
- i := rand.Int() % 4
+ i := mrand.Int() % 4
fsym.Topics[i] = params.Topic
fasym.Topics[i] = params.Topic
msg = NewSentMessage(params)
@@ -544,7 +544,7 @@ func TestWatchers(t *testing.T) {
var envelopes [NumMessages]*Envelope
for i = 0; i < NumMessages; i++ {
- j = rand.Uint32() % NumFilters
+ j = mrand.Uint32() % NumFilters
e = generateCompatibeEnvelope(t, tst[j].f)
envelopes[i] = e
tst[j].msgCnt++
@@ -597,7 +597,7 @@ func TestWatchers(t *testing.T) {
envelopes[0] = e
tst[0].msgCnt++
for i = 1; i < NumMessages; i++ {
- j = rand.Uint32() % NumFilters
+ j = mrand.Uint32() % NumFilters
e = generateCompatibeEnvelope(t, tst[j].f)
envelopes[i] = e
tst[j].msgCnt++