From 19b42c80aa9904741362f947fa773fe6e2b2fd8f Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Thu, 10 Apr 2025 08:45:04 +0200 Subject: [PATCH] Kucoin: Fix failing TestSubscribeBatchLimit (#1884) This test ensures we have eyes on what the subscription limit per session is. They've increased it from 300 to 400. I think when I first did this, the code actually needed to know, but it's still useful to ensure we know exactly where it sits. --- exchanges/kucoin/kucoin_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/exchanges/kucoin/kucoin_test.go b/exchanges/kucoin/kucoin_test.go index 073bdd41..03bbdadc 100644 --- a/exchanges/kucoin/kucoin_test.go +++ b/exchanges/kucoin/kucoin_test.go @@ -3020,11 +3020,13 @@ func TestSubscribeBatches(t *testing.T) { // TestSubscribeTickerAll ensures that ticker subscriptions switch to using all and it works -// TestSubscribeBatchLimit exercises the kucoin batch limits of 300 per connection -// Ensures batching of 100 pairs and the connection symbol limit is still 300 at Kucoin's end +// TestSubscribeBatchLimit exercises the kucoin batch limits of 400 per connection +// Ensures batching of 100 pairs and the connection symbol limit is still 400 at Kucoin's end func TestSubscribeBatchLimit(t *testing.T) { t.Parallel() + const expectedLimit = 400 + ku := testInstance(t) //nolint:govet // Intentional shadow to avoid future copy/paste mistakes ku.Features.Subscriptions = subscription.List{} testexch.SetupWs(t, ku) @@ -3032,13 +3034,13 @@ func TestSubscribeBatchLimit(t *testing.T) { avail, err := ku.GetAvailablePairs(asset.Spot) require.NoError(t, err, "GetAvailablePairs must not error") - err = ku.CurrencyPairs.StorePairs(asset.Spot, avail[:299], true) + err = ku.CurrencyPairs.StorePairs(asset.Spot, avail[:expectedLimit], true) require.NoError(t, err, "StorePairs must not error") ku.Features.Subscriptions = subscription.List{{Asset: asset.Spot, Channel: subscription.AllTradesChannel}} subs, err := ku.generateSubscriptions() require.NoError(t, err, "generateSubscriptions must not error") - require.Len(t, subs, 3, "Must get 3 subs") + require.Len(t, subs, 4, "Must get 4 subs") err = ku.Subscribe(subs) require.NoError(t, err, "Subscribe must not error") @@ -3046,16 +3048,17 @@ func TestSubscribeBatchLimit(t *testing.T) { err = ku.Unsubscribe(subs) require.NoError(t, err, "Unsubscribe must not error") - err = ku.CurrencyPairs.StorePairs(asset.Spot, avail[:320], true) + err = ku.CurrencyPairs.StorePairs(asset.Spot, avail[:expectedLimit+20], true) require.NoError(t, err, "StorePairs must not error") ku.Features.Subscriptions = subscription.List{{Asset: asset.Spot, Channel: subscription.AllTradesChannel}} subs, err = ku.generateSubscriptions() require.NoError(t, err, "generateSubscriptions must not error") - require.Len(t, subs, 4, "Must get 4 subs") + require.Len(t, subs, 5, "Must get 5 subs") err = ku.Subscribe(subs) - assert.ErrorContains(t, err, "exceed max subscription count limitation of 300 per session", "Subscribe to MarketSnapshot should error above connection symbol limit") + require.Error(t, err, "Subscribe must error") + assert.ErrorContains(t, err, "exceed max subscription count limitation of 400 per session", "Subscribe to MarketSnapshot should error above connection symbol limit") } func TestSubscribeTickerAll(t *testing.T) {