Skip to content

Commit

Permalink
Engine pre-merge changes (thrasher-corp#392)
Browse files Browse the repository at this point in the history
* Engine pre merge changes

* Remove redundant "seconds"
  • Loading branch information
thrasher- authored Dec 4, 2019
1 parent 11a68a9 commit 17a7865
Show file tree
Hide file tree
Showing 8 changed files with 4,832 additions and 1,436 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ lib
.vscode

testdata/dump
testdata/preengine_config.json
testdata/writefiletest

# InteliJ
Expand Down
20 changes: 0 additions & 20 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,26 +665,6 @@ func (c *Config) CountEnabledExchanges() int {
return counter
}

// GetConfigCurrencyPairFormat returns the config currency pair format
// for a specific exchange
func (c *Config) GetConfigCurrencyPairFormat(exchName string) (*currency.PairFormat, error) {
exchCfg, err := c.GetExchangeConfig(exchName)
if err != nil {
return nil, err
}
return exchCfg.ConfigCurrencyPairFormat, nil
}

// GetRequestCurrencyPairFormat returns the request currency pair format
// for a specific exchange
func (c *Config) GetRequestCurrencyPairFormat(exchName string) (*currency.PairFormat, error) {
exchCfg, err := c.GetExchangeConfig(exchName)
if err != nil {
return nil, err
}
return exchCfg.RequestCurrencyPairFormat, nil
}

// GetCurrencyPairDisplayConfig retrieves the currency pair display preference
func (c *Config) GetCurrencyPairDisplayConfig() *CurrencyPairFormatConfig {
return c.Currency.CurrencyPairFormat
Expand Down
60 changes: 7 additions & 53 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,59 +1052,6 @@ func TestCountEnabledExchanges(t *testing.T) {
}
}

func TestGetConfigCurrencyPairFormat(t *testing.T) {
cfg := GetConfig()
err := cfg.LoadConfig(TestFile, true)
if err != nil {
t.Errorf(
"TestGetConfigCurrencyPairFormat. LoadConfig Error: %s", err.Error(),
)
}
_, err = cfg.GetConfigCurrencyPairFormat("asdasdasd")
if err == nil {
t.Errorf(
"TestGetRequestCurrencyPairFormat. Non-existent exchange returned nil error",
)
}

exchFmt, err := cfg.GetConfigCurrencyPairFormat("Yobit")
if err != nil {
t.Errorf("TestGetConfigCurrencyPairFormat err: %s", err)
}
if !exchFmt.Uppercase || exchFmt.Delimiter != "_" {
t.Errorf(
"TestGetConfigCurrencyPairFormat. Invalid values",
)
}
}

func TestGetRequestCurrencyPairFormat(t *testing.T) {
cfg := GetConfig()
err := cfg.LoadConfig(TestFile, true)
if err != nil {
t.Errorf(
"TestGetRequestCurrencyPairFormat. LoadConfig Error: %s", err.Error(),
)
}

_, err = cfg.GetRequestCurrencyPairFormat("asdasdasd")
if err == nil {
t.Errorf(
"TestGetRequestCurrencyPairFormat. Non-existent exchange returned nil error",
)
}

exchFmt, err := cfg.GetRequestCurrencyPairFormat("Yobit")
if err != nil {
t.Errorf("TestGetRequestCurrencyPairFormat. Err: %s", err)
}
if exchFmt.Uppercase || exchFmt.Delimiter != "_" || exchFmt.Separator != "-" {
t.Errorf(
"TestGetRequestCurrencyPairFormat. Invalid values",
)
}
}

func TestGetCurrencyPairDisplayConfig(t *testing.T) {
cfg := GetConfig()
err := cfg.LoadConfig(TestFile, true)
Expand Down Expand Up @@ -1929,3 +1876,10 @@ func TestCheckCurrencyConfigValues(t *testing.T) {
t.Error("Failed to set CryptocurrencyProvider.APIkey and AccountPlan")
}
}

func TestPreengineConfigUpgrade(t *testing.T) {
var c Config
if err := c.LoadConfig("../testdata/preengine_config.json", false); err != nil {
t.Fatal(err)
}
}
2,362 changes: 1,672 additions & 690 deletions config_example.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions engine/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
c.Ticker.IsUsingWebsocket = false
c.Ticker.IsUsingREST = true
log.Warnf(log.SyncMgr,
"%s %s: No ticker update after 10 seconds, switching from websocket to rest\n",
c.Exchange, FormatCurrency(enabledPairs[i]).String())
"%s %s: No ticker update after %s, switching from websocket to rest\n",
c.Exchange, FormatCurrency(enabledPairs[i]).String(), e.Cfg.SyncTimeout)
switchedToRest = true
e.setProcessing(c.Exchange, c.Pair, c.AssetType, SyncItemTicker, false)
}
Expand Down Expand Up @@ -435,8 +435,8 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
c.Orderbook.IsUsingWebsocket = false
c.Orderbook.IsUsingREST = true
log.Warnf(log.SyncMgr,
"%s %s: No orderbook update after 15 seconds, switching from websocket to rest\n",
c.Exchange, FormatCurrency(c.Pair).String())
"%s %s: No orderbook update after %s, switching from websocket to rest\n",
c.Exchange, FormatCurrency(c.Pair).String(), e.Cfg.SyncTimeout)
switchedToRest = true
e.setProcessing(c.Exchange, c.Pair, c.AssetType, SyncItemOrderbook, false)
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
flag.BoolVar(&settings.EnableAllPairs, "enableallpairs", false, "enables all pairs for enabled exchanges")
flag.BoolVar(&settings.EnablePortfolioManager, "portfoliomanager", true, "enables the portfolio manager")
flag.BoolVar(&settings.EnableGRPC, "grpc", true, "enables the grpc server")
flag.BoolVar(&settings.EnableGRPCProxy, "grpcproxy", true, "enables the grpc proxy server")
flag.BoolVar(&settings.EnableGRPCProxy, "grpcproxy", false, "enables the grpc proxy server")
flag.BoolVar(&settings.EnableWebsocketRPC, "websocketrpc", true, "enables the websocket RPC server")
flag.BoolVar(&settings.EnableDeprecatedRPC, "deprecatedrpc", true, "enables the deprecated RPC server")
flag.BoolVar(&settings.EnableCommsRelayer, "enablecommsrelayer", true, "enables available communications relayer")
Expand Down
2,346 changes: 1,678 additions & 668 deletions testdata/configtest.json

Large diffs are not rendered by default.

Loading

0 comments on commit 17a7865

Please sign in to comment.