ws: parse remote addrs with trailing dash (#6537)

This commit is contained in:
Callum Waters
2021-06-04 17:07:50 +02:00
committed by GitHub
parent 39ddfc24f4
commit 08b134ddbc
2 changed files with 14 additions and 0 deletions

View File

@@ -63,6 +63,12 @@ func newWsEvents(remote string, wso WSOptions) (*wsEvents, error) {
return nil, fmt.Errorf("invalid WSOptions: %w", err)
}
// remove the trailing / from the remote else the websocket endpoint
// won't parse correctly
if remote[len(remote)-1] == '/' {
remote = remote[:len(remote)-1]
}
w := &wsEvents{
subscriptions: make(map[string]chan ctypes.ResultEvent),
}

View File

@@ -77,6 +77,14 @@ func TestNilCustomHTTPClient(t *testing.T) {
})
}
func TestParseInvalidAddress(t *testing.T) {
_, conf := NodeSuite(t)
// should remove trailing /
invalidRemote := conf.RPC.ListenAddress + "/"
_, err := rpchttp.New(invalidRemote)
require.NoError(t, err)
}
func TestCustomHTTPClient(t *testing.T) {
_, conf := NodeSuite(t)
remote := conf.RPC.ListenAddress