mirror of https://github.com/status-im/bip39.git
tests: add verification of use of crypto.randomBytes
This commit is contained in:
parent
f5208f9a09
commit
65d54896c5
|
@ -21,7 +21,8 @@
|
|||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"crypto-js": "^3.1.2-2"
|
||||
"crypto-js": "^3.1.2-2",
|
||||
"sinon": "^1.10.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^5.9.1",
|
||||
|
|
|
@ -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(' ')
|
||||
|
||||
|
|
Loading…
Reference in New Issue