Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Map the randoms under 0.01 to the range of 0.01 - 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
reyraa committed Sep 28, 2017
1 parent f0ac590 commit 03befac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion features/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Feature: Login page
Then I should be logged in
And I should see text "Testnet" in "peer network" element

@ignore
Scenario: should allow to create a new account
Given I'm on login page
When I click "new account button"
Expand Down
19 changes: 10 additions & 9 deletions src/utils/passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ const leftPadd = (str, pad, length) => {
/**
* Resets previous settings and creates a step with a random length between 1.6% to 3.2%
*/
const init = (rand = Math.random()) => ({
step: (160 + Math.floor(rand * 160)) / 100,
percentage: 0,
seed: emptyByte('00'),
byte: emptyByte(0),
});
const init = (rand = Math.random()) => {
let step = Math.max((160 + Math.floor(rand * 160)));
step = step >= 0.01 ? step : step * 10;
return {
step,
percentage: 0,
seed: emptyByte('00'),
byte: emptyByte(0),
};
};

/**
* - From a zero byte:
Expand All @@ -50,9 +54,6 @@ const init = (rand = Math.random()) => ({
* @param {Number} percentage
* @param {Number} step
*
* @todo
* - Set minimum value for steps to make sure 100 iterations is enough
*
* @returns {number[]} The input array whose member is pos is set
*/
export const generateSeed = ({ byte, seed, percentage, step } = init(), rand = Math.random()) => {
Expand Down

0 comments on commit 03befac

Please sign in to comment.