From fdd3b831c038c1aeba04c867532e36b5577bf0ca Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 4 Feb 2015 12:50:23 -0300 Subject: [PATCH] fix insufficient funds error msg & tests --- lib/server.js | 5 +++-- test/integration.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index 81b732b..78fc0ea 100644 --- a/lib/server.js +++ b/lib/server.js @@ -427,8 +427,9 @@ CopayServer.prototype.createTx = function(opts, cb) { }); txp.inputs = self._selectUtxos(txp, utxos); - if (!txp.inputs) - return cb('insufficient funds') + if (!txp.inputs) { + return cb(new CopayError('INSUFFICIENTFUNDS', 'Insufficient funds')); + } // no need to do this now: // TODO remove this comment //self._createRawTx(txp); diff --git a/test/integration.js b/test/integration.js index 27068aa..d631f98 100644 --- a/test/integration.js +++ b/test/integration.js @@ -778,7 +778,8 @@ describe('Copay server', function() { }; server.createTx(txOpts, function(err, tx) { - err.should.contain('insufficient'); + err.code.should.equal('INSUFFICIENTFUNDS'); + err.message.should.equal('Insufficient funds'); server.getPendingTxs({ walletId: '123' }, function(err, txs) { @@ -879,7 +880,8 @@ describe('Copay server', function() { requestSignature: 'dummy', }; server.createTx(txOpts2, function(err, tx) { - err.should.contain('insufficient'); + err.code.should.equal('INSUFFICIENTFUNDS'); + err.message.should.equal('Insufficient funds'); should.not.exist(tx); server.getPendingTxs({ walletId: '123'