mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-02-05 06:10:09 +08:00
Resolve circular dependency by porting testutil functions over
This commit is contained in:
parent
0cf66c98e5
commit
ad26c6b105
@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
peer "github.com/ipfs/go-libp2p-peer"
|
||||
testutil "github.com/ipfs/go-libp2p/testutil"
|
||||
testutil "github.com/ipfs/go-libp2p-peer/test"
|
||||
)
|
||||
|
||||
func TestLatencyEWMAFun(t *testing.T) {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
u "github.com/ipfs/go-ipfs-util"
|
||||
ic "github.com/ipfs/go-libp2p-crypto"
|
||||
. "github.com/ipfs/go-libp2p-peer"
|
||||
tu "github.com/ipfs/go-libp2p/testutil"
|
||||
tu "github.com/ipfs/go-libp2p-peer/test"
|
||||
|
||||
b58 "github.com/jbenet/go-base58"
|
||||
)
|
||||
|
26
test/utils.go
Normal file
26
test/utils.go
Normal file
@ -0,0 +1,26 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
u "github.com/ipfs/go-ipfs-util"
|
||||
ci "github.com/ipfs/go-libp2p-crypto"
|
||||
peer "github.com/ipfs/go-libp2p-peer"
|
||||
)
|
||||
|
||||
func RandPeerID() (peer.ID, error) {
|
||||
buf := make([]byte, 16)
|
||||
if _, err := io.ReadFull(u.NewTimeSeededRand(), buf); err != nil {
|
||||
return "", err
|
||||
}
|
||||
h := u.Hash(buf)
|
||||
return peer.ID(h), nil
|
||||
}
|
||||
|
||||
func RandTestKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) {
|
||||
return ci.GenerateKeyPairWithReader(ci.RSA, bits, u.NewTimeSeededRand())
|
||||
}
|
||||
|
||||
func SeededTestKeyPair(seed int64) (ci.PrivKey, ci.PubKey, error) {
|
||||
return ci.GenerateKeyPairWithReader(ci.RSA, 512, u.NewSeededRand(seed))
|
||||
}
|
Loading…
Reference in New Issue
Block a user