diff --git a/.gx/lastpubver b/.gx/lastpubver index f237954..90e2a21 100644 --- a/.gx/lastpubver +++ b/.gx/lastpubver @@ -1 +1 @@ -2.2.3: QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS +2.2.4: QmQnuSxgSFubscHgkgSeayLxKmVcmNhFUaZw4gHtV3tJ15 diff --git a/package.json b/package.json index 61033aa..78ed18e 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "license": "MIT", "name": "go-libp2p-peer", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", - "version": "2.2.3" + "version": "2.2.4" } diff --git a/test/utils.go b/test/utils.go index 40ea70d..fd23d1d 100644 --- a/test/utils.go +++ b/test/utils.go @@ -3,6 +3,7 @@ package testutil import ( "io" "math/rand" + "sync/atomic" "time" ci "github.com/libp2p/go-libp2p-crypto" @@ -10,6 +11,8 @@ import ( mh "github.com/multiformats/go-multihash" ) +var generatedPairs int64 = 0 + func RandPeerID() (peer.ID, error) { r := rand.New(rand.NewSource(time.Now().UnixNano())) buf := make([]byte, 16) @@ -21,7 +24,12 @@ func RandPeerID() (peer.ID, error) { } func RandTestKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) { - r := rand.New(rand.NewSource(time.Now().UnixNano())) + seed := time.Now().UnixNano() + + // workaround for low time resolution + seed += atomic.AddInt64(&generatedPairs, 1) << 32 + + r := rand.New(rand.NewSource(seed)) return ci.GenerateKeyPairWithReader(ci.RSA, bits, r) }