Update rng function

In case someone copy pastes, instead of getting a dangerous key, they will get a random key, and a console error.
This commit is contained in:
Jonathan Underwood 2018-12-31 15:17:00 +09:00 committed by GitHub
parent b93d9d99cc
commit f8490b6c0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,14 @@ const LITECOIN = {
} }
// deterministic RNG for testing only // deterministic RNG for testing only
function rng () { return Buffer.from('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') } function rng (c) {
if (describe === undefined || it === undefined) {
console.error('DO NOT USE THIS rng FUNCTION OUTSIDE OF AUTOMATED TESTING!')
const randomBytes = require('randombytes')
return randomBytes(c)
}
return Buffer.from('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz')
}
describe('bitcoinjs-lib (addresses)', function () { describe('bitcoinjs-lib (addresses)', function () {
it('can generate a random address', function () { it('can generate a random address', function () {