Merge pull request #453 from matiu/feature/builder01

fix checkMerge, and tests
This commit is contained in:
Manuel Aráoz 2014-07-24 18:50:55 -03:00
commit cbfd30af16
2 changed files with 11 additions and 6 deletions

View File

@ -869,8 +869,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

View File

@ -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');
});