Skip to content

Commit 601c3f3

Browse files
committed
fix(derp/derphttp): correctly test http2 logic
1 parent 108bab9 commit 601c3f3

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

derp/derphttp/derphttp_test.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"net"
1212
"net/http"
1313
"net/http/httptest"
14-
"strings"
1514
"sync"
1615
"testing"
1716
"time"
@@ -212,7 +211,7 @@ func TestPing(t *testing.T) {
212211
}
213212
}
214213

215-
func TestHTTP2WebSocketFallback(t *testing.T) {
214+
func TestHTTP2OnlyServer(t *testing.T) {
216215
serverPrivateKey := key.NewNode()
217216
s := derp.NewServer(serverPrivateKey, t.Logf)
218217
defer s.Close()
@@ -257,23 +256,9 @@ func TestHTTP2WebSocketFallback(t *testing.T) {
257256
RootCAs: httpsrv.Client().Transport.(*http.Transport).TLSClientConfig.RootCAs,
258257
}
259258
defer c.Close()
260-
reasonCh := make(chan string, 1)
261-
c.SetForcedWebsocketCallback(func(region int, reason string) {
262-
select {
263-
case reasonCh <- reason:
264-
default:
265-
}
266-
})
259+
267260
err = c.Connect(context.Background())
268-
if err == nil {
269-
// Expect an error!
270-
t.Fatal("client didn't error on initial connect")
271-
}
272-
reason := <-reasonCh
273-
if !strings.Contains(reason, "DERP requires Upgrade which needs") {
274-
t.Fatalf("reason doesn't contain message: %s", reason)
275-
}
276-
if err := c.Connect(context.Background()); err != nil {
277-
t.Fatalf("client Connect: %v", err)
261+
if err != nil {
262+
t.Fatalf("client errored initial connect: %v", err)
278263
}
279264
}

0 commit comments

Comments
 (0)