From 8660120addc778f58e12b9f39392e590b453ae85 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 24 Jul 2014 18:46:12 -0300 Subject: [PATCH] fix checkMerge, and tests --- lib/TransactionBuilder.js | 9 +++++++-- test/test.TransactionBuilder.js | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/TransactionBuilder.js b/lib/TransactionBuilder.js index e0cbfe3..954db8e 100644 --- a/lib/TransactionBuilder.js +++ b/lib/TransactionBuilder.js @@ -866,8 +866,13 @@ TransactionBuilder.fromObj = function(data) { TransactionBuilder.prototype._checkMergeability = function(b) { - if (JSON.stringify(this.vanilla) !== JSON.stringify(this.vanilla)) - throw new Error('cannot merge: incompatible builders') + + var toCompare = ['opts', 'hashToScriptMap', 'outs', 'uxtos']; + for (var i in toCompare) { + var k = toCompare[i]; + if (JSON.stringify(this.vanilla[k]) !== JSON.stringify(b.vanilla[k])) + throw new Error('cannot merge: incompatible builders:' + k) + } }; // TODO this could be on Script class diff --git a/test/test.TransactionBuilder.js b/test/test.TransactionBuilder.js index 78e8f44..9dd2327 100644 --- a/test/test.TransactionBuilder.js +++ b/test/test.TransactionBuilder.js @@ -1030,7 +1030,7 @@ describe('TransactionBuilder', function() { }]); (function() { b2.merge(b); - }).should.throw('NTXID'); + }).should.throw('incompatible'); }); it('should check addresses', function() { // bad out @@ -1040,7 +1040,7 @@ describe('TransactionBuilder', function() { }]); (function() { b2.merge(b); - }).should.throw('NTXID'); + }).should.throw('incompatible'); }); @@ -1060,7 +1060,7 @@ describe('TransactionBuilder', function() { (function() { b2.merge(b); - }).should.throw('signhash'); + }).should.throw('incompatible'); }); @@ -1202,7 +1202,7 @@ describe('TransactionBuilder', function() { b2.sign(k2); (function() { b2.merge(b) - }).should.throw('NTXID'); + }).should.throw('incompatible'); });