diff --git a/package.json b/package.json index 0b33e18..398cd5c 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,6 @@ "dvcsimport": "github.com/libp2p/go-libp2p-peerstore" }, "gxDependencies": [ - { - "author": "whyrusleeping", - "hash": "QmWbjfz3u6HkAdPh34dgPchGbQjob6LXLhAeCGii2TX69n", - "name": "go-ipfs-util", - "version": "1.2.4" - }, { "author": "whyrusleeping", "hash": "QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52", diff --git a/queue/queue_test.go b/queue/queue_test.go index cd3c80d..e30794b 100644 --- a/queue/queue_test.go +++ b/queue/queue_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - u "github.com/ipfs/go-ipfs-util" peer "github.com/libp2p/go-libp2p-peer" + mh "github.com/multiformats/go-multihash" ) func TestQueue(t *testing.T) { @@ -64,7 +64,7 @@ func TestQueue(t *testing.T) { func newPeerTime(t time.Time) peer.ID { s := fmt.Sprintf("hmmm time: %v", t) - h := u.Hash([]byte(s)) + h, _ := mh.Sum([]byte(s), mh.SHA2_256, -1) return peer.ID(h) } diff --git a/test/utils.go b/test/utils.go index 6c4f0be..fc141b0 100644 --- a/test/utils.go +++ b/test/utils.go @@ -2,25 +2,35 @@ package testutil import ( "io" + "math/rand" + "time" - u "github.com/ipfs/go-ipfs-util" ci "github.com/libp2p/go-libp2p-crypto" peer "github.com/libp2p/go-libp2p-peer" + mh "github.com/multiformats/go-multihash" ) +func timeSeededRand() io.Reader { + return rand.New(rand.NewSource(time.Now().UnixNano())) +} + func RandPeerID() (peer.ID, error) { buf := make([]byte, 16) - if _, err := io.ReadFull(u.NewTimeSeededRand(), buf); err != nil { + if _, err := io.ReadFull(timeSeededRand(), buf); err != nil { return "", err } - h := u.Hash(buf) + h, err := mh.Sum(buf, mh.SHA2_256, -1) + if err != nil { + return "", err + } + return peer.ID(h), nil } func RandTestKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) { - return ci.GenerateKeyPairWithReader(ci.RSA, bits, u.NewTimeSeededRand()) + return ci.GenerateKeyPairWithReader(ci.RSA, bits, timeSeededRand()) } func SeededTestKeyPair(seed int64) (ci.PrivKey, ci.PubKey, error) { - return ci.GenerateKeyPairWithReader(ci.RSA, 512, u.NewSeededRand(seed)) + return ci.GenerateKeyPairWithReader(ci.RSA, 512, rand.New(rand.NewSource(seed))) }