mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 21:15:47 +00:00
Rename randGen param to random
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const rand = require('brorand');
|
||||
const brorand = require('brorand');
|
||||
const codec = require('ripple-address-codec');
|
||||
|
||||
const {seedFromPhrase, createAccountID} = require('./utils');
|
||||
@@ -48,8 +48,8 @@ function deriveValidator(seedBytes) {
|
||||
}
|
||||
|
||||
function generateWallet(opts={}) {
|
||||
const {type='secp256k1', randGen=rand} = opts;
|
||||
const seedBytes = randGen(16);
|
||||
const {type='secp256k1', random=brorand} = opts;
|
||||
const seedBytes = random(16);
|
||||
return deriveWallet(seedBytes, type);
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ function walletFromPhrase(phrase, type) {
|
||||
}
|
||||
|
||||
function generateValidatorKeys(opts={}) {
|
||||
const {randGen=rand} = opts;
|
||||
return deriveValidator(randGen(16));
|
||||
const {random=brorand} = opts;
|
||||
return deriveValidator(random(16));
|
||||
}
|
||||
|
||||
function nodePublicAccountID(publicKey) {
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('validatorKeysFromPhrase', function() {
|
||||
});
|
||||
|
||||
describe('generateWallet', function() {
|
||||
function randGen(len) {
|
||||
function random(len) {
|
||||
return _.fill(Array(len), 0);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ describe('generateWallet', function() {
|
||||
'ED' +
|
||||
'1A7C082846CFF58FF9A892BA4BA2593151CCF1DBA59F37714CC9ED39824AF85F'
|
||||
};
|
||||
const actual = generateWallet({type: 'ed25519', randGen});
|
||||
const actual = generateWallet({type: 'ed25519', random});
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepEqual(walletFromSeed(actual.seed), expected);
|
||||
});
|
||||
@@ -171,14 +171,14 @@ describe('generateWallet', function() {
|
||||
'03' +
|
||||
'90A196799EE412284A5D80BF78C3E84CBB80E1437A0AECD9ADF94D7FEAAFA284'
|
||||
};
|
||||
const actual = generateWallet({type: undefined, randGen});
|
||||
const actual = generateWallet({type: undefined, random});
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepEqual(walletFromSeed(actual.seed), expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateValidatorKeys', function() {
|
||||
function randGen(len) {
|
||||
function random(len) {
|
||||
return _.fill(Array(len), 0);
|
||||
}
|
||||
it('can generate secp256k1 validator keys', function() {
|
||||
@@ -198,7 +198,7 @@ describe('generateValidatorKeys', function() {
|
||||
seed: 'sp6JS7f14BuwFY8Mw6bTtLKWauoUs',
|
||||
publicKey: 'n9LPxYzbDpWBZ1bC3J3Fdkgqoa3FEhVKCnS8yKp7RFQFwuvd8Q2c'
|
||||
};
|
||||
const actual = generateValidatorKeys({randGen});
|
||||
const actual = generateValidatorKeys({random});
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.deepEqual(validatorKeysFromSeed(actual.seed), expected);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user