forked from btcsuite/btcwire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfakeconn_test.go
62 lines (51 loc) · 1.61 KB
/
fakeconn_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2013-2014 Conformal Systems LLC.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btcwire_test
import (
"net"
"time"
)
// fakeConn implements the net.Conn interface and is used to test functions
// which work with a net.Conn without having to actually make any real
// connections.
type fakeConn struct {
localAddr net.Addr
remoteAddr net.Addr
}
// Read doesn't do anything. It just satisfies the net.Conn interface.
func (c *fakeConn) Read(b []byte) (n int, err error) {
return 0, nil
}
// Write doesn't do anything. It just satisfies the net.Conn interface.
func (c *fakeConn) Write(b []byte) (n int, err error) {
return 0, nil
}
// Close doesn't do anything. It just satisfies the net.Conn interface.
func (c *fakeConn) Close() error {
return nil
}
// LocalAddr returns the localAddr field of the fake connection and satisfies
// the net.Conn interface.
func (c *fakeConn) LocalAddr() net.Addr {
return c.localAddr
}
// RemoteAddr returns the remoteAddr field of the fake connection and satisfies
// the net.Conn interface.
func (c *fakeConn) RemoteAddr() net.Addr {
return c.remoteAddr
}
// SetDeadline doesn't do anything. It just satisfies the net.Conn interface.
func (c *fakeConn) SetDeadline(t time.Time) error {
return nil
}
// SetReadDeadline doesn't do anything. It just satisfies the net.Conn
// interface.
func (c *fakeConn) SetReadDeadline(t time.Time) error {
return nil
}
// SetWriteDeadline doesn't do anything. It just satisfies the net.Conn
// interface.
func (c *fakeConn) SetWriteDeadline(t time.Time) error {
return nil
}