From 00c56650da4bb0cfceede1a16d317551bc62f028 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Sun, 8 Feb 2015 11:53:06 -0300 Subject: [PATCH] fix tx creation when wallet not complete --- lib/server.js | 1 + test/integration.js | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index b58c288..829bc2e 100644 --- a/lib/server.js +++ b/lib/server.js @@ -407,6 +407,7 @@ CopayServer.prototype.createTx = function(opts, cb) { self.getWallet({}, function(err, wallet) { if (err) return cb(err); + if (!wallet.isComplete()) return cb(new ClientError('Wallet is not complete')); self._getUtxos(function(err, utxos) { if (err) return cb(err); diff --git a/test/integration.js b/test/integration.js index ced4a41..7d4c57c 100644 --- a/test/integration.js +++ b/test/integration.js @@ -715,7 +715,42 @@ describe('Copay server', function() { }); }); - it.skip('should fail to create tx when wallet is not complete', function(done) {}); + it('should fail to create tx when wallet is not complete', function(done) { + var server = new CopayServer(); + var walletOpts = { + name: 'my wallet', + m: 2, + n: 3, + pubKey: keyPair.pub, + }; + server.createWallet(walletOpts, function(err, walletId) { + should.not.exist(err); + var copayerOpts = { + walletId: walletId, + name: 'me', + xPubKey: aXPubKey, + xPubKeySignature: aXPubKeySignature, + }; + server.joinWallet(copayerOpts, function(err, copayerId) { + should.not.exist(err); + helpers.getAuthServer(copayerId, function(server, wallet) { + var txOpts = { + toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', + amount: helpers.toSatoshi(80), + message: 'some message', + otToken: 'dummy', + requestSignature: 'dummy', + }; + server.createTx(txOpts, function(err, tx) { + should.not.exist(tx); + err.should.exist; + err.message.should.contain('not complete'); + done(); + }); + }); + }); + }); + }); it('should fail to create tx when insufficient funds', function(done) { helpers.createUtxos(server, wallet, helpers.toSatoshi([100]), function(utxos) {