When disableMoreOutputThanInput is set for getSerializationError, also disable the fee checks as the concept of a fee is meaningless when unspent output value is negative. This also allows for removing the opts from buildSkipTest again and simplifying the skip test for disableMoreOutputThanInput.

This commit is contained in:
David de Kloet 2015-05-20 21:56:52 +02:00 committed by Braydon Fuller
parent dc07788e53
commit ac2fbe2777
2 changed files with 10 additions and 12 deletions

View File

@ -205,6 +205,10 @@ Transaction.prototype._isInvalidSatoshis = function() {
};
Transaction.prototype._hasFeeError = function(opts) {
if (opts.disableMoreOutputThanInput) {
// The concept of a fee is meaningless when the unspent output value is negative.
return;
}
return this._isFeeDifferent() ||
this._isFeeTooLarge(opts) ||
this._isFeeTooSmall(opts);

View File

@ -398,22 +398,20 @@ describe('Transaction', function() {
}).to.throw(errors.Transaction.InvalidOutputAmountSum);
});
describe('skipping checks', function() {
var buildSkipTest = function(builder, check, expectedError, opts) {
var buildSkipTest = function(builder, check, expectedError) {
return function() {
var transaction = new Transaction();
transaction.from(simpleUtxoWith1BTC);
builder(transaction);
var options = opts || {};
var options = {};
options[check] = true;
expect(function() {
return transaction.serialize(options);
}).not.to.throw();
options[check] = false;
expect(function() {
return transaction.serialize(options);
return transaction.serialize();
}).to.throw(expectedError);
};
};
@ -452,13 +450,9 @@ describe('Transaction', function() {
function(transaction) {
return transaction
.to(toAddress, 10000000000000)
.change(changeAddress);
}, 'disableMoreOutputThanInput',
errors.Transaction.InvalidOutputAmountSum,
{
'disableSmallFees': true,
'disableIsFullySigned': true
}
.change(changeAddress)
.sign(privateKey);
}, 'disableMoreOutputThanInput', errors.Transaction.InvalidOutputAmountSum
));
});
});