mirror of
https://github.com/libp2p/go-libp2p.git
synced 2026-04-22 16:17:19 +08:00
fix(mocknet): make stream deadline methods noop instead of returning error (#3471)
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -174,17 +173,12 @@ func (s *stream) Conn() network.Conn {
|
||||
return s.conn
|
||||
}
|
||||
|
||||
func (s *stream) SetDeadline(_ time.Time) error {
|
||||
return &net.OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
|
||||
}
|
||||
|
||||
func (s *stream) SetReadDeadline(_ time.Time) error {
|
||||
return &net.OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
|
||||
}
|
||||
|
||||
func (s *stream) SetWriteDeadline(_ time.Time) error {
|
||||
return &net.OpError{Op: "set", Net: "pipe", Source: nil, Addr: nil, Err: errors.New("deadline not supported")}
|
||||
}
|
||||
// SetDeadline is a noop for mocknet streams since the underlying pipe
|
||||
// transport does not support deadlines. Callers should not treat the
|
||||
// absence of deadline support as an error.
|
||||
func (s *stream) SetDeadline(_ time.Time) error { return nil }
|
||||
func (s *stream) SetReadDeadline(_ time.Time) error { return nil }
|
||||
func (s *stream) SetWriteDeadline(_ time.Time) error { return nil }
|
||||
|
||||
func (s *stream) Read(b []byte) (int, error) {
|
||||
return s.read.Read(b)
|
||||
|
||||
Reference in New Issue
Block a user