From 71d97f34f92503254667b630fd99422ec43571e9 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Mon, 1 Jun 2015 12:16:34 -0300 Subject: [PATCH] add amount to outgoingTx email --- lib/server.js | 3 +- lib/templates/new_outgoing_tx.plain | 2 +- test/integration/server.js | 55 ++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/lib/server.js b/lib/server.js index 9f0c4f5..bfa38a2 100644 --- a/lib/server.js +++ b/lib/server.js @@ -991,7 +991,8 @@ WalletService.prototype.broadcastTx = function(opts, cb) { self._notify('NewOutgoingTx', { txProposalId: opts.txProposalId, - txid: txid + txid: txid, + amount: txp.amount, }, function() { return cb(null, txp); }); diff --git a/lib/templates/new_outgoing_tx.plain b/lib/templates/new_outgoing_tx.plain index a5cba78..38ece4f 100644 --- a/lib/templates/new_outgoing_tx.plain +++ b/lib/templates/new_outgoing_tx.plain @@ -1,2 +1,2 @@ <%= subjectPrefix %>Payment sent -A Payment has been sent from your wallet <%= walletName %>. +A Payment of <%= amount %> has been sent from your wallet <%= walletName %>. diff --git a/test/integration/server.js b/test/integration/server.js index d1fafe9..d8924cc 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -329,7 +329,60 @@ describe('Wallet service', function() { }); }); - it.only('should notify copayers of incoming txs', function(done) { + it('should notify copayers a new outgoing tx has been created', function(done) { + helpers.stubUtxos(server, wallet, [1, 1], function() { + var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); + + var txpId; + async.waterfall([ + + function(next) { + server.createTx(txOpts, next); + }, + function(txp, next) { + txpId = txp.id; + async.eachSeries(_.range(2), function(i, next) { + var copayer = TestData.copayers[i]; + helpers.getAuthServer(copayer.id, function(server) { + var signatures = helpers.clientSign(txp, copayer.xPrivKey); + server.signTx({ + txProposalId: txp.id, + signatures: signatures, + }, next); + }); + }, next); + }, + function(next) { + helpers.stubBroadcast('999'); + server.broadcastTx({ + txProposalId: txpId, + }, next); + }, + ], function(err) { + should.not.exist(err); + + setTimeout(function() { + var calls = mailerStub.sendMail.getCalls(); + var emails = _.map(_.takeRight(calls, 3), function(c) { + return c.args[0]; + }); + _.difference(['copayer0@domain.com', 'copayer1@domain.com', 'copayer2@domain.com'], _.pluck(emails, 'to')).should.be.empty; + var one = emails[0]; + one.from.should.equal('bws@dummy.net'); + one.subject.should.contain('Payment sent'); + one.text.should.contain(wallet.name); + one.text.should.contain('800,000'); + server.storage.fetchUnsentEmails(function(err, unsent) { + should.not.exist(err); + unsent.should.be.empty; + done(); + }); + }, 100); + }); + }); + }); + + it('should notify copayers of incoming txs', function(done) { server.createAddress({}, function(err, address) { should.not.exist(err);