fix(oohelperd): reduce errors to what the old TH would emit (#543)

Reducing the errors is not done in a perfect way.

We have documented the most striking differences inside
https://github.com/ooni/probe/issues/1707#issuecomment-942283746 and
some attempts to improve the situation further inside
https://github.com/ooni/probe/issues/1707#issuecomment-942341255.

A better strategy for the future would be to introduce more
specific timeout errors, such as dns_timeout_error, etc.

More testing may be needed to further validate and compare the
old and the new TH, but this requires Jafar improvements to
more precisely simulate more complex censorship.
This commit is contained in:
Simone Basso 2021-10-13 16:37:02 +02:00 committed by GitHub
commit 4b8cae692b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 315 additions and 8 deletions

View file

@ -0,0 +1,40 @@
package webconnectivity
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
func Test_tcpMapFailure(t *testing.T) {
tests := []struct {
name string
failure *string
want *string
}{{
name: "nil",
failure: nil,
want: nil,
}, {
name: "timeout",
failure: stringPointerForString(netxlite.FailureGenericTimeoutError),
want: stringPointerForString(netxlite.FailureGenericTimeoutError),
}, {
name: "connection refused",
failure: stringPointerForString(netxlite.FailureConnectionRefused),
want: stringPointerForString("connection_refused_error"),
}, {
name: "anything else",
failure: stringPointerForString(netxlite.FailureEOFError),
want: stringPointerForString("connect_error"),
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tcpMapFailure(tt.failure)
if diff := cmp.Diff(tt.want, got); diff != "" {
t.Fatal(diff)
}
})
}
}