From a846651528d99ac25809464d7230c051fa35a49a Mon Sep 17 00:00:00 2001 From: Michael Tsitrin Date: Sun, 10 Nov 2024 21:52:58 +0200 Subject: [PATCH 1/3] fix attempt --- rpc/json/ws_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpc/json/ws_test.go b/rpc/json/ws_test.go index 78a028cb8..543d63924 100644 --- a/rpc/json/ws_test.go +++ b/rpc/json/ws_test.go @@ -144,4 +144,6 @@ func TestWebsocketCloseUnsubscribe(t *testing.T) { assert.Eventually(func() bool { return subscribed_clients == local.EventBus.NumClients() }, 3*time.Second, 100*time.Millisecond) + + srv.Close() } From 8c27ce664fae7d679f81b2b802973ee1b48105a7 Mon Sep 17 00:00:00 2001 From: Michael Tsitrin Date: Mon, 11 Nov 2024 09:07:44 +0200 Subject: [PATCH 2/3] removed G115 from golangci.yaml --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 53f3833d1..53281cc09 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -52,6 +52,7 @@ issues: exclude-use-default: false exclude: - "^.*SA1019.*$" # Excluding SA1019 errors + - "^.*G115.*$" # Excluding G115 errors exclude-files: - da/celestia/mock/server.go - ./*_test.go # TODO: bring back From 36431a652df82a3f39e5e208a409541e7f510947 Mon Sep 17 00:00:00 2001 From: Michael Tsitrin Date: Mon, 11 Nov 2024 11:55:46 +0200 Subject: [PATCH 3/3] another attempt --- rpc/json/ws_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpc/json/ws_test.go b/rpc/json/ws_test.go index 543d63924..3a0acd7de 100644 --- a/rpc/json/ws_test.go +++ b/rpc/json/ws_test.go @@ -116,6 +116,7 @@ func TestWebsocketCloseUnsubscribe(t *testing.T) { srv := httptest.NewServer(handler) conn, resp, err := websocket.DefaultDialer.Dial(strings.Replace(srv.URL, "http://", "ws://", 1)+"/websocket", nil) + require.NoError(err) require.NotNil(resp) require.NotNil(conn) @@ -140,10 +141,15 @@ func TestWebsocketCloseUnsubscribe(t *testing.T) { // disconnect websocket err = conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Now().Add(time.Second)) assert.NoError(err) + + // Wait for close to complete + <-time.After(100 * time.Millisecond) + // Validate we have one less client assert.Eventually(func() bool { return subscribed_clients == local.EventBus.NumClients() }, 3*time.Second, 100*time.Millisecond) + conn.Close() srv.Close() }