|
|
@ -5760,7 +5760,6 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should select smaller utxos if within fee constraints', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [1, '800bit', '800bit', '800bit'], function() { |
|
|
|
var txOpts = { |
|
|
@ -5799,6 +5798,30 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should account for fee when selecting smallest big utxo', function(done) { |
|
|
|
// log.level = 'debug';
|
|
|
|
var _old = Defaults.UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR; |
|
|
|
Defaults.UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR = 2; |
|
|
|
// The 605 bits input cannot be selected even if it is > 2 * tx amount
|
|
|
|
// because it cannot cover for fee on its own.
|
|
|
|
helpers.stubUtxos(server, wallet, [1, '605bit', '100bit', '100bit', '100bit'], function() { |
|
|
|
var txOpts = { |
|
|
|
outputs: [{ |
|
|
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', |
|
|
|
amount: 300e2, |
|
|
|
}], |
|
|
|
feePerKb: 1200e2, |
|
|
|
}; |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(txp); |
|
|
|
txp.inputs.length.should.equal(1); |
|
|
|
txp.inputs[0].satoshis.should.equal(1e8); |
|
|
|
Defaults.UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR = _old; |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should select smallest big utxo if small utxos exceed maximum fee', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [3, 1, 2].concat(_.times(20, function() { |
|
|
|
return '1000bit'; |
|
|
@ -5958,7 +5981,6 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|