mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-07 06:07:36 +03:00
use a mock connection in the send queue tests
This commit is contained in:
parent
adfc015a9f
commit
13b2c7403d
2 changed files with 13 additions and 38 deletions
|
@ -27,38 +27,6 @@ import (
|
|||
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||
)
|
||||
|
||||
type mockConnection struct {
|
||||
remoteAddr net.Addr
|
||||
localAddr net.Addr
|
||||
written chan []byte
|
||||
}
|
||||
|
||||
func newMockConnection() *mockConnection {
|
||||
return &mockConnection{
|
||||
remoteAddr: &net.UDPAddr{},
|
||||
written: make(chan []byte, 100),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mockConnection) Write(p []byte) error {
|
||||
b := make([]byte, len(p))
|
||||
copy(b, p)
|
||||
select {
|
||||
case m.written <- b:
|
||||
default:
|
||||
panic("mockConnection channel full")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *mockConnection) Read([]byte) (int, net.Addr, error) { panic("not implemented") }
|
||||
|
||||
func (m *mockConnection) SetCurrentRemoteAddr(addr net.Addr) {
|
||||
m.remoteAddr = addr
|
||||
}
|
||||
func (m *mockConnection) LocalAddr() net.Addr { return m.localAddr }
|
||||
func (m *mockConnection) RemoteAddr() net.Addr { return m.remoteAddr }
|
||||
func (*mockConnection) Close() error { panic("not implemented") }
|
||||
|
||||
func areSessionsRunning() bool {
|
||||
var b bytes.Buffer
|
||||
pprof.Lookup("goroutine").WriteTo(&b, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue