tests: verify ECPair loops until within interval

This commit is contained in:
Daniel Cousens 2015-09-08 23:39:31 +10:00
parent 610f342707
commit f11cce0710

View file

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