all: remove deprecated uses of math.rand #26710 (#1549)

This commit is contained in:
Daniel Liu 2025-09-22 20:42:14 +08:00 committed by GitHub
parent 07399bc552
commit 31f5c7da88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 0 additions and 9 deletions

View file

@ -3,7 +3,6 @@ package lendingstate
import (
"fmt"
"math/big"
"math/rand"
"os"
"testing"
"time"
@ -521,7 +520,6 @@ func sendOrder(nonce uint64) {
os.Exit(1)
}
defer rpcClient.Close()
rand.Seed(time.Now().UTC().UnixNano())
item := &LendingOrderMsg{
AccountNonce: nonce,
Quantity: EtherToWei(big.NewInt(1000)),

View file

@ -81,7 +81,6 @@ func randomHash() common.Hash {
letterBytes := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
var b common.Hash
for i := range b {
rand.Seed(time.Now().UnixNano())
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return b

View file

@ -22,7 +22,6 @@ import (
"math/big"
"math/rand"
"testing"
"time"
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind"
"github.com/XinFinOrg/XDPoSChain/accounts/abi/bind/backends"
@ -121,7 +120,6 @@ func randomHash() common.Hash {
letterBytes := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
var b common.Hash
for i := range b {
rand.Seed(time.Now().UnixNano())
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return b
@ -170,7 +168,6 @@ func isArrayEqual(a [][]int64, b [][]int64) bool {
func TestGenM2FromRandomize(t *testing.T) {
var a []int64
for i := 0; i <= 10; i++ {
rand.Seed(time.Now().UTC().UnixNano())
a = append(a, int64(rand.Intn(9999)))
}
b, err := GenM2FromRandomize(a, common.MaxMasternodes)

View file

@ -131,7 +131,6 @@ func TestRewardBalance(t *testing.T) {
}
logCaps := make(map[int]*logCap)
for i := 0; i <= 10; i++ {
rand.Seed(time.Now().UTC().UnixNano())
randIndex := rand.Intn(len(accounts))
randCap := rand.Intn(10) * 1000
if randCap <= 0 {

View file

@ -100,7 +100,6 @@ func TestSubscribeDuplicateType(t *testing.T) {
}
func TestMuxConcurrent(t *testing.T) {
rand.Seed(time.Now().Unix())
mux := new(TypeMux)
defer mux.Stop()

View file

@ -147,7 +147,6 @@ func TestUDP_responseTimeouts(t *testing.T) {
test := newUDPTest(t)
defer test.table.Close()
rand.Seed(time.Now().UnixNano())
randomDuration := func(max time.Duration) time.Duration {
return time.Duration(rand.Int63n(int64(max)))
}