mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 07:26:44 +00:00
Tests: Abstract UpdatePairsOnce (#1503)
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -23,6 +22,7 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
||||
testexch "github.com/thrasher-corp/gocryptotrader/internal/testing/exchange"
|
||||
)
|
||||
|
||||
// Please supply your own keys here to do better tests
|
||||
@@ -60,7 +60,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
func TestUpdateTradablePairs(t *testing.T) {
|
||||
t.Parallel()
|
||||
updatePairsOnce(t)
|
||||
testexch.UpdatePairsOnce(t, b)
|
||||
expected := map[asset.Item][]string{
|
||||
asset.Spot: {"BTCUSD", "BTCUSDT", "ETHBTC"},
|
||||
asset.Futures: {"BTCPFC", "ETHPFC"},
|
||||
@@ -600,6 +600,7 @@ func seedOrderSizeLimitMap() {
|
||||
|
||||
func TestWithinLimits(t *testing.T) {
|
||||
t.Parallel()
|
||||
testexch.UpdatePairsOnce(t, b)
|
||||
seedOrderSizeLimitMap()
|
||||
p, _ := currency.NewPairDelimiter("XRP-USD", "-")
|
||||
assert.NoError(t, b.withinLimits(p, 1.0), "withinLimits should not error")
|
||||
@@ -714,18 +715,9 @@ func TestIsPerpetualFutureCurrency(t *testing.T) {
|
||||
assert.False(t, isPerp, "IsPerpetualFutureCurrency should return false for a spot pair")
|
||||
}
|
||||
|
||||
var updatePairsGuard sync.Once
|
||||
|
||||
func updatePairsOnce(tb testing.TB) {
|
||||
tb.Helper()
|
||||
updatePairsGuard.Do(func() {
|
||||
err := b.UpdateTradablePairs(context.Background(), true)
|
||||
assert.NoError(tb, err, "UpdateTradablePairs should not error")
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetOpenInterest(t *testing.T) {
|
||||
t.Parallel()
|
||||
testexch.UpdatePairsOnce(t, b)
|
||||
cp1 := currency.NewPair(currency.BTC, currency.PFC)
|
||||
cp2 := currency.NewPair(currency.ETH, currency.PFC)
|
||||
sharedtestvalues.SetupCurrencyPairsForExchangeAsset(t, b, asset.Futures, futuresPair, cp1, cp2)
|
||||
|
||||
Reference in New Issue
Block a user