p2p: use fake net.Pipe since only >=Go1.10 implements SetDeadline

Fixes https://github.com/tendermint/tendermint/issues/851

Go1.9 and below's net.Pipe did not implement the SetDeadline
method so after commit
e2dd8ca946
this problem was exposed since now we check for errors.

To counter this problem, implement a simple composition for
net.Conn that always returns nil on SetDeadline instead of
tripping out.

Added build tags so that anyone using go1.10 when it is released
will be able to automatically use net.Pipe's net.Conns
This commit is contained in:
Emmanuel Odeke
2017-11-14 21:49:08 -07:00
parent 49faa79bdc
commit 283544c7f3
4 changed files with 48 additions and 9 deletions

View File

@ -160,7 +160,7 @@ func TestConnAddrFilter(t *testing.T) {
defer s1.Stop()
defer s2.Stop()
c1, c2 := net.Pipe()
c1, c2 := netPipe()
s1.SetAddrFilter(func(addr net.Addr) error {
if addr.String() == c1.RemoteAddr().String() {
@ -194,7 +194,7 @@ func TestConnPubKeyFilter(t *testing.T) {
defer s1.Stop()
defer s2.Stop()
c1, c2 := net.Pipe()
c1, c2 := netPipe()
// set pubkey filter
s1.SetPubKeyFilter(func(pubkey crypto.PubKeyEd25519) error {