From 1f5dfaec16fa99b8e588fa7f03df53c5bc001dba Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:30:47 +0800 Subject: [PATCH] chore: fix lint --- pkg/util/fr32/fr32_test.go | 9 ++++++--- venus-shared/testutil/value_provider_primitive.go | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/util/fr32/fr32_test.go b/pkg/util/fr32/fr32_test.go index 182433d3c0..cd711b1ea9 100644 --- a/pkg/util/fr32/fr32_test.go +++ b/pkg/util/fr32/fr32_test.go @@ -74,7 +74,8 @@ func TestPadChunkRandEqFFI(t *testing.T) { tf.UnitTest(t) for i := 0; i < 200; i++ { var input [127]byte - rand.Read(input[:]) + _, err := rand.Read(input[:]) + require.NoError(t, err) var buf [128]byte @@ -113,7 +114,8 @@ func TestRoundtripChunkRand(t *testing.T) { tf.UnitTest(t) for i := 0; i < 200; i++ { var input [127]byte - rand.Read(input[:]) + _, err := rand.Read(input[:]) + require.NoError(t, err) var buf [128]byte copy(buf[:], input[:]) @@ -132,7 +134,8 @@ func TestRoundtrip16MRand(t *testing.T) { up := abi.PaddedPieceSize(16 << 20).Unpadded() input := make([]byte, up) - rand.Read(input[:]) + _, err := rand.Read(input[:]) + require.NoError(t, err) buf := make([]byte, 16<<20) diff --git a/venus-shared/testutil/value_provider_primitive.go b/venus-shared/testutil/value_provider_primitive.go index eeda9eebad..00366a140c 100644 --- a/venus-shared/testutil/value_provider_primitive.go +++ b/venus-shared/testutil/value_provider_primitive.go @@ -1,9 +1,12 @@ package testutil import ( + crand "crypto/rand" "encoding/hex" "math/rand" "testing" + + "github.com/stretchr/testify/require" ) func init() { @@ -33,7 +36,8 @@ func IntRangedProvider(min, max int) func(*testing.T) int { func BytesFixedProvider(size int) func(*testing.T) []byte { return func(t *testing.T) []byte { b := make([]byte, size) - rand.Read(b[:]) + _, err := crand.Read(b[:]) + require.NoError(t, err) return b } } @@ -41,7 +45,8 @@ func BytesFixedProvider(size int) func(*testing.T) []byte { func BytesAtMostProvider(size int) func(*testing.T) []byte { return func(t *testing.T) []byte { b := make([]byte, rand.Intn(size)) - rand.Read(b[:]) + _, err := crand.Read(b[:]) + require.NoError(t, err) return b } }