Skip to content

Commit

Permalink
engine: Add additional SetupExchanges edge case test and prevent supp…
Browse files Browse the repository at this point in the history
…ressed dry run warnings
  • Loading branch information
thrasher- committed Aug 27, 2024
1 parent a0bc623 commit 71eddf8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
13 changes: 9 additions & 4 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,12 @@ func (bot *Engine) dryRunParamInteraction(param string) {
return
}

gctlog.Warnf(gctlog.Global,
"Command line argument '-%s' induces dry run mode."+
" Set -dryrun=false if you wish to override this.",
param)

if !bot.Settings.EnableDryRun {
gctlog.Warnf(gctlog.Global,
"Command line argument '-%s' induces dry run mode."+
" Set -dryrun=false if you wish to override this.",
param)
bot.Settings.EnableDryRun = true
}
}
Expand Down Expand Up @@ -908,6 +909,10 @@ func (bot *Engine) SetupExchanges() error {
}
}

if bot.Settings.EnableAllExchanges && len(exchangesOverride) > 0 {
return errors.New("cannot enable all exchanges and specific exchanges concurrently")
}

var wg sync.WaitGroup
for x := range configs {
shouldLoad := false
Expand Down
15 changes: 14 additions & 1 deletion engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,20 @@ func TestSetupExchanges(t *testing.T) {
assert.ErrorIs(t, e.SetupExchanges(), ErrNoExchangesLoaded)
})

// Test that adjusting settings induces dry run mode correctly
t.Run("EnableAllExchanges with specific exchanges set", func(t *testing.T) {
t.Parallel()
e := &Engine{
Config: &config.Config{},
Settings: Settings{
CoreSettings: CoreSettings{
EnableAllExchanges: true,
Exchanges: "Bitstamp,Bitfinex",
},
},
}
assert.EqualError(t, e.SetupExchanges(), "cannot enable all exchanges and specific exchanges concurrently")
})

t.Run("Settings dry run toggling", func(t *testing.T) {
t.Parallel()
e := &Engine{
Expand Down

0 comments on commit 71eddf8

Please sign in to comment.