fix checkMerge, and tests

This commit is contained in:
Matias Alejo Garcia 2014-07-24 18:46:12 -03:00
parent 494fc25d27
commit 8660120add
2 changed files with 11 additions and 6 deletions

View File

@ -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

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