Browse Source

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

callum/config
Callum Waters 4 years ago
committed by GitHub
parent
commit
08b134ddbc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions
  1. +6
    -0
      rpc/client/http/ws.go
  2. +8
    -0
      rpc/client/rpc_test.go

+ 6
- 0
rpc/client/http/ws.go 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),
}


+ 8
- 0
rpc/client/rpc_test.go 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


Loading…
Cancel
Save