Add "Default Ripple" account flag and associated logic:

AccountSet set/clear, asfDefaultRipple = 8

AccountRoot flag, lsfDefaultRipple = 0x00800000

In trustCreate, set no ripple flag if appropriate.

If an account does not have the default ripple flag set,
new ripple lines created as a result of its offers being
taken or people creating trust lines to it have no ripple
set by that account's side automatically

Trust lines can be deleted if the no ripple flag matches
its default setting based on the account's default ripple
setting.

Fix default no-rippling in integration tests.
This commit is contained in:
David Schwartz
2015-03-09 13:43:58 -07:00
committed by Nik Bougalis
parent 9cc8eec773
commit e9381ddeb2
13 changed files with 286 additions and 125 deletions

View File

@@ -215,6 +215,18 @@ function account_dump(remote, account, callback) {
// construct a json result
};
function set_account_flag(remote, account, options, callback) {
if (typeof options === 'number') {
options = { set_flag: options };
}
var tx = remote.createTransaction('AccountSet', extend({
account: account
}, options));
submit_transaction(tx, callback);
}
exports.fund_account =
fund_account =
function(remote, src, account, amount, callback) {
@@ -228,7 +240,7 @@ function(remote, src, account, amount, callback) {
tx.once('proposed', function (result) {
//console.log('proposed: %s', JSON.stringify(result));
callback(result.engine_result === 'tesSUCCESS' ? null : new Error());
callback(result.engine_result === 'tesSUCCESS' ? null : result);
});
tx.once('error', function (result) {
@@ -241,7 +253,14 @@ function(remote, src, account, amount, callback) {
exports.create_account =
create_account =
function(remote, src, account, amount, callback) {
function(remote, src, account, amount, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = extend({default_rippling: true}, options);
// Before creating the account, check if it exists in the ledger.
// If it does, regardless of the balance, fail the test, because
// the ledger is not in the expected state.
@@ -253,25 +272,39 @@ function(remote, src, account, amount, callback) {
});
info.once('error', function(result) {
if (result.error === "remoteError" && result.remote.error === "actNotFound") {
// rippled indicated the account does not exist. Create it by funding it.
fund_account(remote, src, account, amount, callback);
} else {
// Some other error occurred. Pass it up to the callback.
callback(result);
var isNotFoundError = result.error === 'remoteError'
&& result.remote.error === 'actNotFound';
if (!isNotFoundError) {
return callback(result);
}
// rippled indicated the account does not exist. Create it by funding it.
fund_account(remote, src, account, amount, function(err) {
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();
}
function create_accounts(remote, src, amount, accounts, callback) {
assert.strictEqual(arguments.length, 5);
function create_accounts(remote, src, amount, accounts, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
remote.set_account_seq(src, 1);
async.forEach(accounts, function (account, callback) {
create_account(remote, src, account, amount, callback);
create_account(remote, src, account, amount, options, callback);
}, callback);
};
@@ -568,13 +601,18 @@ function ledger_wait(remote, tx) {
;(function nextLedger() {
remote.once('ledger_closed', function() {
if (!tx.finalized) {
setTimeout(nextLedger, isTravis ? 400 : 100);
setTimeout(nextLedger, isTravis ? 200 : 50);
}
});
remote.ledger_accept();
})();
};
function submit_transaction(tx, callback) {
tx.submit(callback);
ledger_wait(tx.remote, tx);
}
exports.account_dump = account_dump;
exports.build_setup = build_setup;
exports.build_teardown = build_teardown;
@@ -595,6 +633,7 @@ exports.verify_offer_not_found = verify_offer_not_found;
exports.verify_owner_count = verify_owner_count;
exports.verify_owner_counts = verify_owner_counts;
exports.ledger_wait = ledger_wait;
exports.submit_transaction = submit_transaction;
process.on('uncaughtException', function() {
Object.keys(server).forEach(function(host) {