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

View file

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