Skip to content

Commit

Permalink
chore: another test
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed May 16, 2024
1 parent 7fbf8ca commit 06c4405
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"errors"
"io"
"math/big"
"net"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -251,23 +250,12 @@ func newTestServer(t *testing.T, o testServerOptions) (*http.Client, *websocket.
var (
httpClient = &http.Client{
Transport: web.RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
requestURL := r.URL.String()
if r.URL.Scheme != "http" {
requestURL = ts.URL + r.URL.String()
}
u, err := url.Parse(requestURL)
u, err := url.Parse(ts.URL + r.URL.String())
if err != nil {
return nil, err
}
r.URL = u

transport := ts.Client().Transport.(*http.Transport)
transport = transport.Clone()
// always dial to the server address, regardless of the url host and port
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return net.Dial(network, ts.Listener.Addr().String())
}
return transport.RoundTrip(r)
return ts.Client().Transport.RoundTrip(r)
}),
}
conn *websocket.Conn
Expand Down

0 comments on commit 06c4405

Please sign in to comment.