mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
rpc: adjust cases when WS connection close error is returned
Do not return error in case of (*WSClient).Close() method was the initiator of connection closing.
This commit is contained in:
parent
4afdb9fd89
commit
8f53c7d78a
2 changed files with 27 additions and 15 deletions
|
@ -472,20 +472,24 @@ func TestWS_RequestAfterClose(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWSClient_ConnClosedError(t *testing.T) {
|
||||
srv := initTestServer(t, "")
|
||||
|
||||
t.Run("standard closing", func(t *testing.T) {
|
||||
srv := initTestServer(t, `{"jsonrpc": "2.0", "id": 1, "result": 123}`)
|
||||
c, err := NewWS(context.TODO(), httpURLtoWS(srv.URL), Options{})
|
||||
require.NoError(t, err)
|
||||
|
||||
c.Close()
|
||||
|
||||
// Check client is working.
|
||||
_, err = c.GetBlockCount()
|
||||
require.NoError(t, err)
|
||||
err = c.GetError()
|
||||
require.Error(t, err)
|
||||
require.True(t, strings.Contains(err.Error(), "use of closed network connection"))
|
||||
require.NoError(t, err)
|
||||
|
||||
c.Close()
|
||||
err = c.GetError()
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("malformed request", func(t *testing.T) {
|
||||
srv := initTestServer(t, "")
|
||||
c, err := NewWS(context.TODO(), httpURLtoWS(srv.URL), Options{})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue