aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2018-11-12 09:18:03 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitaa0a3d80802bd137a661a8562f796d6f4763eac4 (patch)
treee89a5b38bff8fc45ced7bec828ab6a8c7535374b /p2p
parent665b5c0c80b48e31a6da1f0afc36fc95c4580295 (diff)
downloaddexon-aa0a3d80802bd137a661a8562f796d6f4763eac4.tar.gz
dexon-aa0a3d80802bd137a661a8562f796d6f4763eac4.tar.zst
dexon-aa0a3d80802bd137a661a8562f796d6f4763eac4.zip
dex: porting test to enode (#9)
Diffstat (limited to 'p2p')
-rw-r--r--p2p/peer.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/p2p/peer.go b/p2p/peer.go
index 2c357fdc9..3d6ce9dcd 100644
--- a/p2p/peer.go
+++ b/p2p/peer.go
@@ -125,6 +125,15 @@ func NewPeer(id enode.ID, name string, caps []Cap) *Peer {
return peer
}
+// NewPeer returns peer with given enode.Node for testing purposes.
+func NewPeerWithEnode(node *enode.Node, name string, caps []Cap) *Peer {
+ pipe, _ := net.Pipe()
+ conn := &conn{fd: pipe, transport: nil, node: node, caps: caps, name: name}
+ peer := newPeer(conn, nil)
+ close(peer.closed) // ensures Disconnect doesn't block
+ return peer
+}
+
// ID returns the node's public key.
func (p *Peer) ID() enode.ID {
return p.rw.node.ID()