From f4eca3bbf72da719c1a12f8026447cc5ed8c644e Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Wed, 17 Jan 2024 10:45:44 +0700 Subject: [PATCH] Kucoin: Fix intermittent conflict in test currs Use isolated test instance for `TestGetOpenInterest`. `TestGetOpenInterest` would occassionally change pairs before GenerateDefault Subs. --- exchanges/kucoin/kucoin_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/exchanges/kucoin/kucoin_test.go b/exchanges/kucoin/kucoin_test.go index fcab0a16823..0be84033ffa 100644 --- a/exchanges/kucoin/kucoin_test.go +++ b/exchanges/kucoin/kucoin_test.go @@ -12,6 +12,7 @@ import ( "github.com/gofrs/uuid" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/thrasher-corp/gocryptotrader/common" "github.com/thrasher-corp/gocryptotrader/common/key" "github.com/thrasher-corp/gocryptotrader/config" @@ -28,6 +29,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/exchanges/stream/buffer" "github.com/thrasher-corp/gocryptotrader/exchanges/subscription" "github.com/thrasher-corp/gocryptotrader/exchanges/ticker" + testexch "github.com/thrasher-corp/gocryptotrader/internal/testing/exchange" "github.com/thrasher-corp/gocryptotrader/portfolio/withdraw" ) @@ -2711,14 +2713,18 @@ func TestUpdateOrderExecutionLimits(t *testing.T) { func TestGetOpenInterest(t *testing.T) { t.Parallel() - _, err := ku.GetOpenInterest(context.Background(), key.PairAsset{ + + nu := new(Kucoin) + require.NoError(t, testexch.TestInstance(nu), "TestInstance setup should not error") + + _, err := nu.GetOpenInterest(context.Background(), key.PairAsset{ Base: currency.ETH.Item, Quote: currency.USDT.Item, Asset: asset.USDTMarginedFutures, }) assert.ErrorIs(t, err, asset.ErrNotSupported) - resp, err := ku.GetOpenInterest(context.Background(), key.PairAsset{ + resp, err := nu.GetOpenInterest(context.Background(), key.PairAsset{ Base: futuresTradablePair.Base.Item, Quote: futuresTradablePair.Quote.Item, Asset: asset.Futures, @@ -2727,8 +2733,8 @@ func TestGetOpenInterest(t *testing.T) { assert.NotEmpty(t, resp) cp1 := currency.NewPair(currency.ETH, currency.USDTM) - sharedtestvalues.SetupCurrencyPairsForExchangeAsset(t, ku, asset.Futures, cp1) - resp, err = ku.GetOpenInterest(context.Background(), + sharedtestvalues.SetupCurrencyPairsForExchangeAsset(t, nu, asset.Futures, cp1) + resp, err = nu.GetOpenInterest(context.Background(), key.PairAsset{ Base: futuresTradablePair.Base.Item, Quote: futuresTradablePair.Quote.Item, @@ -2743,7 +2749,7 @@ func TestGetOpenInterest(t *testing.T) { assert.NoError(t, err) assert.NotEmpty(t, resp) - resp, err = ku.GetOpenInterest(context.Background()) + resp, err = nu.GetOpenInterest(context.Background()) assert.NoError(t, err) assert.NotEmpty(t, resp) }