prioritize error messages
This commit is contained in:
parent
69ae9a63e7
commit
3bf7b4d51f
|
@ -587,12 +587,12 @@ WalletService.prototype.joinWallet = function(opts, cb) {
|
|||
return cb(new ClientError());
|
||||
}
|
||||
|
||||
if (wallet.copayers.length == wallet.n) return cb(Errors.WALLET_FULL);
|
||||
|
||||
if (_.find(wallet.copayers, {
|
||||
xPubKey: opts.xPubKey
|
||||
})) return cb(Errors.COPAYER_IN_WALLET);
|
||||
|
||||
if (wallet.copayers.length == wallet.n) return cb(Errors.WALLET_FULL);
|
||||
|
||||
self._addCopayerToWallet(wallet, opts, cb);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -940,8 +940,8 @@ describe('Wallet service', function() {
|
|||
server = new WalletService();
|
||||
var walletOpts = {
|
||||
name: 'my wallet',
|
||||
m: 2,
|
||||
n: 3,
|
||||
m: 1,
|
||||
n: 2,
|
||||
pubKey: TestData.keyPair.pub,
|
||||
};
|
||||
server.createWallet(walletOpts, function(err, wId) {
|
||||
|
@ -1054,6 +1054,23 @@ describe('Wallet service', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return copayer in wallet error before full wallet', function(done) {
|
||||
helpers.createAndJoinWallet(1, 1, function(s, wallet) {
|
||||
var copayerOpts = helpers.getSignedCopayerOpts({
|
||||
walletId: wallet.id,
|
||||
name: 'me',
|
||||
xPubKey: TestData.copayers[0].xPubKey_44H_0H_0H,
|
||||
requestPubKey: TestData.copayers[0].pubKey_1H_0,
|
||||
supportBIP44AndP2PKH: true,
|
||||
});
|
||||
server.joinWallet(copayerOpts, function(err) {
|
||||
should.exist(err);
|
||||
err.code.should.equal('COPAYER_IN_WALLET');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail to re-join wallet', function(done) {
|
||||
var copayerOpts = helpers.getSignedCopayerOpts({
|
||||
walletId: walletId,
|
||||
|
|
Loading…
Reference in New Issue