From 376d8ad68864e182e32193a5c350e5f3b41189f7 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 26 Feb 2015 10:37:21 -0300 Subject: [PATCH] rebase --- lib/server.js | 20 -------------------- test/integration/server.js | 32 ++++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/server.js b/lib/server.js index 98114f7..46a2efd 100644 --- a/lib/server.js +++ b/lib/server.js @@ -695,26 +695,6 @@ WalletService.prototype.signTx = function(opts, cb) { self._notify('TxProposalFinallyAccepted', { txProposalId: opts.txProposalId, }); -<<<<<<< HEAD -======= - - self._broadcastTx(txp, function(err, txid) { - if (err) return cb(err, txp); - - txp.setBroadcasted(txid); - self.storage.storeTx(self.walletId, txp, function(err) { - if (err) return cb(err); - - self._notify('NewOutgoingTx', { - txProposalId: opts.txProposalId, - txid: txid - }); - return cb(null, txp); - }); - }); - } else { - return cb(null, txp); ->>>>>>> broadcast tests } return cb(null, txp); diff --git a/test/integration/server.js b/test/integration/server.js index cf251e1..dfa701f 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -228,12 +228,11 @@ describe('Copay server', function() { .privateKey .toString(); - var message = 'hola'; - var sig = WalletUtils.signMessage(message, priv); + var sig = WalletUtils.signMessage('hello world', priv); WalletService.getInstanceWithAuth({ copayerId: wallet.copayers[0].id, - message: message, + message: 'hello world', signature: sig, }, function(err, server) { should.not.exist(err); @@ -1274,7 +1273,7 @@ describe('Copay server', function() { txProposalId: txp.id, signatures: signatures, }, function(err, txp) { - should.exist(err); + should.not.exist(err); should.exist(txp); txp.isAccepted().should.be.true; txpid = txp.id; @@ -1313,9 +1312,8 @@ describe('Copay server', function() { should.not.exist(err); server.broadcastTx({ txProposalId: txpid - }, function(err, txid) { + }, function(err) { should.exist(err); - should.not.exist(txid); err.code.should.equal('TXALREADYBROADCASTED'); done(); }); @@ -1330,14 +1328,32 @@ describe('Copay server', function() { should.exist(txp); server.broadcastTx({ txProposalId: txp.id - }, function(err, txid) { + }, function(err) { should.exist(err); - should.not.exist(txid); err.code.should.equal('TXNOTACCEPTED'); done(); }); }); }); + + it('should keep tx as accepted if unable to broadcast it', function(done) { + helpers.stubBroadcastFail(); + server.broadcastTx({ + txProposalId: txpid + }, function(err) { + should.exist(err); + server.getTx({ + id: txpid + }, function(err, txp) { + should.not.exist(err); + should.not.exist(txp.txid); + txp.isBroadcasted().should.be.false; + should.not.exist(txp.broadcastedOn); + txp.isAccepted().should.be.true; + done(); + }); + }); + }); });