Browse Source

upgrade test dependencies

hk-custom-address
Dave Kerr 7 years ago
parent
commit
b000377fd5
  1. 7
      package.json
  2. 6
      test/ecdsa.js
  3. 12
      test/ecpair.js
  4. 16
      test/hdnode.js

7
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"

6
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

12
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)

16
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')

Loading…
Cancel
Save