Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
b31f7281
Commit
b31f7281
authored
Dec 23, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(testutil) add testutil.Peer shim
parent
c933d439
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
util/testutil/peer.go
util/testutil/peer.go
+57
-0
No files found.
util/testutil/peer.go
0 → 100644
View file @
b31f7281
package
testutil
import
(
"testing"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
ci
"github.com/jbenet/go-ipfs/crypto"
ipfspeer
"github.com/jbenet/go-ipfs/peer"
)
type
Peer
interface
{
Address
()
ma
.
Multiaddr
ID
()
ipfspeer
.
ID
PrivateKey
()
ci
.
PrivKey
PublicKey
()
ci
.
PubKey
}
func
RandPeer
(
t
*
testing
.
T
)
Peer
{
p
:=
RandPeerNetParams
(
t
)
var
err
error
p
.
Addr
=
RandLocalTCPAddress
()
p
.
PrivKey
,
p
.
PubKey
,
err
=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
512
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
p
.
ID
,
err
=
ipfspeer
.
IDFromPublicKey
(
p
.
PubKey
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
p
.
checkKeys
();
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
&
testpeer
{
p
}
}
// peer is a temporary shim to delay binding of PeerNetParams.
type
testpeer
struct
{
PeerNetParams
}
func
(
p
*
testpeer
)
ID
()
ipfspeer
.
ID
{
return
p
.
PeerNetParams
.
ID
}
func
(
p
*
testpeer
)
Address
()
ma
.
Multiaddr
{
return
p
.
Addr
}
func
(
p
*
testpeer
)
PrivateKey
()
ci
.
PrivKey
{
return
p
.
PrivKey
}
func
(
p
*
testpeer
)
PublicKey
()
ci
.
PubKey
{
return
p
.
PubKey
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment