Browse Source

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.

patch-2
David de Kloet 10 years ago
committed by Braydon Fuller
parent
commit
ac2fbe2777
  1. 4
      lib/transaction/transaction.js
  2. 18
      test/transaction/transaction.js

4
lib/transaction/transaction.js

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

18
test/transaction/transaction.js

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

Loading…
Cancel
Save