From 8ba50ab2aaf8770821b0a6c4fbf66fa65935d01c Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Wed, 25 Jun 2025 16:57:23 +0800 Subject: [PATCH] trie: remove deprecated uses of math.rand (#1136) --- trie/encoding_test.go | 3 ++- trie/trie_test.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/trie/encoding_test.go b/trie/encoding_test.go index 16393313f7..65e775c325 100644 --- a/trie/encoding_test.go +++ b/trie/encoding_test.go @@ -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) diff --git a/trie/trie_test.go b/trie/trie_test.go index de68992c12..8ae4db0716 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -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) } }