Skip to content

Commit 86ae2f5

Browse files
authored
Merge pull request #7 from ipfs/new-version
new version
2 parents 4c0ccb3 + 54ffc8e commit 86ae2f5

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

random/random.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ func BlocksOfSize(n int, size int) []blocks.Block {
8686
// Bytes returns a byte array of the given size with random values.
8787
func Bytes(n int) []byte {
8888
data := make([]byte, n)
89-
rng := NewRand()
90-
rng.Read(data)
89+
NewRand().Read(data)
9190
return data
9291
}
9392

@@ -114,8 +113,7 @@ func Cids(n int) []cid.Cid {
114113

115114
// Identity returns a random unique peer ID, private key, and public key.
116115
func Identity() (peer.ID, crypto.PrivKey, crypto.PubKey) {
117-
rng := NewRand()
118-
privKey, pubKey, err := crypto.GenerateKeyPairWithReader(crypto.Ed25519, 256, rng)
116+
privKey, pubKey, err := crypto.GenerateKeyPairWithReader(crypto.Ed25519, 256, NewRand())
119117
if err != nil {
120118
panic(err)
121119
}

random/random_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,12 @@ func TestNewRand(t *testing.T) {
167167
}
168168
require.False(t, allEqual)
169169
}
170+
171+
func TestRead(t *testing.T) {
172+
buf1 := make([]byte, 16)
173+
buf2 := make([]byte, 16)
174+
175+
random.NewRand().Read(buf1)
176+
random.NewRand().Read(buf2)
177+
require.NotEqual(t, buf1, buf2)
178+
}

version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.0.3"
2+
"version": "v0.0.4"
33
}

0 commit comments

Comments
 (0)