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

Syntax and documentation improvements in passphrase utility - closes #663 #654

Merged
merged 6 commits into from
Apr 4, 2018

Conversation

webmaster128
Copy link
Contributor

@webmaster128 webmaster128 commented Apr 1, 2018

What was the problem?

Code was hard to review and sometimes a little buggy.

How did I fix it?

Fixed what I found and described in each commit message what and why.

How to test it?

Run the tests. All still passing like before. No functional change. But test coverage is better now

Review checklist

Simon Warta added 6 commits April 1, 2018 02:21
This code selects a random array index from `available` or `byte`. The
formular for this operation is `Math.floor(Math.random()*items.length)`
(see https://stackoverflow.com/a/5915122).

In the current code, Math.floor is replaced with parseInt, which is
meant to convert a string, not a floating point number. Since parseInt
converts a number to a string first, the result will be the same in most
cases. However, parseInt is not the right tool in this place. MDN
excplicitly warns: "parseInt should not be used as a substitute for
Math.floor()"
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt)
The value of the variable is not the bit (0 or 1) but the index in the
array `byte`.
parseInt(`0x${num}`, 10) is always 0 for any hex string `num`.
Before, an empty array from generateSeed() would make this test pass.
@slaweet slaweet requested a review from reyraa April 3, 2018 06:41
Copy link
Contributor

@reyraa reyraa left a comment

Choose a reason for hiding this comment

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

Thank you Simon. We appreciate your contribution. hope we receive more good work like this from you :-)

@reyraa reyraa changed the base branch from development to 0.4.0 April 3, 2018 09:50
@reyraa reyraa changed the title Rng cleanups Syntax and documentation improvements in passphrase utility - closes #663 Apr 3, 2018
@reyraa reyraa merged commit 8fa5757 into LiskHQ:0.4.0 Apr 4, 2018
@webmaster128 webmaster128 deleted the rng-cleanups branch April 4, 2018 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants