From b000377fd5434f802fd2971e55d6518ad535a651 Mon Sep 17 00:00:00 2001 From: Dave Kerr Date: Mon, 19 Feb 2018 16:25:56 -0500 Subject: [PATCH] upgrade test dependencies --- package.json | 7 ++++--- test/ecdsa.js | 6 ++++-- test/ecpair.js | 12 +++++++----- test/hdnode.js | 16 +++++++++------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 1fedcae..5594b35 100644 --- a/package.json +++ b/package.json @@ -52,10 +52,11 @@ "bs58": "^4.0.0", "dhttp": "^2.4.2", "minimaldata": "^1.0.2", - "mocha": "^3.1.0", - "nyc": "^10.2.0", + "mocha": "^5.0.1", + "nyc": "^11.4.1", "proxyquire": "^1.4.0", - "sinon": "^1.12.2", + "sinon": "^4.3.0", + "sinon-test": "^2.1.3", "standard": "^9.0.2" }, "license": "MIT" diff --git a/test/ecdsa.js b/test/ecdsa.js index c5b44bc..8d8b17c 100644 --- a/test/ecdsa.js +++ b/test/ecdsa.js @@ -4,6 +4,8 @@ var assert = require('assert') var bcrypto = require('../src/crypto') var ecdsa = require('../src/ecdsa') var sinon = require('sinon') +var sinonTest = require('sinon-test') +var setupTest = sinonTest(sinon) var BigInteger = require('bigi') var ECSignature = require('../src/ecsignature') @@ -28,7 +30,7 @@ describe('ecdsa', function () { }) }) - it('loops until an appropriate k value is found', sinon.test(function () { + it('loops until an appropriate k value is found', setupTest(function () { this.mock(BigInteger).expects('fromBuffer') .exactly(3) .onCall(0).returns(new BigInteger('0')) // < 1 @@ -42,7 +44,7 @@ describe('ecdsa', function () { assert.strictEqual(k.toString(), '42') })) - it('loops until a suitable signature is found', sinon.test(function () { + it('loops until a suitable signature is found', setupTest(function () { this.mock(BigInteger).expects('fromBuffer') .exactly(4) .onCall(0).returns(new BigInteger('0')) // < 1 diff --git a/test/ecpair.js b/test/ecpair.js index 50ef3fb..7972585 100644 --- a/test/ecpair.js +++ b/test/ecpair.js @@ -6,6 +6,8 @@ var ecdsa = require('../src/ecdsa') var ecurve = require('ecurve') var proxyquire = require('proxyquire') var sinon = require('sinon') +var sinonTest = require('sinon-test') +var setupTest = sinonTest(sinon) var BigInteger = require('bigi') var ECPair = require('../src/ecpair') @@ -74,7 +76,7 @@ describe('ECPair', function () { keyPair = new ECPair(BigInteger.ONE) }) - it('wraps Q.getEncoded', sinon.test(function () { + it('wraps Q.getEncoded', setupTest(function () { this.mock(keyPair.Q).expects('getEncoded') .once().withArgs(keyPair.compressed) @@ -165,7 +167,7 @@ describe('ECPair', function () { assert.strictEqual(keyPair.network, NETWORKS.testnet) }) - it('loops until d is within interval [1, n - 1] : 1', sinon.test(function () { + it('loops until d is within interval [1, n - 1] : 1', setupTest(function () { var rng = this.mock() rng.exactly(2) rng.onCall(0).returns(BigInteger.ZERO.toBuffer(32)) // invalid length @@ -174,7 +176,7 @@ describe('ECPair', function () { ECPair.makeRandom({ rng: rng }) })) - it('loops until d is within interval [1, n - 1] : n - 1', sinon.test(function () { + it('loops until d is within interval [1, n - 1] : n - 1', setupTest(function () { var rng = this.mock() rng.exactly(3) rng.onCall(0).returns(BigInteger.ZERO.toBuffer(32)) // < 1 @@ -215,7 +217,7 @@ describe('ECPair', function () { }) describe('signing', function () { - it('wraps ecdsa.sign', sinon.test(function () { + it('wraps ecdsa.sign', setupTest(function () { this.mock(ecdsa).expects('sign') .once().withArgs(hash, keyPair.d) @@ -238,7 +240,7 @@ describe('ECPair', function () { signature = keyPair.sign(hash) }) - it('wraps ecdsa.verify', sinon.test(function () { + it('wraps ecdsa.verify', setupTest(function () { this.mock(ecdsa).expects('verify') .once().withArgs(hash, signature, keyPair.Q) diff --git a/test/hdnode.js b/test/hdnode.js index dfdf03f..944dded 100644 --- a/test/hdnode.js +++ b/test/hdnode.js @@ -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')