-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix: added key when dry-run is true #9480
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9480 +/- ##
==========================================
+ Coverage 60.66% 60.70% +0.03%
==========================================
Files 588 588
Lines 37273 37277 +4
==========================================
+ Hits 22612 22628 +16
+ Misses 12715 12699 -16
- Partials 1946 1950 +4
|
13e19b1
to
206c0bf
Compare
@@ -100,10 +100,11 @@ input | |||
output | |||
- armor encrypted private key (saved to file) | |||
*/ | |||
func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error { | |||
func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error { |
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.
I'm not not sure why this was public before.
I think it would be worth to add a regression test to make sure this does not happen again in the future as it might break a lot of things |
client/keys/add.go
Outdated
} | ||
|
||
return printCreate(cmd, info, false, "", outputFormat) |
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.
Print info for multisig as we do for other keys.
} | ||
} | ||
|
||
return printCreate(cmd, info, false, "", outputFormat) |
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.
Print info for pubkey as we do for other keys.
5ba63d4
to
9e3edfe
Compare
client/keys/add.go
Outdated
|
||
multisigKeys, _ := cmd.Flags().GetStringSlice(flagMultisig) | ||
if len(multisigKeys) != 0 { | ||
var pks []cryptotypes.PubKey |
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.
For better efficiency, I would define pks
as slice with finite cap like that pks := make([]cryptotypes.PubKey, len(multisigKeys))
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.
Thanks! This causes a panic on line 162 with sorting. Maybe we can optimize in a separate pull request?
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.
LGTM
I manual tested :
./build/simd keys add jack
./build/simd keys add jack --dry-run
override the existing name jack [y/N]: y
Error: override not available with --dry-run
should I perform more manual testing?
What? It asks you if you want to override?! Shouldn't |
Yes, please. I manually tested the
|
What if you first add a key and the use
Before this bug, |
@RiccardoM Thanks for clarifying the issue and providing feedback. I will take another look. |
b7d47e7
to
c2a6c76
Compare
c2a6c76
to
37c3ce4
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
@@ -136,7 +141,6 @@ func RunAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf | |||
} | |||
} | |||
|
|||
multisigKeys, _ := cmd.Flags().GetStringSlice(flagMultisig) |
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.
why moving it out of the else
scope? seems like it's only used here
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.
lgtm
@RiccardoM does this PR look good to you? Should we put automerge? |
tACK, implementations looks great 👍 |
(cherry picked from commit 7679820)
Description
Closes: #9475
This pull request ensures a key is not added after running
keys add
with--dry-run
. This pull request also adds consistent output information for each key (previously multisig and pubkey did not print info).Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking change - n/aCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change