Browse Source

Merge pull request #453 from matiu/feature/builder01

fix checkMerge, and tests
patch-2
Manuel Aráoz 11 years ago
parent
commit
cbfd30af16
  1. 9
      lib/TransactionBuilder.js
  2. 8
      test/test.TransactionBuilder.js

9
lib/TransactionBuilder.js

@ -869,8 +869,13 @@ TransactionBuilder.fromObj = function(data) {
TransactionBuilder.prototype._checkMergeability = function(b) { 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 // TODO this could be on Script class

8
test/test.TransactionBuilder.js

@ -1030,7 +1030,7 @@ describe('TransactionBuilder', function() {
}]); }]);
(function() { (function() {
b2.merge(b); b2.merge(b);
}).should.throw('NTXID'); }).should.throw('incompatible');
}); });
it('should check addresses', function() { it('should check addresses', function() {
// bad out // bad out
@ -1040,7 +1040,7 @@ describe('TransactionBuilder', function() {
}]); }]);
(function() { (function() {
b2.merge(b); b2.merge(b);
}).should.throw('NTXID'); }).should.throw('incompatible');
}); });
@ -1060,7 +1060,7 @@ describe('TransactionBuilder', function() {
(function() { (function() {
b2.merge(b); b2.merge(b);
}).should.throw('signhash'); }).should.throw('incompatible');
}); });
@ -1202,7 +1202,7 @@ describe('TransactionBuilder', function() {
b2.sign(k2); b2.sign(k2);
(function() { (function() {
b2.merge(b) b2.merge(b)
}).should.throw('NTXID'); }).should.throw('incompatible');
}); });

Loading…
Cancel
Save