|
@ -3696,7 +3696,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
it('should be able to get send max info on empty wallet', function(done) { |
|
|
it('should be able to get send max info on 0 utxo wallet', function(done) { |
|
|
server.getSendMaxInfo({ |
|
|
server.getSendMaxInfo({ |
|
|
feePerKb: 10000, |
|
|
feePerKb: 10000, |
|
|
returnInputs: true, |
|
|
returnInputs: true, |
|
@ -3707,6 +3707,10 @@ describe('Wallet service', function() { |
|
|
info.amount.should.equal(0); |
|
|
info.amount.should.equal(0); |
|
|
info.fee.should.equal(0); |
|
|
info.fee.should.equal(0); |
|
|
info.inputs.should.be.empty; |
|
|
info.inputs.should.be.empty; |
|
|
|
|
|
info.utxosBelowFee.should.equal(0); |
|
|
|
|
|
info.amountBelowFee.should.equal(0); |
|
|
|
|
|
info.utxosAboveMaxSize.should.equal(0); |
|
|
|
|
|
info.amountAboveMaxSize.should.equal(0); |
|
|
done(); |
|
|
done(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -3722,6 +3726,10 @@ describe('Wallet service', function() { |
|
|
info.size.should.equal(1304); |
|
|
info.size.should.equal(1304); |
|
|
info.fee.should.equal(info.size * 10000 / 1000.); |
|
|
info.fee.should.equal(info.size * 10000 / 1000.); |
|
|
info.amount.should.equal(1e8 - info.fee); |
|
|
info.amount.should.equal(1e8 - info.fee); |
|
|
|
|
|
info.utxosBelowFee.should.equal(0); |
|
|
|
|
|
info.amountBelowFee.should.equal(0); |
|
|
|
|
|
info.utxosAboveMaxSize.should.equal(0); |
|
|
|
|
|
info.amountAboveMaxSize.should.equal(0); |
|
|
sendTx(info, done); |
|
|
sendTx(info, done); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -3745,7 +3753,6 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should exclude unconfirmed inputs', function(done) { |
|
|
it('should exclude unconfirmed inputs', function(done) { |
|
|
helpers.stubUtxos(server, wallet, ['u0.1', 0.2, 0.3, 0.4], function() { |
|
|
helpers.stubUtxos(server, wallet, ['u0.1', 0.2, 0.3, 0.4], function() { |
|
|
server.getSendMaxInfo({ |
|
|
server.getSendMaxInfo({ |
|
@ -3791,7 +3798,7 @@ describe('Wallet service', function() { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
it('should ignore utxos not contributing to total amount (below their cost in fee)', function(done) { |
|
|
it('should ignore utxos not contributing to total amount (below their cost in fee)', function(done) { |
|
|
helpers.stubUtxos(server, wallet, ['u0.1', 0.2, 0.3, 0.4, 0.000001, 0.0002, 0.0003], function() { |
|
|
helpers.stubUtxos(server, wallet, ['u0.1', 0.2, 0.3, 0.4, '1bit', '100bit', '200bit'], function() { |
|
|
server.getSendMaxInfo({ |
|
|
server.getSendMaxInfo({ |
|
|
feePerKb: 0.001e8, |
|
|
feePerKb: 0.001e8, |
|
|
returnInputs: true, |
|
|
returnInputs: true, |
|
@ -3802,6 +3809,8 @@ describe('Wallet service', function() { |
|
|
info.size.should.equal(1304); |
|
|
info.size.should.equal(1304); |
|
|
info.fee.should.equal(info.size * 0.001e8 / 1000.); |
|
|
info.fee.should.equal(info.size * 0.001e8 / 1000.); |
|
|
info.amount.should.equal(1e8 - info.fee); |
|
|
info.amount.should.equal(1e8 - info.fee); |
|
|
|
|
|
info.utxosBelowFee.should.equal(3); |
|
|
|
|
|
info.amountBelowFee.should.equal(301e2); |
|
|
server.getSendMaxInfo({ |
|
|
server.getSendMaxInfo({ |
|
|
feePerKb: 0.0001e8, |
|
|
feePerKb: 0.0001e8, |
|
|
returnInputs: true, |
|
|
returnInputs: true, |
|
@ -3811,12 +3820,32 @@ describe('Wallet service', function() { |
|
|
info.inputs.length.should.equal(6); |
|
|
info.inputs.length.should.equal(6); |
|
|
info.size.should.equal(1907); |
|
|
info.size.should.equal(1907); |
|
|
info.fee.should.equal(info.size * 0.0001e8 / 1000.); |
|
|
info.fee.should.equal(info.size * 0.0001e8 / 1000.); |
|
|
info.amount.should.equal(1.0005e8 - info.fee); |
|
|
info.amount.should.equal(1.0003e8 - info.fee); |
|
|
|
|
|
info.utxosBelowFee.should.equal(1); |
|
|
|
|
|
info.amountBelowFee.should.equal(1e2); |
|
|
sendTx(info, done); |
|
|
sendTx(info, done); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
it('should work when all inputs are below their cost in fee', function(done) { |
|
|
|
|
|
helpers.stubUtxos(server, wallet, ['u 10bit', '10bit', '20bit'], function() { |
|
|
|
|
|
server.getSendMaxInfo({ |
|
|
|
|
|
feePerKb: 500e2, |
|
|
|
|
|
returnInputs: true, |
|
|
|
|
|
}, function(err, info) { |
|
|
|
|
|
should.not.exist(err); |
|
|
|
|
|
should.exist(info); |
|
|
|
|
|
info.inputs.should.be.empty; |
|
|
|
|
|
info.size.should.equal(0); |
|
|
|
|
|
info.fee.should.equal(0); |
|
|
|
|
|
info.amount.should.equal(0); |
|
|
|
|
|
info.utxosBelowFee.should.equal(3); |
|
|
|
|
|
info.amountBelowFee.should.equal(40e2); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
it('should not go beyond max tx size', function(done) { |
|
|
it('should not go beyond max tx size', function(done) { |
|
|
var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB; |
|
|
var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB; |
|
|
Defaults.MAX_TX_SIZE_IN_KB = 2; |
|
|
Defaults.MAX_TX_SIZE_IN_KB = 2; |
|
@ -3829,6 +3858,8 @@ describe('Wallet service', function() { |
|
|
should.exist(info); |
|
|
should.exist(info); |
|
|
info.size.should.be.below(2000); |
|
|
info.size.should.be.below(2000); |
|
|
info.inputs.length.should.be.below(9); |
|
|
info.inputs.length.should.be.below(9); |
|
|
|
|
|
info.utxosAboveMaxSize.should.equal(3); |
|
|
|
|
|
info.amountAboveMaxSize.should.equal(3e8); |
|
|
Defaults.MAX_TX_SIZE_IN_KB = _oldDefault; |
|
|
Defaults.MAX_TX_SIZE_IN_KB = _oldDefault; |
|
|
sendTx(info, done); |
|
|
sendTx(info, done); |
|
|
}); |
|
|
}); |
|
|