From c1a0ec6f5d047b94c6d120ece0f5d9766d76b20b Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Sun, 8 Feb 2015 13:16:41 -0300 Subject: [PATCH] add tests --- lib/server.js | 1 + test/integration.js | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index 829bc2e..98aa301 100644 --- a/lib/server.js +++ b/lib/server.js @@ -91,6 +91,7 @@ CopayServer.prototype.createWallet = function(opts, cb) { Utils.checkRequired(opts, ['name', 'm', 'n', 'pubKey']); + if (_.isEmpty(opts.name)) return cb(new ClientError('Invalid wallet name')); if (!Wallet.verifyCopayerLimits(opts.m, opts.n)) return cb(new ClientError('Invalid combination of required copayers / total copayers')); diff --git a/test/integration.js b/test/integration.js index 038eb81..bd06f35 100644 --- a/test/integration.js +++ b/test/integration.js @@ -253,6 +253,21 @@ describe('Copay server', function() { }); }); + it('should fail to create wallet with no name', function(done) { + var opts = { + name: '', + m: 2, + n: 3, + pubKey: aPubKey, + }; + server.createWallet(opts, function(err, walletId) { + should.not.exist(walletId); + err.should.exist; + err.message.should.contain('name'); + done(); + }); + }); + it('should fail to create wallet with invalid copayer pairs', function(done) { var invalidPairs = [{ m: 0, @@ -753,6 +768,8 @@ describe('Copay server', function() { }); }); + it.skip('should fail to create tx for address of different network', function(done) {}); + it('should fail to create tx when insufficient funds', function(done) { helpers.createUtxos(server, wallet, helpers.toSatoshi([100]), function(utxos) { helpers.stubBlockExplorer(server, utxos); @@ -781,6 +798,10 @@ describe('Copay server', function() { }); }); + it.skip('should fail to create tx when insufficient funds for fee', function(done) {}); + + it.skip('should fail to create tx for dust amount', function(done) {}); + it('should create tx when there is a pending tx and enough UTXOs', function(done) { helpers.createUtxos(server, wallet, helpers.toSatoshi([10.1, 10.2, 10.3]), function(utxos) { helpers.stubBlockExplorer(server, utxos); @@ -858,7 +879,6 @@ describe('Copay server', function() { }); }); }); - }); }); @@ -940,7 +960,6 @@ describe('Copay server', function() { }); }); }); - }); @@ -1031,7 +1050,7 @@ describe('Copay server', function() { }); }); - describe('Multisignature wallet', function() { + describe('Tx proposal workflow', function() { var server, wallet, utxos; beforeEach(function(done) { helpers.createAndJoinWallet(2, 3, function(s, w) { @@ -1071,7 +1090,9 @@ describe('Copay server', function() { }); }); - it.skip('tx proposals should not be broadcast until quorum is reached', function(done) {}); + it.skip('tx proposals should not be broadcast until quorum is reached', function(done) { + + }); it.skip('tx proposals should accept as many rejections as possible without finally rejecting', function(done) {});