Skip to content

Commit

Permalink
fix: replace math/rand#Read with crypto/rand#Read
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Feb 16, 2023
1 parent 5950c1a commit a580e5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion benchmarks/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package graphsync_test
import (
"bytes"
"context"
crand "crypto/rand"
"fmt"
"math/rand"
"os"
Expand Down Expand Up @@ -264,7 +265,7 @@ const defaultUnixfsLinksPerLevel = 1024
func loadRandomUnixFxFile(ctx context.Context, b *testing.B, bs blockstore.Blockstore, size uint64, unixfsChunkSize uint64, unixfsLinksPerLevel int, useRawNodes bool) cid.Cid {

data := make([]byte, size)
_, err := rand.Read(data)
_, err := crand.Read(data)
require.NoError(b, err)
buf := bytes.NewReader(data)
file := files.NewReaderFile(buf)
Expand Down
5 changes: 3 additions & 2 deletions responsemanager/queryexecutor/queryexecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package queryexecutor
import (
"bytes"
"context"
"crypto/rand"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -220,15 +221,15 @@ func TestSmallGraphTask(t *testing.T) {

func newRandomBlock(index int64) *blockData {
digest := make([]byte, 32)
_, err := rand.Read(digest)
_, err := crand.Read(digest)
if err != nil {
panic(err)
}
mh, _ := multihash.Encode(digest, multihash.SHA2_256)
c := cid.NewCidV1(cid.DagCBOR, mh)
link := &cidlink.Link{Cid: c}
data := make([]byte, rand.Intn(64)+1)
_, err = rand.Read(data)
_, err = crand.Read(data)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit a580e5d

Please sign in to comment.