-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config: Fix config version downgrade #1770
Conversation
df0de84
to
8457cb1
Compare
Pulling out the os.Exit and replacing with testable pathway. |
a8dbd89
to
82174cf
Compare
That's better, and testable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one thing and a suggestion. Thanks you! 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last thing on new changes and linter issue then looks good to go. Thanks!
Linter fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK! tested both encrypted and unencrypted
😆
go run . --edit --version=-21 downgrade
GoCryptoTrader: config-helper tool
2025/02/17 13:29:06 Running downgrade from config version 2
2025/02/17 13:29:06 Running downgrade from config version 1
2025/02/17 13:29:06 Running downgrade from config version 0
2025/02/17 13:29:06 Running downgrade from config version -1
panic: runtime error: index out of range [-1]
goroutine 1 [running]:
github.com/thrasher-corp/gocryptotrader/config/versions.(*manager).Deploy(0x1029d4900, {0x1027f9b00, 0x1029fcbe0}, {0x14000400000, 0x757c6, 0x757c7}, 0xffffffffffffffeb)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/config/versions/versions.go:117 +0xd58
main.main()
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/cmd/config/config.go:90 +0xa00
exit status 2
@gloriousCode I know you didn't ask for it but ... Fixed gbjk@2184f0672 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go run . upgrade --edit --in=../../config_example.json --out=../../config_example.json
GoCryptoTrader: config-helper tool
2025/02/19 17:30:43 Running upgrade to config version 0
2025/02/19 17:30:43 Running upgrade to config version 1
2025/02/19 17:30:43 Running upgrade to config version 2
2025/02/19 17:30:43 Version management finished
Success! File written to ../../config_example.json
go run . downgrade --version=1 --edit --in=../../config_example.json --out=../../config_example.json
GoCryptoTrader: config-helper tool
2025/02/19 17:31:12 Running downgrade from config version 2
2025/02/19 17:31:12 Version management finished
Success! File written to ../../config_example.json
Same above works for both an encrypted config!
An issue I found when testing this on a fresh config_example.json:
go run . downgrade --version=5 --edit --in=../../config_example.json --out=../../config_example.json
GoCryptoTrader: config-helper tool
2025/02/19 17:27:51 Running upgrade to config version 0
2025/02/19 17:27:51 Running upgrade to config version 1
2025/02/19 17:27:51 Running upgrade to config version 2
2025/02/19 17:27:51 Running upgrade to config version 3
panic: runtime error: index out of range [3] with length 3
goroutine 1 [running]:
github.com/thrasher-corp/gocryptotrader/config/versions.(*manager).Deploy(0xb30e80, {0x8ef1a0, 0xb784e0}, {0xc000380000, 0x32395, 0x32396}, 0x5)
/go/src/github.com/thrasher-corp/gocryptotrader/config/versions/versions.go:117 +0x12cd
main.main()
/go/src/github.com/thrasher-corp/gocryptotrader/cmd/config/config.go:94 +0xb52
exit status 2
At some point I want to add fuzzing to GCT, so this is a good thing to resolve even though it's a funny user request
Thanks! Fixed gbjk@8b9dbe47f |
Because this isn't really a file, it's a byte slice
Because it's not actually a file
8b9dbe4
to
4904098
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK, thanks for fixing that!
Fixes #1769 and issue raised on #1735
Type of change
How has this been tested