mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 01:52:26 +08:00
add RandPeerOrFatal test helper
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
package testutil
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
||||||
ci "github.com/jbenet/go-ipfs/crypto"
|
ci "github.com/jbenet/go-ipfs/crypto"
|
||||||
peer "github.com/jbenet/go-ipfs/peer"
|
peer "github.com/jbenet/go-ipfs/peer"
|
||||||
@ -21,6 +23,14 @@ func RandPeer() (Peer, error) {
|
|||||||
return &testpeer{*p}, nil
|
return &testpeer{*p}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RandPeerOrFatal(t *testing.T) Peer {
|
||||||
|
p, err := RandPeerNetParams()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return &testpeer{*p}
|
||||||
|
}
|
||||||
|
|
||||||
// peer is a temporary shim to delay binding of PeerNetParams.
|
// peer is a temporary shim to delay binding of PeerNetParams.
|
||||||
type testpeer struct {
|
type testpeer struct {
|
||||||
PeerNetParams
|
PeerNetParams
|
||||||
|
Reference in New Issue
Block a user