Skip to content

Commit

Permalink
fixup! Kraken: Subscription templating
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Aug 14, 2024
1 parent 5ca23bc commit 8a2360d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions exchanges/kraken/kraken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,8 @@ func TestWsSubscribe(t *testing.T) {
currency.NewPairWithDelimiter("ETH", "USD", "/"),
currency.NewPairWithDelimiter("LTC", "ETH", "/"),
currency.NewPairWithDelimiter("ETH", "XBT", "/"),
currency.NewPairWithDelimiter("DWARF", "HOBBIT", "/"),
currency.NewPairWithDelimiter("DWARF", "GOBLIN", "/"),
}, asset.Spot, enabled), "SetPairs must not error")
}

Expand All @@ -954,8 +956,7 @@ func TestWsSubscribe(t *testing.T) {
assert.Equal(t, subscription.SubscribedState, subs[0].State(), "Existing subscription state should not change")

err = k.Subscribe(subscription.List{{Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPairWithDelimiter("DWARF", "HOBBIT", "/")}}})
assert.ErrorIs(t, err, currency.ErrPairNotContainedInAvailablePairs, "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "DWARF/HOBBIT", "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "Currency pair not supported; Channel: ticker Pairs: DWARF/HOBBIT", "Subscribing to an invalid pair should error correctly")
require.Len(t, k.Websocket.GetSubscriptions(), 1, "Should not add a subscription on error")

// Mix success and failure
Expand All @@ -964,19 +965,15 @@ func TestWsSubscribe(t *testing.T) {
{Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPairWithDelimiter("DWARF", "HOBBIT", "/")}},
{Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPairWithDelimiter("DWARF", "ELF", "/")}},
})
assert.ErrorIs(t, err, currency.ErrPairNotContainedInAvailablePairs, "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "DWARF/ELF", "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "DWARF/HOBBIT", "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "Currency pair not supported; Channel: ticker Pairs: DWARF/HOBBIT,DWARF/ELF", "Subscribing to an invalid pair should error correctly")
require.Len(t, k.Websocket.GetSubscriptions(), 2, "Should have 2 subscriptions after mixed success/failures")

// Just failures
err = k.Subscribe(subscription.List{
{Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPairWithDelimiter("DWARF", "HOBBIT", "/")}},
{Asset: asset.Spot, Channel: subscription.TickerChannel, Pairs: currency.Pairs{currency.NewPairWithDelimiter("DWARF", "GOBLIN", "/")}},
})
assert.ErrorIs(t, err, currency.ErrPairNotContainedInAvailablePairs, "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "DWARF/GOBLIN", "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "DWARF/HOBBIT", "Subscribing to an invalid pair should error correctly")
assert.ErrorContains(t, err, "Currency pair not supported; Channel: ticker Pairs: DWARF/HOBBIT,DWARF/GOBLIN", "Subscribing to an invalid pair should error correctly")
require.Len(t, k.Websocket.GetSubscriptions(), 2, "Should have 2 subscriptions after mixed success/failures")

// Just success
Expand Down

0 comments on commit 8a2360d

Please sign in to comment.