integration: use an rng for the example over mocking
This commit is contained in:
parent
689f444bdf
commit
b55874718a
1 changed files with 5 additions and 8 deletions
|
@ -3,21 +3,18 @@
|
|||
var assert = require('assert')
|
||||
var bigi = require('bigi')
|
||||
var bitcoin = require('../../')
|
||||
var crypto = require('crypto')
|
||||
var sinon = require('sinon')
|
||||
|
||||
describe('bitcoinjs-lib (basic)', function () {
|
||||
it('can generate a random bitcoin address', sinon.test(function () {
|
||||
it('can generate a random bitcoin address', function () {
|
||||
// for testing only
|
||||
this.mock(crypto).expects('randomBytes')
|
||||
.onCall(0).returns(new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'))
|
||||
function rng () { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') }
|
||||
|
||||
// generate random key
|
||||
var key = bitcoin.ECKey.makeRandom()
|
||||
// generate random key (custom rng for testing only)
|
||||
var key = bitcoin.ECKey.makeRandom(undefined, rng)
|
||||
var address = key.pub.getAddress().toString()
|
||||
|
||||
assert.equal(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64')
|
||||
}))
|
||||
})
|
||||
|
||||
it('can generate an address from a SHA256 hash', function () {
|
||||
var hash = bitcoin.crypto.sha256('correct horse battery staple')
|
||||
|
|
Loading…
Reference in a new issue