Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Jul 13, 2024
1 parent 4c0ccb3 commit 54ffc8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 2 additions & 4 deletions random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
}
Expand Down
9 changes: 9 additions & 0 deletions random/random_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.0.3"
"version": "v0.0.4"
}

0 comments on commit 54ffc8e

Please sign in to comment.