adhere to standard

This commit is contained in:
Daniel Cousens 2015-10-02 00:30:01 +10:00
parent 967512dc25
commit 889f233bdd
2 changed files with 72 additions and 71 deletions

View File

@ -111,12 +111,12 @@ function salt(password) {
function bytesToBinary (bytes) {
return bytes.map(function (x) {
return lpad(x.toString(2), '0', 8)
}).join('');
}).join('')
}
function lpad (str, padString, length) {
while (str.length < length) str = padString + str;
return str;
while (str.length < length) str = padString + str
return str
}
module.exports = {

View File

@ -1,3 +1,5 @@
/* global describe it */
var assert = require('assert')
var mock = require('mock-require')
@ -111,7 +113,6 @@ describe('BIP39', function() {
describe('validateMnemonic', function () {
vectors.english.forEach(function (v, i) {
it('passes check ' + i, function () {
assert(BIP39.validateMnemonic(v[1]))
})
@ -119,7 +120,6 @@ describe('BIP39', function() {
describe('with a custom wordlist', function () {
vectors.custom.forEach(function (v, i) {
it('passes custom check ' + i, function () {
assert(BIP39.validateMnemonic(v[1], wordlists.custom))
})
@ -132,7 +132,7 @@ describe('BIP39', function() {
})
it('fails for mnemonics that contains words not from the word list', function () {
assert(!BIP39.validateMnemonic("turtle front uncle idea crush write shrug there lottery flower risky shell"))
assert(!BIP39.validateMnemonic('turtle front uncle idea crush write shrug there lottery flower risky shell'))
})
it('fails for mnemonics of invalid checksum', function () {
@ -143,12 +143,12 @@ describe('BIP39', function() {
describe('utf8 passwords', function () {
vectors.japanese.forEach(function (v) {
it('creates the correct seed', function () {
var utf8Password = "㍍ガバヴァぱばぐゞちぢ十人十色"
var utf8Password = '㍍ガバヴァぱばぐゞちぢ十人十色'
assert.equal(BIP39.mnemonicToSeedHex(v[1], utf8Password), v[2])
})
it('works with already normalized password', function () {
var normalizedPassword = "メートルガバヴァぱばぐゞちぢ十人十色"
var normalizedPassword = 'メートルガバヴァぱばぐゞちぢ十人十色'
assert.equal(BIP39.mnemonicToSeedHex(v[1], normalizedPassword), v[2])
})
})
@ -184,6 +184,7 @@ describe('BIP39', function() {
assert.ok(bool)
bool = bip39.validateMnemonic('basket actual')
// false
assert.ok(!bool)
})