fix netTotal bug + test

This commit is contained in:
Ivan Socolsky 2016-03-11 11:13:29 -03:00
parent 6f7488fb59
commit 10b4ff3d15
2 changed files with 17 additions and 4 deletions

View File

@ -1335,7 +1335,7 @@ WalletService.prototype._selectTxInputs = function(txp, utxosToExclude, cb) {
log.debug('Considering ' + smallInputs.length + ' small inputs (' + Utils.formatUtxos(smallInputs) + ')');
var total = 0;
var netTotal = 0;
var netTotal = -baseTxpFee;
var selected = [];
var fee;
var error;

View File

@ -3562,9 +3562,22 @@ describe('Wallet service', function() {
});
});
});
it('should always select inputs as long as there are sufficient funds', function(done) {
helpers.stubUtxos(server, wallet, [80, '50bit', '50bit', '50bit', '50bit', '50bit'], function() {
var txOpts = {
outputs: [{
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
amount: 101e2,
}],
feePerKb: 100e2,
};
server.createTx(txOpts, function(err, txp) {
should.not.exist(err);
should.exist(txp);
done();
});
});
});
});
});