cli: upgrade to lucas-clemente/quic-go 0.23.0 (#449)
See https://github.com/ooni/probe/issues/1754 for a comprehensive description.
This commit is contained in:
parent
a9014e7950
commit
8f18813e17
12 changed files with 192 additions and 130 deletions
|
|
@ -10,12 +10,13 @@ import (
|
|||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxmocks"
|
||||
"github.com/ooni/probe-cli/v3/internal/quicx"
|
||||
)
|
||||
|
||||
func TestErrorWrapperQUICListenerSuccess(t *testing.T) {
|
||||
ql := &ErrorWrapperQUICListener{
|
||||
QUICListener: &netxmocks.QUICListener{
|
||||
MockListen: func(addr *net.UDPAddr) (quic.OOBCapablePacketConn, error) {
|
||||
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
|
||||
return &net.UDPConn{}, nil
|
||||
},
|
||||
},
|
||||
|
|
@ -30,7 +31,7 @@ func TestErrorWrapperQUICListenerSuccess(t *testing.T) {
|
|||
func TestErrorWrapperQUICListenerFailure(t *testing.T) {
|
||||
ql := &ErrorWrapperQUICListener{
|
||||
QUICListener: &netxmocks.QUICListener{
|
||||
MockListen: func(addr *net.UDPAddr) (quic.OOBCapablePacketConn, error) {
|
||||
MockListen: func(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
|
||||
return nil, io.EOF
|
||||
},
|
||||
},
|
||||
|
|
@ -46,7 +47,7 @@ func TestErrorWrapperQUICListenerFailure(t *testing.T) {
|
|||
|
||||
func TestErrorWrapperUDPConnWriteToSuccess(t *testing.T) {
|
||||
quc := &errorWrapperUDPConn{
|
||||
OOBCapablePacketConn: &netxmocks.QUICUDPConn{
|
||||
UDPLikeConn: &netxmocks.QUICUDPConn{
|
||||
MockWriteTo: func(p []byte, addr net.Addr) (int, error) {
|
||||
return 10, nil
|
||||
},
|
||||
|
|
@ -66,7 +67,7 @@ func TestErrorWrapperUDPConnWriteToSuccess(t *testing.T) {
|
|||
func TestErrorWrapperUDPConnWriteToFailure(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
quc := &errorWrapperUDPConn{
|
||||
OOBCapablePacketConn: &netxmocks.QUICUDPConn{
|
||||
UDPLikeConn: &netxmocks.QUICUDPConn{
|
||||
MockWriteTo: func(p []byte, addr net.Addr) (int, error) {
|
||||
return 0, expected
|
||||
},
|
||||
|
|
@ -83,58 +84,44 @@ func TestErrorWrapperUDPConnWriteToFailure(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestErrorWrapperUDPConnReadMsgUDPSuccess(t *testing.T) {
|
||||
func TestErrorWrapperUDPConnReadFromSuccess(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
quc := &errorWrapperUDPConn{
|
||||
OOBCapablePacketConn: &netxmocks.QUICUDPConn{
|
||||
MockReadMsgUDP: func(b, oob []byte) (int, int, int, *net.UDPAddr, error) {
|
||||
return 0, 0, 0, nil, expected
|
||||
UDPLikeConn: &netxmocks.QUICUDPConn{
|
||||
MockReadFrom: func(b []byte) (int, net.Addr, error) {
|
||||
return 0, nil, expected
|
||||
},
|
||||
},
|
||||
}
|
||||
b := make([]byte, 128)
|
||||
oob := make([]byte, 128)
|
||||
n, oobn, flags, addr, err := quc.ReadMsgUDP(b, oob)
|
||||
n, addr, err := quc.ReadFrom(b)
|
||||
if !errors.Is(err, expected) {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
if n != 0 {
|
||||
t.Fatal("expected 0 here")
|
||||
}
|
||||
if oobn != 0 {
|
||||
t.Fatal("expected 0 here")
|
||||
}
|
||||
if flags != 0 {
|
||||
t.Fatal("expected 0 here")
|
||||
}
|
||||
if addr != nil {
|
||||
t.Fatal("expected nil here")
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorWrapperUDPConnReadMsgUDPFailure(t *testing.T) {
|
||||
func TestErrorWrapperUDPConnReadFromFailure(t *testing.T) {
|
||||
quc := &errorWrapperUDPConn{
|
||||
OOBCapablePacketConn: &netxmocks.QUICUDPConn{
|
||||
MockReadMsgUDP: func(b, oob []byte) (int, int, int, *net.UDPAddr, error) {
|
||||
return 10, 1, 0, nil, nil
|
||||
UDPLikeConn: &netxmocks.QUICUDPConn{
|
||||
MockReadFrom: func(b []byte) (int, net.Addr, error) {
|
||||
return 10, nil, nil
|
||||
},
|
||||
},
|
||||
}
|
||||
b := make([]byte, 128)
|
||||
oob := make([]byte, 128)
|
||||
n, oobn, flags, addr, err := quc.ReadMsgUDP(b, oob)
|
||||
n, addr, err := quc.ReadFrom(b)
|
||||
if err != nil {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
if n != 10 {
|
||||
t.Fatal("expected 10 here")
|
||||
}
|
||||
if oobn != 1 {
|
||||
t.Fatal("expected 1 here")
|
||||
}
|
||||
if flags != 0 {
|
||||
t.Fatal("expected 0 here")
|
||||
}
|
||||
if addr != nil {
|
||||
t.Fatal("expected nil here")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue