trie: remove deprecated uses of math.rand (#1136)

This commit is contained in:
Daniel Liu 2025-06-25 16:57:23 +08:00 committed by GitHub
parent 416c5cb7dd
commit 8ba50ab2aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -18,6 +18,7 @@ package trie
import ( import (
"bytes" "bytes"
crand "crypto/rand"
"encoding/hex" "encoding/hex"
"math/rand" "math/rand"
"testing" "testing"
@ -97,7 +98,7 @@ func TestHexToCompactInPlaceRandom(t *testing.T) {
for i := 0; i < 10000; i++ { for i := 0; i < 10000; i++ {
l := rand.Intn(128) l := rand.Intn(128)
key := make([]byte, l) key := make([]byte, l)
rand.Read(key) crand.Read(key)
hexBytes := keybytesToHex(key) hexBytes := keybytesToHex(key)
hexOrig := []byte(string(hexBytes)) hexOrig := []byte(string(hexBytes))
exp := hexToCompact(hexBytes) exp := hexToCompact(hexBytes)

View file

@ -18,6 +18,7 @@ package trie
import ( import (
"bytes" "bytes"
crand "crypto/rand"
"encoding/binary" "encoding/binary"
"errors" "errors"
"fmt" "fmt"
@ -835,8 +836,8 @@ func TestDecodeNode(t *testing.T) {
elems = make([]byte, 20) elems = make([]byte, 20)
) )
for i := 0; i < 5000000; i++ { for i := 0; i < 5000000; i++ {
rand.Read(hash) crand.Read(hash)
rand.Read(elems) crand.Read(elems)
decodeNode(hash, elems) decodeNode(hash, elems)
} }
} }