mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 23:16:52 +00:00
accounts: Move to instance methods, fix races and isolate tests (#1923)
* Bybit: Fix race in TestUpdateAccountInfo and TestWSHandleData * DriveBy rename TestWSHandleData * This doesn't address running with -race=2+ due to the singleton * Accounts: Add account.GetService() * exchange: Assertify TestSetupDefaults * Exchanges: Add account.Service override for testing * Exchanges: Remove duplicate IsWebsocketEnabled test from TestSetupDefaults * Dispatch: Replace nil checks with NilGuard * Engine: Remove deprecated printAccountHoldingsChangeSummary * Dispatcher: Add EnsureRunning method * Accounts: Move singleton accounts service to exchange Accounts * Move singleton accounts service to exchange Accounts This maintains the concept of a global store, whilst allowing exchanges to override it when needed, particularly for testing. APIServer: * Remove getAllActiveAccounts from apiserver Deprecated apiserver only thing using this, so remove it instead of updating it * Update comment for UpdateAccountBalances everywhere * Docs: Add punctuation to function comments * Bybit: Coverage for wsProcessWalletPushData Save
This commit is contained in:
@@ -39,8 +39,8 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/database"
|
||||
"github.com/thrasher-corp/gocryptotrader/database/drivers"
|
||||
"github.com/thrasher-corp/gocryptotrader/engine"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchange/accounts"
|
||||
gctexchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/binance"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/binanceus"
|
||||
@@ -337,7 +337,7 @@ func TestLoadDataLive(t *testing.T) {
|
||||
ExchangeCredentials: []config.Credentials{
|
||||
{
|
||||
Exchange: testExchange,
|
||||
Keys: account.Credentials{
|
||||
Keys: accounts.Credentials{
|
||||
Key: "test",
|
||||
Secret: "test",
|
||||
ClientID: "test",
|
||||
@@ -1392,7 +1392,7 @@ func TestSetExchangeCredentials(t *testing.T) {
|
||||
// enter them here
|
||||
cfg.DataSettings.LiveData.ExchangeCredentials = []config.Credentials{{
|
||||
Exchange: testExchange,
|
||||
Keys: account.Credentials{
|
||||
Keys: accounts.Credentials{
|
||||
Key: "test",
|
||||
Secret: "test",
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/backtester/eventtypes/signal"
|
||||
"github.com/thrasher-corp/gocryptotrader/backtester/funding"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchange/accounts"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/futures"
|
||||
gctkline "github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||
@@ -219,7 +219,7 @@ func (f fakeFunding) UpdateFundingFromLiveData(bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f fakeFunding) SetFunding(string, asset.Item, *account.Balance, bool) error {
|
||||
func (f fakeFunding) SetFunding(string, asset.Item, *accounts.Balance, bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/database"
|
||||
"github.com/thrasher-corp/gocryptotrader/database/drivers"
|
||||
gctengine "github.com/thrasher-corp/gocryptotrader/engine"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchange/accounts"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
gctkline "github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||
"github.com/thrasher-corp/gocryptotrader/gctrpc/auth"
|
||||
@@ -547,7 +547,7 @@ func (s *GRPCServer) ExecuteStrategyFromConfig(_ context.Context, request *btrpc
|
||||
for i := range request.Config.DataSettings.LiveData.Credentials {
|
||||
creds[i] = config.Credentials{
|
||||
Exchange: request.Config.DataSettings.LiveData.Credentials[i].Exchange,
|
||||
Keys: account.Credentials{
|
||||
Keys: accounts.Credentials{
|
||||
Key: request.Config.DataSettings.LiveData.Credentials[i].Keys.Key,
|
||||
Secret: request.Config.DataSettings.LiveData.Credentials[i].Keys.Secret,
|
||||
ClientID: request.Config.DataSettings.LiveData.Credentials[i].Keys.ClientId,
|
||||
|
||||
Reference in New Issue
Block a user