refactor: cleaner way of passing a UDPConn around (#421)
* refactor: cleaner way of passing a UDPConn around Also part of https://github.com/ooni/probe/issues/1505 * Update internal/engine/netx/quicdialer/connectionstate.go
This commit is contained in:
parent
ec350cba1a
commit
250a595f89
9 changed files with 33 additions and 27 deletions
|
|
@ -6,15 +6,16 @@ import (
|
|||
"net"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/quicx"
|
||||
)
|
||||
|
||||
// QUICListener is a mockable netxlite.QUICListener.
|
||||
type QUICListener struct {
|
||||
MockListen func(addr *net.UDPAddr) (net.PacketConn, error)
|
||||
MockListen func(addr *net.UDPAddr) (quicx.UDPConn, error)
|
||||
}
|
||||
|
||||
// Listen calls MockListen.
|
||||
func (ql *QUICListener) Listen(addr *net.UDPAddr) (net.PacketConn, error) {
|
||||
func (ql *QUICListener) Listen(addr *net.UDPAddr) (quicx.UDPConn, error) {
|
||||
return ql.MockListen(addr)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/quicx"
|
||||
)
|
||||
|
||||
func TestQUICListenerListen(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
ql := &QUICListener{
|
||||
MockListen: func(addr *net.UDPAddr) (net.PacketConn, error) {
|
||||
MockListen: func(addr *net.UDPAddr) (quicx.UDPConn, error) {
|
||||
return nil, expected
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue