diff --git a/internal/netxlite/dnsovertcp_test.go b/internal/netxlite/dnsovertcp_test.go index bdcd4e2..bc16202 100644 --- a/internal/netxlite/dnsovertcp_test.go +++ b/internal/netxlite/dnsovertcp_test.go @@ -208,6 +208,7 @@ func TestDNSOverTCP(t *testing.T) { if txp.Address() != address { t.Fatal("invalid Address") } + txp.CloseIdleConnections() }) t.Run("other functions okay with TLS", func(t *testing.T) { @@ -222,5 +223,6 @@ func TestDNSOverTCP(t *testing.T) { if txp.Address() != address { t.Fatal("invalid Address") } + txp.CloseIdleConnections() }) } diff --git a/internal/netxlite/http3_test.go b/internal/netxlite/http3_test.go index d4a1af0..f063e5d 100644 --- a/internal/netxlite/http3_test.go +++ b/internal/netxlite/http3_test.go @@ -59,6 +59,13 @@ func TestHTTP3Transport(t *testing.T) { } }) + t.Run("Network", func(t *testing.T) { + txp := &http3Transport{} + if txp.Network() != "quic" { + t.Fatal("unexpected .Network return value") + } + }) + t.Run("RoundTrip", func(t *testing.T) { expected := errors.New("mocked error") txp := &http3Transport{ diff --git a/internal/netxlite/http_test.go b/internal/netxlite/http_test.go index a64101d..e45cb01 100644 --- a/internal/netxlite/http_test.go +++ b/internal/netxlite/http_test.go @@ -439,7 +439,6 @@ func TestHTTPTLSDialerWithReadTimeout(t *testing.T) { } func TestNewHTTPTransportStdlib(t *testing.T) { - // What to test about this factory? txp := NewHTTPTransportStdlib(log.Log) ctx, cancel := context.WithCancel(context.Background()) cancel() // immediately! @@ -454,6 +453,9 @@ func TestNewHTTPTransportStdlib(t *testing.T) { if resp != nil { t.Fatal("unexpected resp") } + if txp.Network() != "tcp" { + t.Fatal("unexpected .Network return value") + } txp.CloseIdleConnections() } diff --git a/internal/netxlite/quirks.go b/internal/netxlite/quirks.go index ae0cb72..e705c32 100644 --- a/internal/netxlite/quirks.go +++ b/internal/netxlite/quirks.go @@ -9,6 +9,9 @@ import ( // the original netx implementation and that we cannot remove // or change without thinking about the consequences. +// See https://github.com/ooni/probe/issues/1985 +var errReduceErrorsEmptyList = errors.New("bug: reduceErrors given an empty list") + // quirkReduceErrors finds a known error in a list of errors since // it's probably most relevant. If this error is not found, just // return the first error according to this reasoning: @@ -31,7 +34,8 @@ import ( // See TODO(https://github.com/ooni/probe/issues/1779). func quirkReduceErrors(errorslist []error) error { if len(errorslist) == 0 { - return nil + // See https://github.com/ooni/probe/issues/1985 + return errReduceErrorsEmptyList } for _, err := range errorslist { var wrapper *ErrWrapper diff --git a/internal/netxlite/quirks_test.go b/internal/netxlite/quirks_test.go index 93db8b4..62bdf63 100644 --- a/internal/netxlite/quirks_test.go +++ b/internal/netxlite/quirks_test.go @@ -10,7 +10,7 @@ import ( func TestQuirkReduceErrors(t *testing.T) { t.Run("no errors", func(t *testing.T) { result := quirkReduceErrors(nil) - if result != nil { + if !errors.Is(result, errReduceErrorsEmptyList) { t.Fatal("wrong result") } })