Browse Source

tests: verify ECPair loops until within interval

hk-custom-address
Daniel Cousens 9 years ago
parent
commit
f11cce0710
  1. 10
      test/ecpair.js

10
test/ecpair.js

@ -169,6 +169,16 @@ describe('ECPair', function () {
assert.strictEqual(keyPair.toWIF(), exWIF)
})
it('loops until d is within interval [1, n - 1]', sinon.test(function () {
var rng = this.mock()
rng.exactly(3)
rng.onCall(0).returns(new BigInteger('0').toBuffer(32)) // < 1
rng.onCall(1).returns(curve.n.toBuffer(32)) // > n-1
rng.onCall(2).returns(new BigInteger('42').toBuffer(32)) // valid
ECPair.makeRandom({ rng: rng })
}))
})
describe('getAddress', function () {

Loading…
Cancel
Save