|
|
@ -380,6 +380,7 @@ describe('Wallet service', function() { |
|
|
|
describe('Email notifications', function() { |
|
|
|
var server, wallet, mailerStub, emailService; |
|
|
|
|
|
|
|
describe('Shared wallet', function() { |
|
|
|
beforeEach(function(done) { |
|
|
|
helpers.createAndJoinWallet(2, 3, function(s, w) { |
|
|
|
server = s; |
|
|
@ -750,6 +751,68 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('1-of-N wallet', function() { |
|
|
|
beforeEach(function(done) { |
|
|
|
helpers.createAndJoinWallet(1, 2, function(s, w) { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
|
|
|
|
var i = 0; |
|
|
|
async.eachSeries(w.copayers, function(copayer, next) { |
|
|
|
helpers.getAuthServer(copayer.id, function(server) { |
|
|
|
server.savePreferences({ |
|
|
|
email: 'copayer' + (++i) + '@domain.com', |
|
|
|
unit: 'bit', |
|
|
|
}, next); |
|
|
|
}); |
|
|
|
}, function(err) { |
|
|
|
should.not.exist(err); |
|
|
|
|
|
|
|
mailerStub = sinon.stub(); |
|
|
|
mailerStub.sendMail = sinon.stub(); |
|
|
|
mailerStub.sendMail.yields(); |
|
|
|
|
|
|
|
emailService = new EmailService(); |
|
|
|
emailService.start({ |
|
|
|
lockOpts: {}, |
|
|
|
messageBroker: server.messageBroker, |
|
|
|
storage: storage, |
|
|
|
mailer: mailerStub, |
|
|
|
emailOpts: { |
|
|
|
from: 'bws@dummy.net', |
|
|
|
subjectPrefix: '[test wallet]', |
|
|
|
publicTxUrlTemplate: { |
|
|
|
livenet: 'https://insight.bitpay.com/tx/{{txid}}', |
|
|
|
testnet: 'https://test-insight.bitpay.com/tx/{{txid}}', |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, function(err) { |
|
|
|
should.not.exist(err); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should NOT notify copayers a new tx proposal has been created', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [1, 1], function() { |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, TestData.copayers[0].privKey_1H_0, { |
|
|
|
message: 'some message' |
|
|
|
}); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
setTimeout(function() { |
|
|
|
var calls = mailerStub.sendMail.getCalls(); |
|
|
|
calls.length.should.equal(0); |
|
|
|
done(); |
|
|
|
}, 100); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
describe('#getInstance', function() { |
|
|
|
it('should get server instance', function() { |
|
|
|
var server = WalletService.getInstance({ |
|
|
|