fix 0 UTXOs & locked inputs + test

This commit is contained in:
Ivan Socolsky 2016-06-03 20:59:54 -03:00
parent c44f2977f3
commit d642931de2
No known key found for this signature in database
GPG Key ID: FAECE6A05FAA4F56
2 changed files with 24 additions and 1 deletions

View File

@ -922,7 +922,8 @@ WalletService.prototype._getUtxosForCurrentWallet = function(addresses, cb) {
var addressStrs = _.pluck(allAddresses, 'address');
self._getUtxos(addressStrs, function(err, utxos) {
if (err) return next(err);
if (utxos.length == 0) return next(null, []);
if (utxos.length == 0) return cb(null, []);
allUtxos = utxos;
utxoIndex = _.indexBy(allUtxos, utxoKey);
return next();

View File

@ -1416,6 +1416,28 @@ describe('Wallet service', function() {
});
});
});
it('should not fail when getting UTXOs for wallet with 0 UTXOs and pending txps', function(done) {
helpers.stubUtxos(server, wallet, [1, 1], function() {
var txOpts = {
outputs: [{
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
amount: 1e8,
}],
feePerKb: 100e2,
};
helpers.createAndPublishTx(server, txOpts, TestData.copayers[0].privKey_1H_0, function(txp) {
blockchainExplorer.getUtxos = function(addresses, cb) {
return cb(null, []);
};
server.getUtxos({}, function(err, utxos) {
should.not.exist(err);
utxos.should.be.empty;
done();
});
});
});
});
});
describe('Multiple request Pub Keys', function() {