Let peerConn handle IPs in for tests

This commit is contained in:
Alexander Simmerl
2018-05-18 16:27:57 +02:00
parent b698a9febc
commit d596ed1bc2
3 changed files with 92 additions and 110 deletions

View File

@@ -12,6 +12,8 @@ import (
tmconn "github.com/tendermint/tendermint/p2p/conn"
)
var testIPSuffix = 0
// Peer is an interface representing a peer connected on a reactor.
type Peer interface {
cmn.Service
@@ -53,6 +55,16 @@ func (pc peerConn) RemoteIP() net.IP {
return pc.ips[0]
}
if pc.conn.RemoteAddr().String() == "pipe" {
pc.ips = []net.IP{
net.IP{172, 16, 0, byte(testIPSuffix)},
}
testIPSuffix++
return pc.ips[0]
}
host, _, err := net.SplitHostPort(pc.conn.RemoteAddr().String())
if err != nil {
panic(err)