mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* Config: Version Management * Engine: Improve visibility of TestConfigAllJsonResponse failures * Config: Update cmd/config to allow upgrades * Config: Add Version2 to rename GDAX * Config: Restructure versioning to share types This restructure allows us to share types between versions, avoids needing to import the versions, and puts the test fixtures in same package. It's a win on all fronts * Config: Fix SetNTPCheck using log Called from engine before logger is inited, and also just wrong to use log to communicate with user * Config: Improve TestMigrateConfig * Config: Drop requirement for versions to be registered in sequence Checking the versions at Deploy is much saner. * Config: Fix file encrypted but flag not set * Config: Add -edit and encryption upgrade to cmd/config This simplifies the handling for encryption prompts by moving it to a field on config, allowing us to simplify all the places were were passing around config Also moves password entry to being secure (echo-off) * Tests: Fix inconsistent should/must assertions
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package versions
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// TestVersion1 is an empty and incompatible Version for testing
|
|
type TestVersion1 struct{}
|
|
|
|
// TestVersion2 is test fixture
|
|
type TestVersion2 struct {
|
|
ConfigErr bool
|
|
ExchErr bool
|
|
}
|
|
|
|
var (
|
|
errUpgrade = errors.New("do you expect me to talk?")
|
|
errDowngrade = errors.New("no, I expect you to die")
|
|
)
|
|
|
|
// UpgradeConfig errors if v.ConfigErr is true
|
|
func (v *TestVersion2) UpgradeConfig(_ context.Context, c []byte) ([]byte, error) {
|
|
if v.ConfigErr {
|
|
return c, errUpgrade
|
|
}
|
|
return c, nil
|
|
}
|
|
|
|
// DowngradeConfig errors if v.ConfigErr is true
|
|
func (v *TestVersion2) DowngradeConfig(_ context.Context, c []byte) ([]byte, error) {
|
|
if v.ConfigErr {
|
|
return c, errDowngrade
|
|
}
|
|
return c, nil
|
|
}
|
|
|
|
// Exchanges returns just Juan
|
|
func (v *TestVersion2) Exchanges() []string {
|
|
return []string{"Juan"}
|
|
}
|
|
|
|
// UpgradeExchange errors if ExchErr is true
|
|
func (v *TestVersion2) UpgradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
|
if v.ExchErr {
|
|
return e, errUpgrade
|
|
}
|
|
return e, nil
|
|
}
|
|
|
|
// DowngradeExchange errors if ExchErr is true
|
|
func (v *TestVersion2) DowngradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
|
if v.ExchErr {
|
|
return e, errDowngrade
|
|
}
|
|
return e, nil
|
|
}
|