Skip to content

Commit

Permalink
Kucoin: Fix intermittent conflict in test currs
Browse files Browse the repository at this point in the history
Use isolated test instance for `TestGetOpenInterest`.

`TestGetOpenInterest` would occassionally change pairs before
GenerateDefault Subs.
  • Loading branch information
gbjk committed Jan 17, 2024
1 parent 346c09b commit 61928be
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions exchanges/kucoin/kucoin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,6 +30,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"
)

Expand Down Expand Up @@ -2713,14 +2715,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,
Expand All @@ -2729,8 +2735,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,
Expand All @@ -2745,7 +2751,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)
}

0 comments on commit 61928be

Please sign in to comment.