Browse Source

adds test for randombytes

300
Daniel Cousens 10 years ago
parent
commit
1e2eb62cff
  1. 3
      package.json
  2. 10
      test/index.js

3
package.json

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

10
test/index.js

@ -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)

Loading…
Cancel
Save