diff options
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/peer.go | 9 |
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() |