mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix testutils.create_accounts
* Don't call ledger_wait inside parallel async loop
This commit is contained in:
committed by
Nik Bougalis
parent
70c2854f7c
commit
ed66b951c6
@@ -213,7 +213,7 @@ function account_dump(remote, account, callback) {
|
|||||||
// get closed ledger hash
|
// get closed ledger hash
|
||||||
// get account root
|
// get account root
|
||||||
// construct a json result
|
// construct a json result
|
||||||
};
|
}
|
||||||
|
|
||||||
function set_account_flag(remote, account, options, callback) {
|
function set_account_flag(remote, account, options, callback) {
|
||||||
if (typeof options === 'number') {
|
if (typeof options === 'number') {
|
||||||
@@ -224,7 +224,9 @@ function set_account_flag(remote, account, options, callback) {
|
|||||||
account: account
|
account: account
|
||||||
}, options));
|
}, options));
|
||||||
|
|
||||||
submit_transaction(tx, callback);
|
// submit_transaction(tx, callback);
|
||||||
|
tx.submit();
|
||||||
|
tx.once('proposed', function(){callback();});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fund_account =
|
exports.fund_account =
|
||||||
@@ -259,7 +261,6 @@ function(remote, src, account, amount, options, callback) {
|
|||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
options = extend({default_rippling: true}, options);
|
|
||||||
|
|
||||||
// Before creating the account, check if it exists in the ledger.
|
// Before creating the account, check if it exists in the ledger.
|
||||||
// If it does, regardless of the balance, fail the test, because
|
// If it does, regardless of the balance, fail the test, because
|
||||||
@@ -272,28 +273,19 @@ function(remote, src, account, amount, options, callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
info.once('error', function(result) {
|
info.once('error', function(result) {
|
||||||
var isNotFoundError = result.error === 'remoteError'
|
var isNotFoundError = result.error === 'remoteError' &&
|
||||||
&& result.remote.error === 'actNotFound';
|
result.remote.error === 'actNotFound';
|
||||||
|
|
||||||
if (!isNotFoundError) {
|
if (!isNotFoundError) {
|
||||||
return callback(result);
|
return callback(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rippled indicated the account does not exist. Create it by funding it.
|
// rippled indicated the account does not exist. Create it by funding it.
|
||||||
fund_account(remote, src, account, amount, function(err) {
|
fund_account(remote, src, account, amount, callback);
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
} else if (!options.default_rippling) {
|
|
||||||
callback();
|
|
||||||
} else {
|
|
||||||
// Set default rippling on trustlines for account
|
|
||||||
set_account_flag(remote, account, 8, callback);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
info.request();
|
info.request();
|
||||||
}
|
};
|
||||||
|
|
||||||
function create_accounts(remote, src, amount, accounts, options, callback) {
|
function create_accounts(remote, src, amount, accounts, options, callback) {
|
||||||
if (typeof options === 'function') {
|
if (typeof options === 'function') {
|
||||||
@@ -305,8 +297,24 @@ function create_accounts(remote, src, amount, accounts, options, callback) {
|
|||||||
|
|
||||||
async.forEach(accounts, function (account, callback) {
|
async.forEach(accounts, function (account, callback) {
|
||||||
create_account(remote, src, account, amount, options, callback);
|
create_account(remote, src, account, amount, options, callback);
|
||||||
}, callback);
|
}, function(){
|
||||||
};
|
options = extend({default_rippling: true}, options);
|
||||||
|
// If we don't want to set default rippling, then bail, otherwise
|
||||||
|
if (!options.default_rippling) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
// close the ledger, so all the accounts always exist, then
|
||||||
|
remote.ledger_accept(function(){
|
||||||
|
// set the default rippling flag, on all the accounts
|
||||||
|
async.forEach(accounts, function(account, callback){
|
||||||
|
set_account_flag(remote, account, 8, callback);
|
||||||
|
}, function(){
|
||||||
|
remote.ledger_accept(function(){callback();});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function credit_limit(remote, src, amount, callback) {
|
function credit_limit(remote, src, amount, callback) {
|
||||||
assert.strictEqual(arguments.length, 4);
|
assert.strictEqual(arguments.length, 4);
|
||||||
|
|||||||
Reference in New Issue
Block a user