add WALLET_NOT_FOUND

This commit is contained in:
Ivan Socolsky 2015-08-05 10:41:03 -03:00
parent 6270a326b7
commit 03fe48209e
3 changed files with 6 additions and 5 deletions

View File

@ -26,6 +26,7 @@ var errors = {
WALLET_ALREADY_EXISTS: 'Wallet already exists',
WALLET_FULL: 'Wallet full',
WALLET_NOT_COMPLETE: 'Replace only works on complete wallets',
WALLET_NOT_FOUND: 'Wallet not found',
};
var errorObjects = _.zipObject(_.map(errors, function(msg, code) {

View File

@ -253,7 +253,7 @@ WalletService.prototype.getWallet = function(opts, cb) {
self.storage.fetchWallet(self.walletId, function(err, wallet) {
if (err) return cb(err);
if (!wallet) return cb(new ClientError('Wallet not found'));
if (!wallet) return cb(Errors.WALLET_NOT_FOUND);
return cb(null, wallet);
});
};
@ -285,7 +285,7 @@ WalletService.prototype.replaceTemporaryRequestKey = function(opts, cb) {
self.storage.fetchWallet(self.walletId, function(err, wallet) {
if (err) return cb(err);
if (!wallet) return cb(new ClientError('Wallet not found'));
if (!wallet) return cb(Errors.WALLET_NOT_FOUND);
var hash = WalletUtils.getCopayerHash(opts.name, opts.xPubKey, opts.requestPubKey);
if (!self._verifySignature(hash, opts.copayerSignature, wallet.pubKey)) {
return cb(new ClientError());
@ -397,7 +397,7 @@ WalletService.prototype.joinWallet = function(opts, cb) {
self.storage.fetchWallet(opts.walletId, function(err, wallet) {
if (err) return cb(err);
if (!wallet) return cb(new ClientError('Wallet not found'));
if (!wallet) return cb(Errors.WALLET_NOT_FOUND);
var hash = WalletUtils.getCopayerHash(opts.name, opts.xPubKey, opts.requestPubKey);
if (!self._verifySignature(hash, opts.copayerSignature, wallet.pubKey)) {

View File

@ -3178,7 +3178,7 @@ describe('Wallet service', function() {
should.not.exist(err);
server.getWallet({}, function(err, w) {
should.exist(err);
err.message.should.equal('Wallet not found');
err.code.should.equal('WALLET_NOT_FOUND');
should.not.exist(w);
async.parallel([
@ -3237,7 +3237,7 @@ describe('Wallet service', function() {
function(next) {
server.getWallet({}, function(err, wallet) {
should.exist(err);
err.message.should.contain('not found');
err.code.should.equal('WALLET_NOT_FOUND');
next();
});
},