mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 15:10:44 +00:00
exchanges: Improve TestMain usage (#1946)
* exchanges: Improve TestMain usage * exchanges: Further cleanups * exchanges/kucoin: update TestProcessOrderbook to use test context * refactor: rename SetRunning to SetRunningURL for clarity across exchanges
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
"github.com/thrasher-corp/gocryptotrader/core"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchange/websocket"
|
||||
@@ -28,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
h = &HitBTC{}
|
||||
h *HitBTC
|
||||
wsSetupRan bool
|
||||
)
|
||||
|
||||
@@ -42,29 +41,19 @@ const (
|
||||
var spotPair = currency.NewBTCUSD().Format(currency.PairFormat{Uppercase: true})
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
h.SetDefaults()
|
||||
cfg := config.GetConfig()
|
||||
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
||||
if err != nil {
|
||||
log.Fatal("HitBTC load config error", err)
|
||||
}
|
||||
hitbtcConfig, err := cfg.GetExchangeConfig("HitBTC")
|
||||
if err != nil {
|
||||
log.Fatal("HitBTC Setup() init error")
|
||||
}
|
||||
hitbtcConfig.API.AuthenticatedSupport = true
|
||||
hitbtcConfig.API.AuthenticatedWebsocketSupport = true
|
||||
hitbtcConfig.API.Credentials.Key = apiKey
|
||||
hitbtcConfig.API.Credentials.Secret = apiSecret
|
||||
h.Websocket = sharedtestvalues.NewTestWebsocket()
|
||||
err = h.Setup(hitbtcConfig)
|
||||
if err != nil {
|
||||
log.Fatal("HitBTC setup error", err)
|
||||
h = new(HitBTC)
|
||||
if err := testexch.Setup(h); err != nil {
|
||||
log.Fatalf("HitBTC Setup error: %s", err)
|
||||
}
|
||||
|
||||
err = h.UpdateTradablePairs(context.Background(), false)
|
||||
if err != nil {
|
||||
log.Fatal("HitBTC setup error", err)
|
||||
if apiKey != "" && apiSecret != "" {
|
||||
h.API.AuthenticatedSupport = true
|
||||
h.API.AuthenticatedWebsocketSupport = true
|
||||
h.SetCredentials(apiKey, apiSecret, "", "", "", "")
|
||||
}
|
||||
|
||||
if err := h.UpdateTradablePairs(context.Background(), false); err != nil {
|
||||
log.Fatalf("HitBTC UpdateTradablePairs error: %s", err)
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
|
||||
Reference in New Issue
Block a user