diff --git a/package.json b/package.json index fb5b11f..1fc425f 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "devDependencies": { "browserify": "^9.0.0", - "mocha": "^2.2.0" + "mocha": "^2.2.0", + "mock-require": "^1.0.5" } } diff --git a/test/index.js b/test/index.js index 9cbff2c..b201882 100644 --- a/test/index.js +++ b/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)