|
|
@ -1,5 +1,7 @@ |
|
|
|
var assert = require('assert') |
|
|
|
var crypto = require('crypto') |
|
|
|
var BIP39 = require('../index.js') |
|
|
|
var sinon = require('sinon') |
|
|
|
|
|
|
|
var wordlists = { |
|
|
|
english: require('../wordlists/en.json'), |
|
|
@ -48,7 +50,17 @@ describe('BIP39', function() { |
|
|
|
}) |
|
|
|
|
|
|
|
describe('generateMnemonic', function() { |
|
|
|
it('generates a mnemonic', function() { |
|
|
|
vectors.english.forEach(function(v, i) { |
|
|
|
it('works for tests vector ' + i, sinon.test(function() { |
|
|
|
this.mock(crypto).expects('randomBytes') |
|
|
|
.exactly(1) |
|
|
|
.onCall(0).returns(new Buffer(v[0], 'hex')) |
|
|
|
|
|
|
|
assert.equal(BIP39.generateMnemonic(), v[1]) |
|
|
|
})) |
|
|
|
}) |
|
|
|
|
|
|
|
it('can vary generated entropy bit length', function() { |
|
|
|
var mnemonic = BIP39.generateMnemonic(96) |
|
|
|
var words = mnemonic.split(' ') |
|
|
|
|
|
|
|