From 76c545b1100aa6afe3278e4975b0b6d8ac3a698f Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 5 Aug 2015 10:44:09 -0300 Subject: [PATCH] add WALLET_NOT_COMPLETE --- lib/errors/errordefinitions.js | 2 +- lib/server.js | 10 ++++------ test/integration/server.js | 5 +++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/errors/errordefinitions.js b/lib/errors/errordefinitions.js index 0ea050e..43b8ad3 100644 --- a/lib/errors/errordefinitions.js +++ b/lib/errors/errordefinitions.js @@ -25,7 +25,7 @@ var errors = { UPGRADE_NEEDED: 'Client app needs to be upgraded', WALLET_ALREADY_EXISTS: 'Wallet already exists', WALLET_FULL: 'Wallet full', - WALLET_NOT_COMPLETE: 'Replace only works on complete wallets', + WALLET_NOT_COMPLETE: 'Wallet is not complete', WALLET_NOT_FOUND: 'Wallet not found', }; diff --git a/lib/server.js b/lib/server.js index dac6cff..0fc2fe3 100644 --- a/lib/server.js +++ b/lib/server.js @@ -544,8 +544,7 @@ WalletService.prototype.createAddress = function(opts, cb) { self._runLocked(cb, function(cb) { self.getWallet({}, function(err, wallet) { if (err) return cb(err); - if (!wallet.isComplete()) - return cb(new ClientError('Wallet is not complete')); + if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); var address = wallet.createAddress(false); @@ -977,8 +976,7 @@ WalletService.prototype.createTx = function(opts, cb) { self._runLocked(cb, function(cb) { self.getWallet({}, function(err, wallet) { if (err) return cb(err); - if (!wallet.isComplete()) - return cb(new ClientError('Wallet is not complete')); + if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); var copayer = wallet.getCopayer(self.copayerId); var hash; @@ -1665,7 +1663,7 @@ WalletService.prototype.scan = function(opts, cb) { self._runLocked(cb, function(cb) { self.getWallet({}, function(err, wallet) { if (err) return cb(err); - if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); + if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); wallet.scanStatus = 'running'; self.storage.storeWallet(wallet, function(err) { @@ -1724,7 +1722,7 @@ WalletService.prototype.startScan = function(opts, cb) { self.getWallet({}, function(err, wallet) { if (err) return cb(err); - if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); + if (!wallet.isComplete()) return cb(Errors.WALLET_NOT_COMPLETE); setTimeout(function() { self.scan(opts, scanFinished); diff --git a/test/integration/server.js b/test/integration/server.js index 7af341e..e348733 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -1547,7 +1547,8 @@ describe('Wallet service', function() { server.createAddress({}, function(err, address) { should.not.exist(address); should.exist(err); - err.message.should.contain('not complete'); + err.code.should.equal('WALLET_NOT_COMPLETE'); + err.message.should.equal('Wallet is not complete'); done(); }); }); @@ -1578,7 +1579,7 @@ describe('Wallet service', function() { server.createTx(txOpts, function(err, tx) { should.not.exist(tx); should.exist(err); - err.message.should.contain('not complete'); + err.code.should.equal('WALLET_NOT_COMPLETE'); done(); }); });