Skip to content

Commit

Permalink
rpcsrv: add close of http server in tests
Browse files Browse the repository at this point in the history
The HTTP server should be closed at the end of the test.

Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed Mar 5, 2024
1 parent a504738 commit 0797191
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/rpcclient/wsclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func TestWSClientEvents(t *testing.T) {
return
}
}))
t.Cleanup(srv.Close)
wsc, err := NewWS(context.TODO(), httpURLtoWS(srv.URL), WSOptions{})
require.NoError(t, err)
wsc.getNextRequestID = getTestRequestID
Expand Down Expand Up @@ -314,6 +315,7 @@ func TestWSClientNonBlockingEvents(t *testing.T) {
return
}
}))
t.Cleanup(srv.Close)
wsc, err := NewWS(context.TODO(), httpURLtoWS(srv.URL), WSOptions{CloseNotificationChannelIfFull: true})
require.NoError(t, err)
wsc.getNextRequestID = getTestRequestID
Expand Down Expand Up @@ -744,6 +746,7 @@ func TestWSFilteredSubscriptions(t *testing.T) {
ws.Close()
}
}))
t.Cleanup(srv.Close)
wsc, err := NewWS(context.TODO(), httpURLtoWS(srv.URL), WSOptions{})
require.NoError(t, err)
wsc.getNextRequestID = getTestRequestID
Expand Down
1 change: 1 addition & 0 deletions pkg/services/rpcsrv/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,7 @@ func TestClient_Iterator_SessionConfigVariations(t *testing.T) {
rpcSrv.Start()
handler := http.HandlerFunc(rpcSrv.handleHTTPRequest)
httpSrv := httptest.NewServer(handler)
t.Cleanup(httpSrv.Close)
defer rpcSrv.Shutdown()
for _, b := range getTestBlocks(t) {
require.NoError(t, chain.AddBlock(b))
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/rpcsrv/server_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func wrapUnitTestChain(t testing.TB, chain *core.Blockchain, orc OracleHandler,

handler := http.HandlerFunc(rpcServer.handleHTTPRequest)
srv := httptest.NewServer(handler)

t.Cleanup(srv.Close)
return chain, &rpcServer, srv
}

Expand Down

0 comments on commit 0797191

Please sign in to comment.