Merge pull request #1007 from hackerrdave/update-sinon
upgrade test dependencies
This commit is contained in:
commit
5b0ccb6f68
5 changed files with 25 additions and 18 deletions
|
@ -52,10 +52,11 @@
|
||||||
"bs58": "^4.0.0",
|
"bs58": "^4.0.0",
|
||||||
"dhttp": "^2.4.2",
|
"dhttp": "^2.4.2",
|
||||||
"minimaldata": "^1.0.2",
|
"minimaldata": "^1.0.2",
|
||||||
"mocha": "^3.1.0",
|
"mocha": "^5.0.1",
|
||||||
"nyc": "^10.2.0",
|
"nyc": "^11.4.1",
|
||||||
"proxyquire": "^1.4.0",
|
"proxyquire": "^1.4.0",
|
||||||
"sinon": "^1.12.2",
|
"sinon": "^4.3.0",
|
||||||
|
"sinon-test": "^2.1.3",
|
||||||
"standard": "^9.0.2"
|
"standard": "^9.0.2"
|
||||||
},
|
},
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe('address', function () {
|
||||||
|
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
baddress.fromOutputScript(script)
|
baddress.fromOutputScript(script)
|
||||||
}, new RegExp(f.script + ' ' + f.exception))
|
}, new RegExp(f.exception))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,6 +4,8 @@ var assert = require('assert')
|
||||||
var bcrypto = require('../src/crypto')
|
var bcrypto = require('../src/crypto')
|
||||||
var ecdsa = require('../src/ecdsa')
|
var ecdsa = require('../src/ecdsa')
|
||||||
var sinon = require('sinon')
|
var sinon = require('sinon')
|
||||||
|
var sinonTest = require('sinon-test')
|
||||||
|
var setupTest = sinonTest(sinon)
|
||||||
|
|
||||||
var BigInteger = require('bigi')
|
var BigInteger = require('bigi')
|
||||||
var ECSignature = require('../src/ecsignature')
|
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')
|
this.mock(BigInteger).expects('fromBuffer')
|
||||||
.exactly(3)
|
.exactly(3)
|
||||||
.onCall(0).returns(new BigInteger('0')) // < 1
|
.onCall(0).returns(new BigInteger('0')) // < 1
|
||||||
|
@ -42,7 +44,7 @@ describe('ecdsa', function () {
|
||||||
assert.strictEqual(k.toString(), '42')
|
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')
|
this.mock(BigInteger).expects('fromBuffer')
|
||||||
.exactly(4)
|
.exactly(4)
|
||||||
.onCall(0).returns(new BigInteger('0')) // < 1
|
.onCall(0).returns(new BigInteger('0')) // < 1
|
||||||
|
|
|
@ -6,6 +6,8 @@ var ecdsa = require('../src/ecdsa')
|
||||||
var ecurve = require('ecurve')
|
var ecurve = require('ecurve')
|
||||||
var proxyquire = require('proxyquire')
|
var proxyquire = require('proxyquire')
|
||||||
var sinon = require('sinon')
|
var sinon = require('sinon')
|
||||||
|
var sinonTest = require('sinon-test')
|
||||||
|
var setupTest = sinonTest(sinon)
|
||||||
|
|
||||||
var BigInteger = require('bigi')
|
var BigInteger = require('bigi')
|
||||||
var ECPair = require('../src/ecpair')
|
var ECPair = require('../src/ecpair')
|
||||||
|
@ -74,7 +76,7 @@ describe('ECPair', function () {
|
||||||
keyPair = new ECPair(BigInteger.ONE)
|
keyPair = new ECPair(BigInteger.ONE)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('wraps Q.getEncoded', sinon.test(function () {
|
it('wraps Q.getEncoded', setupTest(function () {
|
||||||
this.mock(keyPair.Q).expects('getEncoded')
|
this.mock(keyPair.Q).expects('getEncoded')
|
||||||
.once().withArgs(keyPair.compressed)
|
.once().withArgs(keyPair.compressed)
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ describe('ECPair', function () {
|
||||||
assert.strictEqual(keyPair.network, NETWORKS.testnet)
|
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()
|
var rng = this.mock()
|
||||||
rng.exactly(2)
|
rng.exactly(2)
|
||||||
rng.onCall(0).returns(BigInteger.ZERO.toBuffer(32)) // invalid length
|
rng.onCall(0).returns(BigInteger.ZERO.toBuffer(32)) // invalid length
|
||||||
|
@ -174,7 +176,7 @@ describe('ECPair', function () {
|
||||||
ECPair.makeRandom({ rng: rng })
|
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()
|
var rng = this.mock()
|
||||||
rng.exactly(3)
|
rng.exactly(3)
|
||||||
rng.onCall(0).returns(BigInteger.ZERO.toBuffer(32)) // < 1
|
rng.onCall(0).returns(BigInteger.ZERO.toBuffer(32)) // < 1
|
||||||
|
@ -215,7 +217,7 @@ describe('ECPair', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('signing', function () {
|
describe('signing', function () {
|
||||||
it('wraps ecdsa.sign', sinon.test(function () {
|
it('wraps ecdsa.sign', setupTest(function () {
|
||||||
this.mock(ecdsa).expects('sign')
|
this.mock(ecdsa).expects('sign')
|
||||||
.once().withArgs(hash, keyPair.d)
|
.once().withArgs(hash, keyPair.d)
|
||||||
|
|
||||||
|
@ -238,7 +240,7 @@ describe('ECPair', function () {
|
||||||
signature = keyPair.sign(hash)
|
signature = keyPair.sign(hash)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('wraps ecdsa.verify', sinon.test(function () {
|
it('wraps ecdsa.verify', setupTest(function () {
|
||||||
this.mock(ecdsa).expects('verify')
|
this.mock(ecdsa).expects('verify')
|
||||||
.once().withArgs(hash, signature, keyPair.Q)
|
.once().withArgs(hash, signature, keyPair.Q)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var ecdsa = require('../src/ecdsa')
|
var ecdsa = require('../src/ecdsa')
|
||||||
var sinon = require('sinon')
|
var sinon = require('sinon')
|
||||||
|
var sinonTest = require('sinon-test')
|
||||||
|
var setupTest = sinonTest(sinon)
|
||||||
|
|
||||||
var BigInteger = require('bigi')
|
var BigInteger = require('bigi')
|
||||||
var ECPair = require('../src/ecpair')
|
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')
|
this.mock(BigInteger).expects('fromBuffer')
|
||||||
.once().returns(BigInteger.ZERO)
|
.once().returns(BigInteger.ZERO)
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ describe('HDNode', function () {
|
||||||
}, /Private key must be greater than 0/)
|
}, /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')
|
this.mock(BigInteger).expects('fromBuffer')
|
||||||
.once().returns(curve.n)
|
.once().returns(curve.n)
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ describe('HDNode', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getAddress', function () {
|
describe('getAddress', function () {
|
||||||
it('wraps keyPair.getAddress', sinon.test(function () {
|
it('wraps keyPair.getAddress', setupTest(function () {
|
||||||
this.mock(keyPair).expects('getAddress')
|
this.mock(keyPair).expects('getAddress')
|
||||||
.once().withArgs().returns('foobar')
|
.once().withArgs().returns('foobar')
|
||||||
|
|
||||||
|
@ -131,7 +133,7 @@ describe('HDNode', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getNetwork', function () {
|
describe('getNetwork', function () {
|
||||||
it('wraps keyPair.getNetwork', sinon.test(function () {
|
it('wraps keyPair.getNetwork', setupTest(function () {
|
||||||
this.mock(keyPair).expects('getNetwork')
|
this.mock(keyPair).expects('getNetwork')
|
||||||
.once().withArgs().returns('network')
|
.once().withArgs().returns('network')
|
||||||
|
|
||||||
|
@ -140,7 +142,7 @@ describe('HDNode', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getPublicKeyBuffer', function () {
|
describe('getPublicKeyBuffer', function () {
|
||||||
it('wraps keyPair.getPublicKeyBuffer', sinon.test(function () {
|
it('wraps keyPair.getPublicKeyBuffer', setupTest(function () {
|
||||||
this.mock(keyPair).expects('getPublicKeyBuffer')
|
this.mock(keyPair).expects('getPublicKeyBuffer')
|
||||||
.once().withArgs().returns('pubKeyBuffer')
|
.once().withArgs().returns('pubKeyBuffer')
|
||||||
|
|
||||||
|
@ -149,7 +151,7 @@ describe('HDNode', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('sign', function () {
|
describe('sign', function () {
|
||||||
it('wraps keyPair.sign', sinon.test(function () {
|
it('wraps keyPair.sign', setupTest(function () {
|
||||||
this.mock(keyPair).expects('sign')
|
this.mock(keyPair).expects('sign')
|
||||||
.once().withArgs(hash).returns('signed')
|
.once().withArgs(hash).returns('signed')
|
||||||
|
|
||||||
|
@ -164,7 +166,7 @@ describe('HDNode', function () {
|
||||||
signature = hd.sign(hash)
|
signature = hd.sign(hash)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('wraps keyPair.verify', sinon.test(function () {
|
it('wraps keyPair.verify', setupTest(function () {
|
||||||
this.mock(keyPair).expects('verify')
|
this.mock(keyPair).expects('verify')
|
||||||
.once().withArgs(hash, signature).returns('verified')
|
.once().withArgs(hash, signature).returns('verified')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue