diff --git a/random/random.go b/random/random.go index 81e729a..a677a83 100644 --- a/random/random.go +++ b/random/random.go @@ -86,8 +86,7 @@ func BlocksOfSize(n int, size int) []blocks.Block { // Bytes returns a byte array of the given size with random values. func Bytes(n int) []byte { data := make([]byte, n) - rng := NewRand() - rng.Read(data) + NewRand().Read(data) return data } @@ -114,8 +113,7 @@ func Cids(n int) []cid.Cid { // Identity returns a random unique peer ID, private key, and public key. func Identity() (peer.ID, crypto.PrivKey, crypto.PubKey) { - rng := NewRand() - privKey, pubKey, err := crypto.GenerateKeyPairWithReader(crypto.Ed25519, 256, rng) + privKey, pubKey, err := crypto.GenerateKeyPairWithReader(crypto.Ed25519, 256, NewRand()) if err != nil { panic(err) } diff --git a/random/random_test.go b/random/random_test.go index 3540229..b98f855 100644 --- a/random/random_test.go +++ b/random/random_test.go @@ -167,3 +167,12 @@ func TestNewRand(t *testing.T) { } require.False(t, allEqual) } + +func TestRead(t *testing.T) { + buf1 := make([]byte, 16) + buf2 := make([]byte, 16) + + random.NewRand().Read(buf1) + random.NewRand().Read(buf2) + require.NotEqual(t, buf1, buf2) +} diff --git a/version.json b/version.json index 4f0adde..edc249c 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "v0.0.3" + "version": "v0.0.4" }