From 15798be382d04949849e98cdc4e3e8fdb71c9a0b Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 11 Feb 2015 12:05:21 -0300 Subject: [PATCH] improve error messages --- lib/server.js | 15 ++++++--------- test/integration.js | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/server.js b/lib/server.js index 0b4ae74..14ec1bd 100644 --- a/lib/server.js +++ b/lib/server.js @@ -496,25 +496,22 @@ CopayServer.prototype.removePendingTx = function(opts, cb) { Utils.runLocked(self.walletId, cb, function(cb) { - self.storage.fetchTx(self.walletId, opts.id, function(err, txp) { + self.getTx({ + id: opts.id + }, function(err, txp) { if (err) return cb(err); - if (!txp) - return cb(new ClientError('Transaction proposal not found')); if (!txp.isPending()) return cb(new ClientError('Transaction proposal not pending')); if (txp.creatorId !== self.copayerId) - return cb(new ClientError('Not allowed to erase this TX')); + return cb(new ClientError('Only creators can remove pending proposals')); var actors = txp.getActors(); - if (actors.length > 1) - return cb(new ClientError('Not allowed to erase this TX')); - - if (actors.length == 1 && actors[0] !== self.copayerId) - return cb(new ClientError('Not allowed to erase this TX')); + if (actors.length > 1 || (actors.length == 1 && actors[0] !== self.copayerId)) + return cb(new ClientError('Cannot remove a proposal signed/rejected by other copayers')); self.storage.removeTx(self.walletId, opts.id, cb); }); diff --git a/test/integration.js b/test/integration.js index 1f632a3..e34b5d3 100644 --- a/test/integration.js +++ b/test/integration.js @@ -1310,7 +1310,7 @@ describe('Copay server', function() { server2.removePendingTx({ id: txp.id }, function(err) { - err.message.should.contain('Not allowed'); + err.message.should.contain('creators'); server2.getPendingTxs({}, function(err, txs) { txs.length.should.equal(1); done(); @@ -1330,7 +1330,7 @@ describe('Copay server', function() { server.removePendingTx({ id: txp.id }, function(err) { - err.message.should.contain('Not allowed'); + err.message.should.contain('other copayers'); done(); }); });