github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/wire/fakeconn_test.go (about) 1 // Copyright (c) 2013-2015 The btcsuite developers 2 // Copyright (c) 2016 The Dash developers 3 // Use of this source code is governed by an ISC 4 // license that can be found in the LICENSE file. 5 6 package wire_test 7 8 import ( 9 "net" 10 "time" 11 ) 12 13 // fakeConn implements the net.Conn interface and is used to test functions 14 // which work with a net.Conn without having to actually make any real 15 // connections. 16 type fakeConn struct { 17 localAddr net.Addr 18 remoteAddr net.Addr 19 } 20 21 // Read doesn't do anything. It just satisfies the net.Conn interface. 22 func (c *fakeConn) Read(b []byte) (n int, err error) { 23 return 0, nil 24 } 25 26 // Write doesn't do anything. It just satisfies the net.Conn interface. 27 func (c *fakeConn) Write(b []byte) (n int, err error) { 28 return 0, nil 29 } 30 31 // Close doesn't do anything. It just satisfies the net.Conn interface. 32 func (c *fakeConn) Close() error { 33 return nil 34 } 35 36 // LocalAddr returns the localAddr field of the fake connection and satisfies 37 // the net.Conn interface. 38 func (c *fakeConn) LocalAddr() net.Addr { 39 return c.localAddr 40 } 41 42 // RemoteAddr returns the remoteAddr field of the fake connection and satisfies 43 // the net.Conn interface. 44 func (c *fakeConn) RemoteAddr() net.Addr { 45 return c.remoteAddr 46 } 47 48 // SetDeadline doesn't do anything. It just satisfies the net.Conn interface. 49 func (c *fakeConn) SetDeadline(t time.Time) error { 50 return nil 51 } 52 53 // SetReadDeadline doesn't do anything. It just satisfies the net.Conn 54 // interface. 55 func (c *fakeConn) SetReadDeadline(t time.Time) error { 56 return nil 57 } 58 59 // SetWriteDeadline doesn't do anything. It just satisfies the net.Conn 60 // interface. 61 func (c *fakeConn) SetWriteDeadline(t time.Time) error { 62 return nil 63 }