From 610f34270772cc28a18d20ac86e234306e7d6afd Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 8 Sep 2015 23:44:37 +1000 Subject: [PATCH] tests: fix ECPair wrapper tests --- test/ecpair.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/test/ecpair.js b/test/ecpair.js index db378a9..b1ed5cb 100644 --- a/test/ecpair.js +++ b/test/ecpair.js @@ -11,7 +11,7 @@ var BigInteger = require('bigi') var ECPair = require('../src/ecpair') var fixtures = require('./fixtures/ecpair.json') -var secp256k1 = ecurve.getCurveByName('secp256k1') +var curve = ecdsa.__curve var NETWORKS = require('../src/networks') var NETWORKS_LIST = [] // Object.values(NETWORKS) @@ -54,7 +54,7 @@ describe('ECPair', function () { it('throws if public and private key given', function () { var qBuffer = new Buffer('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', 'hex') - var Q = ecurve.Point.decodeFrom(secp256k1, qBuffer) + var Q = ecurve.Point.decodeFrom(curve, qBuffer) assert.throws(function () { new ECPair(BigInteger.ONE, Q) @@ -100,7 +100,7 @@ describe('ECPair', function () { it('wraps Q.getEncoded', sinon.test(function () { this.mock(keyPair.Q).expects('getEncoded') - .once().calledWith(keyPair.compressed) + .once().withArgs(keyPair.compressed) keyPair.getPublicKeyBuffer() })) @@ -160,18 +160,6 @@ describe('ECPair', function () { var keyPair = ProxiedECPair.makeRandom() assert.strictEqual(keyPair.toWIF(), exWIF) }) - - it('passes the options param', sinon.test(function () { - var options = { - compressed: true - } - - // FIXME: waiting on https://github.com/cjohansen/Sinon.JS/issues/613 -// this.mock(ECPair).expects('constructor') -// .once().calledWith(options) - - ECPair.makeRandom(options) - })) }) it('allows a custom RNG to be used', function () { @@ -204,7 +192,7 @@ describe('ECPair', function () { describe('signing', function () { it('wraps ecdsa.sign', sinon.test(function () { this.mock(ecdsa).expects('sign') - .once().calledWith(secp256k1, hash, keyPair.d) + .once().withArgs(hash, keyPair.d) keyPair.sign(hash) })) @@ -227,7 +215,7 @@ describe('ECPair', function () { it('wraps ecdsa.verify', sinon.test(function () { this.mock(ecdsa).expects('verify') - .once().calledWith(secp256k1, hash, signature, keyPair.Q) + .once().withArgs(hash, signature, keyPair.Q) keyPair.verify(hash, signature) }))