8ad17775fa
We already configure a timeout in the underlying dialer, hence there's no point in keeping the TimeoutDialer around. Part of https://github.com/ooni/probe/issues/1507
29 lines
661 B
Go
29 lines
661 B
Go
package dialer
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/ooni/psiphon/oopsi/golang.org/x/net/context"
|
|
)
|
|
|
|
func TestSystemDialerWorks(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
cancel() // fail immediately
|
|
conn, err := Default.DialContext(ctx, "tcp", "8.8.8.8:853")
|
|
if err == nil || !strings.HasSuffix(err.Error(), "operation was canceled") {
|
|
t.Fatal("not the error we expected", err)
|
|
}
|
|
if conn != nil {
|
|
t.Fatal("expected nil conn here")
|
|
}
|
|
}
|
|
|
|
func TestUnderlyingDialerHasTimeout(t *testing.T) {
|
|
expected := 15 * time.Second
|
|
if underlyingDialer.Timeout != expected {
|
|
t.Fatal("unexpected timeout value")
|
|
}
|
|
}
|