tests: add HDNode fromSeed throwing tests
This commit is contained in:
parent
5c3d3b61e6
commit
888393fa8f
2 changed files with 24 additions and 4 deletions
test
|
@ -2,6 +2,7 @@
|
|||
/* eslint-disable no-new */
|
||||
|
||||
var assert = require('assert')
|
||||
var ecdsa = require('../src/ecdsa')
|
||||
var sinon = require('sinon')
|
||||
|
||||
var BigInteger = require('bigi')
|
||||
|
@ -9,6 +10,7 @@ var ECPair = require('../src/ecpair')
|
|||
var HDNode = require('../src/hdnode')
|
||||
|
||||
var fixtures = require('./fixtures/hdnode.json')
|
||||
var curve = ecdsa.__curve
|
||||
|
||||
var NETWORKS = require('../src/networks')
|
||||
var NETWORKS_LIST = [] // Object.values(NETWORKS)
|
||||
|
@ -68,6 +70,24 @@ describe('HDNode', function () {
|
|||
})
|
||||
})
|
||||
|
||||
it('throws if IL is not within interval [1, n - 1] | IL === 0', sinon.test(function () {
|
||||
this.mock(BigInteger).expects('fromBuffer')
|
||||
.once().returns(BigInteger.ZERO)
|
||||
|
||||
assert.throws(function () {
|
||||
HDNode.fromSeedHex('ffffffffffffffffffffffffffffffff')
|
||||
}, /Private key must be greater than 0/)
|
||||
}))
|
||||
|
||||
it('throws if IL is not within interval [1, n - 1] | IL === n', sinon.test(function () {
|
||||
this.mock(BigInteger).expects('fromBuffer')
|
||||
.once().returns(curve.n)
|
||||
|
||||
assert.throws(function () {
|
||||
HDNode.fromSeedHex('ffffffffffffffffffffffffffffffff')
|
||||
}, /Private key must be less than the curve order/)
|
||||
}))
|
||||
|
||||
it('throws on low entropy seed', function () {
|
||||
assert.throws(function () {
|
||||
HDNode.fromSeedHex('ffffffffff')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue