Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
[TASK] Support DefaultRipple flag (RLJS-280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Cohen committed Mar 20, 2015
1 parent de8f8ee commit 486f7bf
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
20 changes: 11 additions & 9 deletions api/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ var RestToTxConverter = require('./../lib/rest-to-tx-converter.js');
const InvalidRequestError = errors.InvalidRequestError;

const AccountRootFlags = {
PasswordSpent: { name: 'password_spent', value: 0x00010000 },
RequireDestTag: { name: 'require_destination_tag', value: 0x00020000 },
RequireAuth: { name: 'require_authorization', value: 0x00040000 },
DisallowXRP: { name: 'disallow_xrp', value: 0x00080000 },
DisableMaster: { name: 'disable_master', value: 0x00100000 },
NoFreeze: { name: 'no_freeze', value: 0x00200000 },
GlobalFreeze: { name: 'global_freeze', value: 0x00400000 }
PasswordSpent: { name: 'password_spent', value: ripple.Remote.flags.account_root.PasswordSpent },
RequireDestTag: { name: 'require_destination_tag', value: ripple.Remote.flags.account_root.RequireDestTag },
RequireAuth: { name: 'require_authorization', value: ripple.Remote.flags.account_root.RequireAuth },
DisallowXRP: { name: 'disallow_xrp', value: ripple.Remote.flags.account_root.DisallowXRP },
DisableMaster: { name: 'disable_master', value: ripple.Remote.flags.account_root.DisableMaster },
NoFreeze: { name: 'no_freeze', value: 0x00200000},
GlobalFreeze: { name: 'global_freeze', value: 0x00400000},
DefaultRipple: { name: 'default_ripple', value: ripple.Remote.flags.account_root.DefaultRipple }
};

const AccountRootFields = {
Expand All @@ -35,7 +36,8 @@ const AccountRootFields = {

const AccountSetIntFlags = {
NoFreeze: { name: 'no_freeze', value: ripple.Transaction.set_clear_flags.AccountSet.asfNoFreeze },
GlobalFreeze: { name: 'global_freeze', value: ripple.Transaction.set_clear_flags.AccountSet.asfGlobalFreeze }
GlobalFreeze: { name: 'global_freeze', value: ripple.Transaction.set_clear_flags.AccountSet.asfGlobalFreeze },
DefaultRipple: { name: 'default_ripple', value: ripple.Transaction.set_clear_flags.AccountSet.asfDefaultRipple }
};

const AccountSetFlags = {
Expand Down Expand Up @@ -328,4 +330,4 @@ module.exports = {
change: changeSettings,
AccountSetIntFlags: AccountSetIntFlags,
AccountRootFields: AccountRootFields
};
};
5 changes: 3 additions & 2 deletions test/fixtures/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports.accountInfoResponse = function(request) {
Balance: '922913243',
Domain: '6578616D706C652E636F6D',
EmailHash: '23463B99B62A72F26ED677CC556C44E8',
Flags: 655360,
Flags: 9043968,
LedgerEntryType: 'AccountRoot',
OwnerCount: 1,
PreviousTxnID: '19899273706A9E040FDB5885EE991A1DC2BAD878A0D6E7DBCFB714E63BF737F7',
Expand Down Expand Up @@ -201,7 +201,8 @@ module.exports.RESTAccountSettingsResponse = JSON.stringify({
wallet_size: '',
message_key: '',
domain: 'example.com',
signers: ''
signers: '',
default_ripple: true
}
});

Expand Down
38 changes: 37 additions & 1 deletion test/settings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,42 @@ suite('post settings', function() {
.end(done);
});

test('/accounts/:account/settings -- default_ripple -- clear setting', function(done) {
var hash = testutils.generateHash();

self.wss.once('request_account_info', function(message, conn) {
assert.strictEqual(message.command, 'account_info');
assert.strictEqual(message.account, addresses.VALID);
conn.send(fixtures.accountInfoResponse(message));
});

self.wss.once('request_submit', function(message, conn) {
assert.strictEqual(message.command, 'submit');
assert(message.hasOwnProperty('tx_blob'));

var so = new ripple.SerializedObject(message.tx_blob).to_json();

assert.strictEqual(so.TransactionType, 'AccountSet');
assert.strictEqual(so.ClearFlag, 8);

conn.send(fixtures.submitSettingsResponse(message, {
hash: hash
}));
});

self.app
.post(fixtures.requestPath(addresses.VALID))
.send({
secret: addresses.SECRET,
settings: {
default_ripple: false
}
})
.expect(testutils.checkStatus(200))
.expect(testutils.checkHeaders)
.end(done);
});

test('/accounts/:account/settings -- no_freeze and global_freeze -- clear settings', function(done) {
self.wss.once('request_account_info', function(message, conn) {
assert(false, 'Should not request account info');
Expand Down Expand Up @@ -860,4 +896,4 @@ suite('post settings', function() {
.expect(testutils.checkHeaders)
.end(done);
});
});
});
1 change: 1 addition & 0 deletions test/unit/fixtures/tx-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ module.exports.settingResponseRest = {
require_destination_tag: true,
require_authorization: true,
disallow_xrp: true,
default_ripple: true
},
hash: '0F480D344CFC610DFA5CAC62CC1621C92953A05FE8C319281CA49C5C162AF40E',
ledger: 8820076,
Expand Down
3 changes: 2 additions & 1 deletion test/unit/tx-converter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ suite('unit - converter - Tx to Rest', function() {
wallet_size: 1,
transfer_rate: 2,
no_freeze: false,
global_freeze: true
global_freeze: true,
default_ripple: true
}
};

Expand Down

0 comments on commit 486f7bf

Please sign in to comment.