diff options
author | Sonic <sonic@dexon.org> | 2018-11-12 09:18:03 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 13:49:56 +0800 |
commit | e25deb471bf4fef449996d4616b6919e2302f7a0 (patch) | |
tree | 25bfb5c441f6ef92898315871867f3d416554586 /p2p | |
parent | cde3dfa5a29db9eeea9803a0942a4eb97792f72a (diff) | |
download | dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.tar dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.tar.gz dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.tar.bz2 dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.tar.lz dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.tar.xz dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.tar.zst dexon-e25deb471bf4fef449996d4616b6919e2302f7a0.zip |
dex: porting test to enode (#9)
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() |