Skip to content

Commit

Permalink
Tests: Fix panic on websocket not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Feb 12, 2024
1 parent 9b16fcb commit 924edb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions exchanges/kraken/kraken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,8 @@ func TestWsSubscribe(t *testing.T) {

// TestWsOrderbookSub tests orderbook subscriptions for MaxDepth params
func TestWsOrderbookSub(t *testing.T) {
t.Parallel()

testexch.SetupWs(t, k)

err := k.Subscribe([]subscription.Subscription{{
Expand Down
8 changes: 5 additions & 3 deletions internal/testing/exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ func SetupWs(tb testing.TB, e exchange.IBotExchange) {
}

b := e.GetBase()
if !b.Websocket.IsEnabled() {
w, err := b.GetWebsocket()
if err != nil || !b.Websocket.IsEnabled() {
tb.Skip("Websocket not enabled")
}
if b.Websocket.IsConnected() {
if w.IsConnected() {
return
}
err := b.Websocket.Connect()

err = w.Connect()
require.NoError(tb, err, "WsConnect should not error")

setupWsOnce[e] = true
Expand Down

0 comments on commit 924edb3

Please sign in to comment.