diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index c0b7319182c..14cad60fd3f 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -1321,7 +1321,7 @@ func TestWebsocketSubscribe(t *testing.T) { err = k.Unsubscribe([]stream.ChannelSubscription{{Channel: krakenWsTicker, Currency: currency.NewPairWithDelimiter("DWARF", "WIZARD", "/"), Key: 1337}}) assert.ErrorIs(t, err, stream.ErrUnsubscribeFailure, "Simple failing Unsubscribe should error") assert.ErrorContains(t, err, "Currency pair not supported DWARF/WIZARD", "Simple failing Unsubscribe should error") - assert.Len(t, k.Websocket.GetSubscriptions(), 3, "Should not have have removed any channels") + assert.Len(t, k.Websocket.GetSubscriptions(), 3, "Should not have removed any channels") err = k.Unsubscribe([]stream.ChannelSubscription{ subs[1], @@ -1527,7 +1527,16 @@ func TestWsTicker(t *testing.T) { func TestWsOHLC(t *testing.T) { t.Parallel() - k.Websocket.AddSuccessfulSubscriptions(stream.ChannelSubscription{stream.DefaultChannelKey{krakenWsOHLC + "-5", btcusdPair, asset.Spot}, krakenWsOHLC, btcusdPair, asset.Spot, nil}) + k.Websocket.AddSuccessfulSubscriptions(stream.ChannelSubscription{ + Key: stream.DefaultChannelKey{ + Channel: krakenWsOHLC + "-5", + Currency: btcusdPair, + Asset: asset.Spot, + }, + Channel: krakenWsOHLC, + Currency: btcusdPair, + Asset: asset.Spot, + }) pressXToJSON := []byte(`[2,["1542057314.748456","1542057360.435743","3586.70000","3586.70000","3586.60000","3586.60000","3586.68894","0.03373000",2],"ohlc-5","XBT/USD"]`) err := k.wsHandleData(pressXToJSON) assert.NoError(t, err, "handle WS Candles should not error") @@ -1552,7 +1561,11 @@ func TestWsSpread(t *testing.T) { func TestWsOrdrbook(t *testing.T) { t.Parallel() k.Websocket.AddSuccessfulSubscriptions(stream.ChannelSubscription{ - Key: stream.DefaultChannelKey{krakenWsOrderbook + "-100", btcusdPair, asset.Spot}, + Key: stream.DefaultChannelKey{ + Channel: krakenWsOrderbook + "-100", + Currency: btcusdPair, + Asset: asset.Spot, + }, Channel: krakenWsOrderbook, Currency: btcusdPair, Asset: asset.Spot, @@ -2036,7 +2049,11 @@ func TestWsOrderbookMax10Depth(t *testing.T) { p, err := currency.NewPairFromString(c) assert.NoErrorf(t, err, "NewPairFromString %s should not error", c) k.Websocket.AddSuccessfulSubscriptions(stream.ChannelSubscription{ - Key: stream.DefaultChannelKey{krakenWsOrderbook + "-10", p, asset.Spot}, + Key: stream.DefaultChannelKey{ + Channel: krakenWsOrderbook + "-10", + Currency: p, + Asset: asset.Spot, + }, Channel: krakenWsOrderbook, Currency: p, Asset: asset.Spot, diff --git a/exchanges/kraken/kraken_types.go b/exchanges/kraken/kraken_types.go index 9da0cdf847b..838a67461cb 100644 --- a/exchanges/kraken/kraken_types.go +++ b/exchanges/kraken/kraken_types.go @@ -502,7 +502,7 @@ type WithdrawStatusResponse struct { Status string `json:"status"` } -// WebsocketSubscribeReq +// WebsocketSubscribeRequest contains request data for Subscribing to channels type WebsocketSubscribeRequest struct { Event string `json:"event"` // "subscribe" RequestID int64 `json:"reqid,omitempty"` @@ -510,7 +510,7 @@ type WebsocketSubscribeRequest struct { Subscription WebsocketSubscriptionData `json:"subscription,omitempty"` } -// WebsocketUnsubscribeRequest handles WS unsubscribe events +// WebsocketUnsubscribeRequest contains request data for Unsubscribing from channels type WebsocketUnsubscribeRequest struct { Event string `json:"event"` // "unsubscribe" RequestID int64 `json:"reqid,omitempty"` diff --git a/exchanges/kraken/kraken_websocket.go b/exchanges/kraken/kraken_websocket.go index 7abdc5dba63..aad059d6d3b 100644 --- a/exchanges/kraken/kraken_websocket.go +++ b/exchanges/kraken/kraken_websocket.go @@ -217,9 +217,9 @@ func (k *Kraken) wsHandleData(respRaw []byte) error { } } - c := k.Websocket.GetSubscription(stream.DefaultChannelKey{channelName, wsPair, asset.Spot}) + c := k.Websocket.GetSubscription(stream.DefaultChannelKey{Channel: channelName, Currency: wsPair, Asset: asset.Spot}) if c == nil { - return fmt.Errorf("Could not find subscription channel: %s %s %s", asset.Spot, channelName, wsPair) + return fmt.Errorf("could not find subscription channel: %s %s %s", asset.Spot, channelName, wsPair) } if err := k.wsReadDataResponse(c, dataResponse); err != nil { @@ -1257,11 +1257,11 @@ func (k *Kraken) unsubscribeFromChan(c *stream.ChannelSubscription) error { } if c.Channel == krakenWsOrderbook { - if depth, err := depthFromChan(c); err != nil { + depth, err := depthFromChan(c) + if err != nil { return fmt.Errorf("%w Channel: %s Pair: %s Error: %w", stream.ErrSubscriptionFailure, c.Channel, c.Currency, err) - } else { - r.Subscription.Depth = depth } + r.Subscription.Depth = depth } if common.StringDataContains(authenticatedChannels, c.Channel) {