diff options
author | Sonic <sonic@dexon.org> | 2018-11-12 09:18:03 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:53 +0800 |
commit | 3f97380de3d19ddff60e13845fe94b8816c64427 (patch) | |
tree | 5ba609f73c33dfe91f65ce1867717de518eccdad /p2p/peer.go | |
parent | 832f0acdf908a18b266099c4bf5d77663e203628 (diff) | |
download | dexon-3f97380de3d19ddff60e13845fe94b8816c64427.tar dexon-3f97380de3d19ddff60e13845fe94b8816c64427.tar.gz dexon-3f97380de3d19ddff60e13845fe94b8816c64427.tar.bz2 dexon-3f97380de3d19ddff60e13845fe94b8816c64427.tar.lz dexon-3f97380de3d19ddff60e13845fe94b8816c64427.tar.xz dexon-3f97380de3d19ddff60e13845fe94b8816c64427.tar.zst dexon-3f97380de3d19ddff60e13845fe94b8816c64427.zip |
dex: porting test to enode (#9)
Diffstat (limited to 'p2p/peer.go')
-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() |