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) { 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() || return this._isFeeDifferent() ||
this._isFeeTooLarge(opts) || this._isFeeTooLarge(opts) ||
this._isFeeTooSmall(opts); this._isFeeTooSmall(opts);

18
test/transaction/transaction.js

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

Loading…
Cancel
Save