|
|
@ -4,6 +4,8 @@ |
|
|
|
var assert = require('assert') |
|
|
|
var ecdsa = require('../src/ecdsa') |
|
|
|
var sinon = require('sinon') |
|
|
|
var sinonTest = require('sinon-test') |
|
|
|
var setupTest = sinonTest(sinon) |
|
|
|
|
|
|
|
var BigInteger = require('bigi') |
|
|
|
var ECPair = require('../src/ecpair') |
|
|
@ -79,7 +81,7 @@ describe('HDNode', function () { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
it('throws if IL is not within interval [1, n - 1] | IL === 0', sinon.test(function () { |
|
|
|
it('throws if IL is not within interval [1, n - 1] | IL === 0', setupTest(function () { |
|
|
|
this.mock(BigInteger).expects('fromBuffer') |
|
|
|
.once().returns(BigInteger.ZERO) |
|
|
|
|
|
|
@ -88,7 +90,7 @@ describe('HDNode', function () { |
|
|
|
}, /Private key must be greater than 0/) |
|
|
|
})) |
|
|
|
|
|
|
|
it('throws if IL is not within interval [1, n - 1] | IL === n', sinon.test(function () { |
|
|
|
it('throws if IL is not within interval [1, n - 1] | IL === n', setupTest(function () { |
|
|
|
this.mock(BigInteger).expects('fromBuffer') |
|
|
|
.once().returns(curve.n) |
|
|
|
|
|
|
@ -122,7 +124,7 @@ describe('HDNode', function () { |
|
|
|
}) |
|
|
|
|
|
|
|
describe('getAddress', function () { |
|
|
|
it('wraps keyPair.getAddress', sinon.test(function () { |
|
|
|
it('wraps keyPair.getAddress', setupTest(function () { |
|
|
|
this.mock(keyPair).expects('getAddress') |
|
|
|
.once().withArgs().returns('foobar') |
|
|
|
|
|
|
@ -131,7 +133,7 @@ describe('HDNode', function () { |
|
|
|
}) |
|
|
|
|
|
|
|
describe('getNetwork', function () { |
|
|
|
it('wraps keyPair.getNetwork', sinon.test(function () { |
|
|
|
it('wraps keyPair.getNetwork', setupTest(function () { |
|
|
|
this.mock(keyPair).expects('getNetwork') |
|
|
|
.once().withArgs().returns('network') |
|
|
|
|
|
|
@ -140,7 +142,7 @@ describe('HDNode', function () { |
|
|
|
}) |
|
|
|
|
|
|
|
describe('getPublicKeyBuffer', function () { |
|
|
|
it('wraps keyPair.getPublicKeyBuffer', sinon.test(function () { |
|
|
|
it('wraps keyPair.getPublicKeyBuffer', setupTest(function () { |
|
|
|
this.mock(keyPair).expects('getPublicKeyBuffer') |
|
|
|
.once().withArgs().returns('pubKeyBuffer') |
|
|
|
|
|
|
@ -149,7 +151,7 @@ describe('HDNode', function () { |
|
|
|
}) |
|
|
|
|
|
|
|
describe('sign', function () { |
|
|
|
it('wraps keyPair.sign', sinon.test(function () { |
|
|
|
it('wraps keyPair.sign', setupTest(function () { |
|
|
|
this.mock(keyPair).expects('sign') |
|
|
|
.once().withArgs(hash).returns('signed') |
|
|
|
|
|
|
@ -164,7 +166,7 @@ describe('HDNode', function () { |
|
|
|
signature = hd.sign(hash) |
|
|
|
}) |
|
|
|
|
|
|
|
it('wraps keyPair.verify', sinon.test(function () { |
|
|
|
it('wraps keyPair.verify', setupTest(function () { |
|
|
|
this.mock(keyPair).expects('verify') |
|
|
|
.once().withArgs(hash, signature).returns('verified') |
|
|
|
|
|
|
|