Browse Source

lodash each needs return-false to break out of loop, travis timeout debug

activeAddress
Gregg Zigler 10 years ago
parent
commit
c64790f014
  1. 31
      lib/server.js
  2. 1
      test/integration/server.js

31
lib/server.js

@ -878,23 +878,30 @@ WalletService.prototype.createTx = function(opts, cb) {
var outputs = (opts.type == Model.TxProposal.Types.MULTIPLEOUTPUTS)
? opts.outputs
: [ { toAddress: opts.toAddress, amount: opts.amount } ];
// _.each(outputs) fails here, causes multiple callbacks to be executed
// use for-loop instead
for (var i = 0; i < outputs.length; i++) {
var output = outputs[i];
_.each(outputs, function(output) {
output.valid = false;
var toAddress = {};
try {
toAddress = new Bitcore.Address(output.toAddress);
} catch (ex) {
return cb(new ClientError('INVALIDADDRESS', 'Invalid address'));
cb(new ClientError('INVALIDADDRESS', 'Invalid address'));
return false;
}
if (toAddress.network != wallet.getNetworkName())
return cb(new ClientError('INVALIDADDRESS', 'Incorrect address network'));
if (output.amount <= 0)
return cb(new ClientError('Invalid amount'));
if (output.amount < Bitcore.Transaction.DUST_AMOUNT)
return cb(new ClientError('DUSTAMOUNT', 'Amount below dust threshold'));
}
if (toAddress.network != wallet.getNetworkName()) {
cb(new ClientError('INVALIDADDRESS', 'Incorrect address network'));
return false;
}
if (output.amount <= 0) {
cb(new ClientError('Invalid amount'));
return false;
}
if (output.amount < Bitcore.Transaction.DUST_AMOUNT) {
cb(new ClientError('DUSTAMOUNT', 'Amount below dust threshold'));
return false;
}
output.valid = true;
});
if (_.any(outputs, 'valid', false)) return;
var changeAddress = wallet.createAddress(true);

1
test/integration/server.js

@ -1770,6 +1770,7 @@ describe('Wallet service', function() {
});
it('should follow backoff time after consecutive rejections', function(done) {
this.timeout(10000); // find out why travis is timing out
async.series([
function(next) {

Loading…
Cancel
Save