adds test for randombytes

This commit is contained in:
Daniel Cousens 2015-04-08 12:26:14 +10:00
parent d99ec8630f
commit 1e2eb62cff
2 changed files with 12 additions and 1 deletions

View File

@ -28,6 +28,7 @@
},
"devDependencies": {
"browserify": "^9.0.0",
"mocha": "^2.2.0"
"mocha": "^2.2.0",
"mock-require": "^1.0.5"
}
}

View File

@ -1,4 +1,10 @@
var assert = require('assert')
var mock = require('mock-require')
mock('randombytes', function(size) {
return new Buffer('qwertyuiopasdfghjklzxcvbnm[];,./'.slice(0, size))
})
var BIP39 = require('../index.js')
var wordlists = {
@ -63,6 +69,10 @@ describe('BIP39', function() {
assert.equal(words.length, 9)
})
it('defaults to randombytes for the RNG', function() {
assert.equal(BIP39.generateMnemonic(32), 'imitate robot frequent')
})
it('allows a custom RNG to be used', function() {
var rng = function(size) {
var buffer = new Buffer(size)