From a530c27b2e775dff7a15fdc0c3e2b162366444af Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Wed, 4 Feb 2015 17:43:16 -0300 Subject: [PATCH] More tests on TxProposal --- js/models/TxProposal.js | 6 ------ test/TxProposal.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/js/models/TxProposal.js b/js/models/TxProposal.js index 63d672093..ba3def705 100644 --- a/js/models/TxProposal.js +++ b/js/models/TxProposal.js @@ -154,12 +154,6 @@ TxProposal.prototype._check = function() { }; -TxProposal.prototype.trimForStorage = function() { - // TODO (remove builder / builderObj. utxos, etc) - // - return this; -}; - TxProposal.prototype.addMerchantData = function(merchantData) { preconditions.checkArgument(merchantData.pr); preconditions.checkArgument(merchantData.request_url); diff --git a/test/TxProposal.js b/test/TxProposal.js index 931ce4cfc..3fbab8403 100644 --- a/test/TxProposal.js +++ b/test/TxProposal.js @@ -431,6 +431,17 @@ describe('TxProposal', function() { it('OK', function() { dummyProposal({})._check(); }); + it('FAIL Invalid tx proposal', function() { + var txp = dummyProposal(); + var old = txp.builder.signhash; + txp.builder.signhash = 'ppp'; + (function() { + txp._check(); + }).should.throw('Invalid tx proposal'); + + txp.builder.signhash = old; + }); + it('FAIL ins', function() { (function() { dummyProposal({ @@ -438,6 +449,24 @@ describe('TxProposal', function() { })._check(); }).should.throw('no ins'); }); + + it('FAIL txp too big ', function() { + var txp = dummyProposal(); + var old_builder = txp.builder.build; + + var tx = { + getSize: function() { + return 90000; + } + }; + + txp.builder.build = sinon.stub().returns(tx);; + (function() { + txp._check(); + }).should.throw('BIG: Invalid TX proposal. Too big'); + txp.builder.build = old_builder; + }); + it('FAIL signhash SINGLE', function() { var txp = dummyProposal({ hashtype: Transaction.SIGHASH_SINGLE