Config: OrderManager upgrade (#1737)

* Config: Allow missing Versions

This allows easier development of non-stacked version upgrades.
Though the PRs still need to be merged sequentially, or renumbered right
before merging

* Config: Move OrderManager upgrade to Version management
This commit is contained in:
Gareth Kirwan
2025-03-19 12:11:28 +07:00
committed by GitHub
parent f5faca2eb2
commit ade3ac5c59
10 changed files with 180 additions and 74 deletions

View File

@@ -13,7 +13,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/convert"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
@@ -162,30 +161,23 @@ func (f omfExchange) GetFuturesPositions(_ context.Context, req *futures.Positio
func TestSetupOrderManager(t *testing.T) {
_, err := SetupOrderManager(nil, nil, nil, nil)
if !errors.Is(err, errNilExchangeManager) {
t.Errorf("error '%v', expected '%v'", err, errNilExchangeManager)
}
assert.ErrorIs(t, err, errNilExchangeManager)
_, err = SetupOrderManager(NewExchangeManager(), nil, nil, nil)
if !errors.Is(err, errNilCommunicationsManager) {
t.Errorf("error '%v', expected '%v'", err, errNilCommunicationsManager)
}
assert.ErrorIs(t, err, errNilCommunicationsManager)
_, err = SetupOrderManager(NewExchangeManager(), &CommunicationManager{}, nil, &config.OrderManager{})
if !errors.Is(err, errNilWaitGroup) {
t.Errorf("error '%v', expected '%v'", err, errNilWaitGroup)
}
assert.ErrorIs(t, err, errNilWaitGroup)
var wg sync.WaitGroup
_, err = SetupOrderManager(NewExchangeManager(), &CommunicationManager{}, &wg, &config.OrderManager{})
if !errors.Is(err, nil) {
t.Errorf("error '%v', expected '%v'", err, nil)
}
_, err = SetupOrderManager(NewExchangeManager(), &CommunicationManager{}, &wg, &config.OrderManager{ActivelyTrackFuturesPositions: true, FuturesTrackingSeekDuration: 0})
if !errors.Is(err, nil) {
t.Errorf("error '%v', expected '%v'", err, nil)
}
require.NoError(t, err)
_, err = SetupOrderManager(NewExchangeManager(), &CommunicationManager{}, &wg, &config.OrderManager{ActivelyTrackFuturesPositions: true})
require.ErrorIs(t, err, errInvalidFuturesTrackingSeekDuration)
_, err = SetupOrderManager(NewExchangeManager(), &CommunicationManager{}, &wg, &config.OrderManager{ActivelyTrackFuturesPositions: true, FuturesTrackingSeekDuration: time.Hour})
if !errors.Is(err, nil) {
t.Errorf("error '%v', expected '%v'", err, nil)
}
require.NoError(t, err)
}
func TestOrderManagerStart(t *testing.T) {
@@ -1546,7 +1538,7 @@ func TestGetOpenFuturesPosition(t *testing.T) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
o, err = SetupOrderManager(em, &CommunicationManager{}, wg, &config.OrderManager{
Enabled: convert.BoolPtr(true),
Enabled: true,
FuturesTrackingSeekDuration: time.Hour,
Verbose: true,
ActivelyTrackFuturesPositions: true,