Skip to content
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

Move "Enter a password" cmd instructions to shared/cmd #5724

Merged
merged 28 commits into from
May 5, 2020
Merged

Conversation

0xKiwi
Copy link
Contributor

@0xKiwi 0xKiwi commented May 3, 2020

Improvement for validator client

This PR moves the CMD "Enter password" to its own function under shared/cmd, it will be reused in a future PR so might as well relocate it.

Testing terminal.ReadPassword is rather complicated so I've made a tracking issue for it #5749

@0xKiwi 0xKiwi requested a review from a team as a code owner May 3, 2020 19:52
@0xKiwi 0xKiwi added the Ready For Review A pull request ready for code review label May 3, 2020
@@ -42,3 +43,16 @@ func ConfirmAction(actionText string, deniedText string) (bool, error) {

return confirmed, nil
}

func EnterPassword() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional comment

@@ -42,3 +43,16 @@ func ConfirmAction(actionText string, deniedText string) (bool, error) {

return confirmed, nil
}

func EnterPassword() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also is a good unit test candidate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 unit test would be good for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing a test for terminal.ReadPassword is rather complicated, made a tracking issue at #5749

log.Fatalf("Could not read account password: %v", err)
return path, passphrase, err
log.Fatal(err)
return path, enteredPassphrase, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no point of returning the result here, when you have a fatal log above

Copy link
Contributor Author

@0xKiwi 0xKiwi May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is duplicated several times in the validator client, was gonna make another PR making sure it's either handled or returned, never both.

@codecov
Copy link

codecov bot commented May 4, 2020

Codecov Report

Merging #5724 into master will decrease coverage by 14.56%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           master    #5724       +/-   ##
===========================================
- Coverage   54.76%   40.20%   -14.57%     
===========================================
  Files         313      301       -12     
  Lines       26485    25154     -1331     
===========================================
- Hits        14504    10112     -4392     
- Misses       9894    13184     +3290     
+ Partials     2087     1858      -229     

@0xKiwi 0xKiwi requested review from terencechain and nisdas May 5, 2020 19:13
rauljordan
rauljordan previously approved these changes May 5, 2020

// EnterPassword queries the user for their password through the terminal, in order to make sure it is
// not passed in a visible way to the terminal.
// TODO(#5749) This function is untested, would be a good candidate for unit test.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO(#5749) This function is untested, would be a good candidate for unit test.
// TODO(#5749) This function is untested, would be a good candidate for unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, fixed.

rauljordan
rauljordan previously approved these changes May 5, 2020
shared/cmd/helpers.go Outdated Show resolved Hide resolved
@0xKiwi 0xKiwi merged commit 2b7865c into master May 5, 2020
@delete-merged-branch delete-merged-branch bot deleted the move-pass-to-cmd branch May 5, 2020 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants