Skip to content

Commit

Permalink
BTCMarkets: Fix testexch.Setup not finding config
Browse files Browse the repository at this point in the history
BTCMarkets is the only example where config name doesn't match the
package name.
Renaming it shouldn't have any impact.
Users having different names locally for it in config shouldn't either
  • Loading branch information
gbjk committed Aug 20, 2024
1 parent ec283f2 commit d6abdc0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
2 changes: 1 addition & 1 deletion config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
},
"exchanges": [
{
"name": "BTC Markets",
"name": "BTCMarkets",
"enabled": true,
"verbose": false,
"httpTimeout": 15000000000,
Expand Down
33 changes: 10 additions & 23 deletions exchanges/btcmarkets/btcmarkets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package btcmarkets
import (
"context"
"errors"
"fmt"
"log"
"os"
"testing"
Expand All @@ -12,7 +11,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/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
Expand All @@ -37,30 +35,19 @@ const (
)

func TestMain(m *testing.M) {
b.SetDefaults()
cfg := config.GetConfig()
err := cfg.LoadConfig("../../testdata/configtest.json", true)
if err != nil {
log.Fatal(err)
}
bConfig, err := cfg.GetExchangeConfig("BTC Markets")
if err != nil {
log.Fatal(err)
}
bConfig.API.Credentials.Key = apiKey
bConfig.API.Credentials.Secret = apiSecret
bConfig.API.AuthenticatedSupport = true
b.Websocket = sharedtestvalues.NewTestWebsocket()
err = b.Setup(bConfig)
if err != nil {
b = new(BTCMarkets)
if err := testexch.Setup(b); err != nil {
log.Fatal(err)
}
err = b.ValidateAPICredentials(context.Background(), asset.Spot)
if err != nil {
fmt.Println("API credentials are invalid:", err)
b.API.AuthenticatedSupport = false
b.API.AuthenticatedWebsocketSupport = false

if apiKey != "" && apiSecret != "" {
b.API.AuthenticatedSupport = true
b.API.AuthenticatedWebsocketSupport = true
b.API.CredentialsValidator.RequiresBase64DecodeSecret = false
b.SetCredentials(apiKey, apiSecret, "", "", "", "")
b.Websocket.SetCanUseAuthenticatedEndpoints(true)
}

os.Exit(m.Run())
}

Expand Down
2 changes: 1 addition & 1 deletion testdata/configtest.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
},
"exchanges": [
{
"name": "BTC Markets",
"name": "BTCMarkets",
"enabled": true,
"verbose": false,
"httpTimeout": 15000000000,
Expand Down

0 comments on commit d6abdc0

Please sign in to comment.