Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default limits for get_full_accounts API #2190

Merged
merged 6 commits into from Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docker/default_config.ini
Expand Up @@ -64,11 +64,11 @@ rpc-endpoint = 0.0.0.0:8090
# For database_api_impl::get_htlc_by_from and get_htlc_by_to to set max limit value
# api-limit-get-htlc-by = 100

# For database_api_impl::get_full_accounts to set max limit value
# api-limit-get-full-accounts = 10
# For database_api_impl::get_full_accounts to set max accounts to query at once
# api-limit-get-full-accounts = 50

# For database_api_impl::get_full_accounts to set max limit value
# api-limit-get-full-accounts-lists = 100
# For database_api_impl::get_full_accounts to set max items to return in the lists
# api-limit-get-full-accounts-lists = 500

# For database_api_impl::get_call_orders and get_call_orders_by_account to set max limit value
# api-limit-get-call-orders = 300
Expand Down
8 changes: 4 additions & 4 deletions libraries/app/application.cpp
Expand Up @@ -999,10 +999,10 @@ void application::set_program_options(boost::program_options::options_descriptio
"For database_api_impl::get_key_references to set max limit value")
("api-limit-get-htlc-by",boost::program_options::value<uint64_t>()->default_value(100),
"For database_api_impl::get_htlc_by_from and get_htlc_by_to to set max limit value")
("api-limit-get-full-accounts",boost::program_options::value<uint64_t>()->default_value(10),
"For database_api_impl::get_full_accounts to set max limit value")
("api-limit-get-full-accounts-lists",boost::program_options::value<uint64_t>()->default_value(100),
"For database_api_impl::get_full_accounts to set max limit value")
("api-limit-get-full-accounts",boost::program_options::value<uint64_t>()->default_value(50),
"For database_api_impl::get_full_accounts to set max accounts to query at once")
("api-limit-get-full-accounts-lists",boost::program_options::value<uint64_t>()->default_value(500),
"For database_api_impl::get_full_accounts to set max items to return in the lists")
("api-limit-get-call-orders",boost::program_options::value<uint64_t>()->default_value(300),
"For database_api_impl::get_call_orders and get_call_orders_by_account to set max limit value")
("api-limit-get-settle-orders",boost::program_options::value<uint64_t>()->default_value(300),
Expand Down
4 changes: 2 additions & 2 deletions libraries/app/include/graphene/app/application.hpp
Expand Up @@ -51,8 +51,8 @@ namespace graphene { namespace app {
uint64_t api_limit_get_asset_holders = 100;
uint64_t api_limit_get_key_references = 100;
uint64_t api_limit_get_htlc_by = 100;
uint64_t api_limit_get_full_accounts = 10;
uint64_t api_limit_get_full_accounts_lists = 100;
uint64_t api_limit_get_full_accounts = 50;
uint64_t api_limit_get_full_accounts_lists = 500;
uint64_t api_limit_get_call_orders = 300;
uint64_t api_limit_get_settle_orders = 300;
uint64_t api_limit_get_assets = 101;
Expand Down
37 changes: 11 additions & 26 deletions tests/tests/api_limit_tests.cpp
Expand Up @@ -77,45 +77,30 @@ BOOST_AUTO_TEST_CASE( api_limit_get_full_accounts ) {

try {
graphene::app::database_api db_api(db, &(this->app.get_options()));

const account_object& alice = create_account("alice");
const account_object& bob = create_account("bob");
const account_object& carl = create_account("carl");
const account_object& dan = create_account("dan");
const account_object& fred = create_account("fred");
const account_object& henry = create_account("henry");
const account_object& kevin = create_account("kevin");
const account_object& laura = create_account("laura");
const account_object& lucy = create_account("lucy");
const account_object& martin = create_account("martin");
const account_object& patty = create_account("patty");


vector<string> accounts;
accounts.push_back(alice.name);
accounts.push_back(bob.name);
accounts.push_back(carl.name);
accounts.push_back(dan.name);
accounts.push_back(fred.name);
accounts.push_back(henry.name);
accounts.push_back(kevin.name);
accounts.push_back(laura.name);
accounts.push_back(lucy.name);
accounts.push_back(martin.name);
accounts.push_back(patty.name);

for( size_t i = 0; i < 51; ++i )
{
string account_name = "testaccount" + fc::to_string(i);
create_account( account_name );
accounts.push_back( account_name );
}

// Too many accounts
GRAPHENE_CHECK_THROW(db_api.get_full_accounts(accounts, false), fc::exception);
abitmore marked this conversation as resolved.
Show resolved Hide resolved

accounts.erase(accounts.begin());
auto full_accounts = db_api.get_full_accounts(accounts, false);
BOOST_CHECK(full_accounts.size() == 10);
BOOST_CHECK(full_accounts.size() == 50);

// not an account
accounts.erase(accounts.begin());
accounts.push_back("nosuchaccount");

// non existing accounts will be ignored in the results
full_accounts = db_api.get_full_accounts(accounts, false);
BOOST_CHECK(full_accounts.size() == 9);
BOOST_CHECK(full_accounts.size() == 49);

} catch (fc::exception& e) {
edump((e.to_detail_string()));
Expand Down