account name or id support in all database api

This commit is contained in:
Sandip Patel 2019-11-26 13:50:06 +05:30
parent fd2679a888
commit 7aeaa14bae
7 changed files with 237 additions and 189 deletions

View file

@ -551,7 +551,7 @@ namespace graphene { namespace app {
return result; return result;
} }
vector<operation_history_object> history_api::get_account_history( account_id_type account, vector<operation_history_object> history_api::get_account_history( const std::string account_id_or_name,
operation_history_id_type stop, operation_history_id_type stop,
unsigned limit, unsigned limit,
operation_history_id_type start ) const operation_history_id_type start ) const
@ -560,7 +560,9 @@ namespace graphene { namespace app {
const auto& db = *_app.chain_database(); const auto& db = *_app.chain_database();
FC_ASSERT( limit <= 100 ); FC_ASSERT( limit <= 100 );
vector<operation_history_object> result; vector<operation_history_object> result;
account_id_type account;
try { try {
account = database_api.get_account_id_from_string(account_id_or_name);
const account_transaction_history_object& node = account(db).statistics(db).most_recent_op(db); const account_transaction_history_object& node = account(db).statistics(db).most_recent_op(db);
if(start == operation_history_id_type() || start.instance.value > node.operation_id.instance.value) if(start == operation_history_id_type() || start.instance.value > node.operation_id.instance.value)
start = node.operation_id; start = node.operation_id;
@ -584,7 +586,7 @@ namespace graphene { namespace app {
return result; return result;
} }
vector<operation_history_object> history_api::get_account_history_operations( account_id_type account, vector<operation_history_object> history_api::get_account_history_operations( const std::string account_id_or_name,
int operation_id, int operation_id,
operation_history_id_type start, operation_history_id_type start,
operation_history_id_type stop, operation_history_id_type stop,
@ -594,6 +596,11 @@ namespace graphene { namespace app {
const auto& db = *_app.chain_database(); const auto& db = *_app.chain_database();
FC_ASSERT( limit <= 100 ); FC_ASSERT( limit <= 100 );
vector<operation_history_object> result; vector<operation_history_object> result;
account_id_type account;
try {
account = database_api.get_account_id_from_string(account_id_or_name);
} catch (...) { return result; }
const auto& stats = account(db).statistics(db); const auto& stats = account(db).statistics(db);
if( stats.most_recent_op == account_transaction_history_id_type() ) return result; if( stats.most_recent_op == account_transaction_history_id_type() ) return result;
const account_transaction_history_object* node = &stats.most_recent_op(db); const account_transaction_history_object* node = &stats.most_recent_op(db);
@ -620,7 +627,7 @@ namespace graphene { namespace app {
} }
vector<operation_history_object> history_api::get_relative_account_history( account_id_type account, vector<operation_history_object> history_api::get_relative_account_history( const std::string account_id_or_name,
uint32_t stop, uint32_t stop,
unsigned limit, unsigned limit,
uint32_t start) const uint32_t start) const
@ -629,6 +636,10 @@ namespace graphene { namespace app {
const auto& db = *_app.chain_database(); const auto& db = *_app.chain_database();
FC_ASSERT(limit <= 100); FC_ASSERT(limit <= 100);
vector<operation_history_object> result; vector<operation_history_object> result;
account_id_type account;
try {
account = database_api.get_account_id_from_string(account_id_or_name);
} catch(...) { return result; }
const auto& stats = account(db).statistics(db); const auto& stats = account(db).statistics(db);
if( start == 0 ) if( start == 0 )
start = stats.total_ops; start = stats.total_ops;

View file

@ -81,20 +81,20 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
bool is_public_key_registered(string public_key) const; bool is_public_key_registered(string public_key) const;
// Accounts // Accounts
vector<optional<account_object>> get_accounts(const vector<account_id_type>& account_ids)const; account_id_type get_account_id_from_string(const std::string& name_or_id)const;
vector<optional<account_object>> get_accounts(const vector<std::string>& account_names_or_ids)const;
std::map<string,full_account> get_full_accounts( const vector<string>& names_or_ids, bool subscribe ); std::map<string,full_account> get_full_accounts( const vector<string>& names_or_ids, bool subscribe );
optional<account_object> get_account_by_name( string name )const; optional<account_object> get_account_by_name( string name )const;
vector<account_id_type> get_account_references( account_id_type account_id )const; vector<account_id_type> get_account_references( const std::string account_id_or_name )const;
vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const; vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const;
map<string,account_id_type> lookup_accounts(const string& lower_bound_name, uint32_t limit)const; map<string,account_id_type> lookup_accounts(const string& lower_bound_name, uint32_t limit)const;
uint64_t get_account_count()const; uint64_t get_account_count()const;
// Balances // Balances
vector<asset> get_account_balances(account_id_type id, const flat_set<asset_id_type>& assets)const; vector<asset> get_account_balances(const std::string& account_name_or_id, const flat_set<asset_id_type>& assets)const;
vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;
vector<balance_object> get_balance_objects( const vector<address>& addrs )const; vector<balance_object> get_balance_objects( const vector<address>& addrs )const;
vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const; vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const;
vector<vesting_balance_object> get_vesting_balances( account_id_type account_id )const; vector<vesting_balance_object> get_vesting_balances( const std::string account_id_or_name )const;
// Assets // Assets
vector<optional<asset_object>> get_assets(const vector<asset_id_type>& asset_ids)const; vector<optional<asset_object>> get_assets(const vector<asset_id_type>& asset_ids)const;
@ -127,7 +127,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const; vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const;
vector<call_order_object> get_call_orders(asset_id_type a, uint32_t limit)const; vector<call_order_object> get_call_orders(asset_id_type a, uint32_t limit)const;
vector<force_settlement_object> get_settle_orders(asset_id_type a, uint32_t limit)const; vector<force_settlement_object> get_settle_orders(asset_id_type a, uint32_t limit)const;
vector<call_order_object> get_margin_positions( const account_id_type& id )const; vector<call_order_object> get_margin_positions( const std::string account_id_or_name )const;
void subscribe_to_market(std::function<void(const variant&)> callback, asset_id_type a, asset_id_type b); void subscribe_to_market(std::function<void(const variant&)> callback, asset_id_type a, asset_id_type b);
void unsubscribe_from_market(asset_id_type a, asset_id_type b); void unsubscribe_from_market(asset_id_type a, asset_id_type b);
market_ticker get_ticker( const string& base, const string& quote )const; market_ticker get_ticker( const string& base, const string& quote )const;
@ -137,13 +137,13 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
// Witnesses // Witnesses
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const; vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const;
fc::optional<witness_object> get_witness_by_account(account_id_type account)const; fc::optional<witness_object> get_witness_by_account(const std::string account_id_or_name)const;
map<string, witness_id_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const; map<string, witness_id_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;
uint64_t get_witness_count()const; uint64_t get_witness_count()const;
// Committee members // Committee members
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type>& committee_member_ids)const; vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type>& committee_member_ids)const;
fc::optional<committee_member_object> get_committee_member_by_account(account_id_type account)const; fc::optional<committee_member_object> get_committee_member_by_account(const std::string account_id_or_name)const;
map<string, committee_member_id_type> lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const; map<string, committee_member_id_type> lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const;
// Votes // Votes
@ -160,7 +160,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
vector< fc::variant > get_required_fees( const vector<operation>& ops, asset_id_type id )const; vector< fc::variant > get_required_fees( const vector<operation>& ops, asset_id_type id )const;
// Proposed transactions // Proposed transactions
vector<proposal_object> get_proposed_transactions( account_id_type id )const; vector<proposal_object> get_proposed_transactions( const std::string account_id_or_name )const;
// Blinded balances // Blinded balances
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const; vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
@ -175,6 +175,8 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
gpos_info get_gpos_info(const account_id_type account) const; gpos_info get_gpos_info(const account_id_type account) const;
//private: //private:
const account_object* get_account_from_string( const std::string& name_or_id,
bool throw_if_not_found = true ) const;
template<typename T> template<typename T>
void subscribe_to_item( const T& i )const void subscribe_to_item( const T& i )const
{ {
@ -614,22 +616,27 @@ bool database_api_impl::is_public_key_registered(string public_key) const
// // // //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
vector<optional<account_object>> database_api::get_accounts(const vector<account_id_type>& account_ids)const account_id_type database_api::get_account_id_from_string(const std::string& name_or_id)const
{ {
return my->get_accounts( account_ids ); return my->get_account_from_string( name_or_id )->id;
} }
vector<optional<account_object>> database_api_impl::get_accounts(const vector<account_id_type>& account_ids)const vector<optional<account_object>> database_api::get_accounts(const vector<std::string>& account_names_or_ids)const
{ {
vector<optional<account_object>> result; result.reserve(account_ids.size()); return my->get_accounts( account_names_or_ids );
std::transform(account_ids.begin(), account_ids.end(), std::back_inserter(result), }
[this](account_id_type id) -> optional<account_object> {
if(auto o = _db.find(id)) vector<optional<account_object>> database_api_impl::get_accounts(const vector<std::string>& account_names_or_ids)const
{ {
subscribe_to_item( id ); vector<optional<account_object>> result; result.reserve(account_names_or_ids.size());
return *o; std::transform(account_names_or_ids.begin(), account_names_or_ids.end(), std::back_inserter(result),
} [this](std::string id_or_name) -> optional<account_object> {
return {}; const account_object *account = get_account_from_string(id_or_name, false);
if(account == nullptr)
return {};
subscribe_to_item( account->id );
return *account;
}); });
return result; return result;
} }
@ -758,16 +765,17 @@ optional<account_object> database_api_impl::get_account_by_name( string name )co
return optional<account_object>(); return optional<account_object>();
} }
vector<account_id_type> database_api::get_account_references( account_id_type account_id )const vector<account_id_type> database_api::get_account_references( const std::string account_id_or_name )const
{ {
return my->get_account_references( account_id ); return my->get_account_references( account_id_or_name );
} }
vector<account_id_type> database_api_impl::get_account_references( account_id_type account_id )const vector<account_id_type> database_api_impl::get_account_references( const std::string account_id_or_name )const
{ {
const auto& idx = _db.get_index_type<account_index>(); const auto& idx = _db.get_index_type<account_index>();
const auto& aidx = dynamic_cast<const base_primary_index&>(idx); const auto& aidx = dynamic_cast<const base_primary_index&>(idx);
const auto& refs = aidx.get_secondary_index<graphene::chain::account_member_index>(); const auto& refs = aidx.get_secondary_index<graphene::chain::account_member_index>();
const account_id_type account_id = get_account_from_string(account_id_or_name)->id;
auto itr = refs.account_to_account_memberships.find(account_id); auto itr = refs.account_to_account_memberships.find(account_id);
vector<account_id_type> result; vector<account_id_type> result;
@ -836,13 +844,16 @@ uint64_t database_api_impl::get_account_count()const
// // // //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
vector<asset> database_api::get_account_balances(account_id_type id, const flat_set<asset_id_type>& assets)const vector<asset> database_api::get_account_balances(const std::string& account_name_or_id, const flat_set<asset_id_type>& assets)const
{ {
return my->get_account_balances( id, assets ); return my->get_account_balances( account_name_or_id, assets );
} }
vector<asset> database_api_impl::get_account_balances(account_id_type acnt, const flat_set<asset_id_type>& assets)const vector<asset> database_api_impl::get_account_balances( const std::string& account_name_or_id,
const flat_set<asset_id_type>& assets)const
{ {
const account_object* account = get_account_from_string(account_name_or_id);
account_id_type acnt = account->id;
vector<asset> result; vector<asset> result;
if (assets.empty()) if (assets.empty())
{ {
@ -865,15 +876,7 @@ vector<asset> database_api_impl::get_account_balances(account_id_type acnt, cons
vector<asset> database_api::get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const vector<asset> database_api::get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const
{ {
return my->get_named_account_balances( name, assets ); return my->get_account_balances( name, assets );
}
vector<asset> database_api_impl::get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets) const
{
const auto& accounts_by_name = _db.get_index_type<account_index>().indices().get<by_name>();
auto itr = accounts_by_name.find(name);
FC_ASSERT( itr != accounts_by_name.end() );
return get_account_balances(itr->get_id(), assets);
} }
vector<balance_object> database_api::get_balance_objects( const vector<address>& addrs )const vector<balance_object> database_api::get_balance_objects( const vector<address>& addrs )const
@ -923,15 +926,16 @@ vector<asset> database_api_impl::get_vested_balances( const vector<balance_id_ty
} FC_CAPTURE_AND_RETHROW( (objs) ) } FC_CAPTURE_AND_RETHROW( (objs) )
} }
vector<vesting_balance_object> database_api::get_vesting_balances( account_id_type account_id )const vector<vesting_balance_object> database_api::get_vesting_balances( const std::string account_id_or_name )const
{ {
return my->get_vesting_balances( account_id ); return my->get_vesting_balances( account_id_or_name );
} }
vector<vesting_balance_object> database_api_impl::get_vesting_balances( account_id_type account_id )const vector<vesting_balance_object> database_api_impl::get_vesting_balances( const std::string account_id_or_name )const
{ {
try try
{ {
const account_id_type account_id = get_account_from_string(account_id_or_name)->id;
vector<vesting_balance_object> result; vector<vesting_balance_object> result;
auto vesting_range = _db.get_index_type<vesting_balance_index>().indices().get<by_account>().equal_range(account_id); auto vesting_range = _db.get_index_type<vesting_balance_index>().indices().get<by_account>().equal_range(account_id);
std::for_each(vesting_range.first, vesting_range.second, std::for_each(vesting_range.first, vesting_range.second,
@ -941,7 +945,7 @@ vector<vesting_balance_object> database_api_impl::get_vesting_balances( account_
}); });
return result; return result;
} }
FC_CAPTURE_AND_RETHROW( (account_id) ); FC_CAPTURE_AND_RETHROW( (account_id_or_name) );
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -1273,17 +1277,18 @@ vector<force_settlement_object> database_api_impl::get_settle_orders(asset_id_ty
settle_index.upper_bound(mia.get_id())); settle_index.upper_bound(mia.get_id()));
} }
vector<call_order_object> database_api::get_margin_positions( const account_id_type& id )const vector<call_order_object> database_api::get_margin_positions( const std::string account_id_or_name )const
{ {
return my->get_margin_positions( id ); return my->get_margin_positions( account_id_or_name );
} }
vector<call_order_object> database_api_impl::get_margin_positions( const account_id_type& id )const vector<call_order_object> database_api_impl::get_margin_positions( const std::string account_id_or_name )const
{ {
try try
{ {
const auto& idx = _db.get_index_type<call_order_index>(); const auto& idx = _db.get_index_type<call_order_index>();
const auto& aidx = idx.indices().get<by_account>(); const auto& aidx = idx.indices().get<by_account>();
const account_id_type id = get_account_from_string(account_id_or_name)->id;
auto start = aidx.lower_bound( boost::make_tuple( id, asset_id_type(0) ) ); auto start = aidx.lower_bound( boost::make_tuple( id, asset_id_type(0) ) );
auto end = aidx.lower_bound( boost::make_tuple( id+1, asset_id_type(0) ) ); auto end = aidx.lower_bound( boost::make_tuple( id+1, asset_id_type(0) ) );
vector<call_order_object> result; vector<call_order_object> result;
@ -1293,7 +1298,7 @@ vector<call_order_object> database_api_impl::get_margin_positions( const account
++start; ++start;
} }
return result; return result;
} FC_CAPTURE_AND_RETHROW( (id) ) } FC_CAPTURE_AND_RETHROW( (account_id_or_name) )
} }
void database_api::subscribe_to_market(std::function<void(const variant&)> callback, asset_id_type a, asset_id_type b) void database_api::subscribe_to_market(std::function<void(const variant&)> callback, asset_id_type a, asset_id_type b)
@ -1540,9 +1545,10 @@ vector<optional<witness_object>> database_api::get_witnesses(const vector<witnes
return my->get_witnesses( witness_ids ); return my->get_witnesses( witness_ids );
} }
vector<worker_object> database_api::get_workers_by_account(account_id_type account)const vector<worker_object> database_api::get_workers_by_account(const std::string account_id_or_name)const
{ {
const auto& idx = my->_db.get_index_type<worker_index>().indices().get<by_account>(); const auto& idx = my->_db.get_index_type<worker_index>().indices().get<by_account>();
const account_id_type account = get_account_from_string(account_id_or_name)->id;
auto itr = idx.find(account); auto itr = idx.find(account);
vector<worker_object> result; vector<worker_object> result;
@ -1568,14 +1574,15 @@ vector<optional<witness_object>> database_api_impl::get_witnesses(const vector<w
return result; return result;
} }
fc::optional<witness_object> database_api::get_witness_by_account(account_id_type account)const fc::optional<witness_object> database_api::get_witness_by_account(const std::string account_id_or_name)const
{ {
return my->get_witness_by_account( account ); return my->get_witness_by_account( account_id_or_name );
} }
fc::optional<witness_object> database_api_impl::get_witness_by_account(account_id_type account) const fc::optional<witness_object> database_api_impl::get_witness_by_account(const std::string account_id_or_name) const
{ {
const auto& idx = _db.get_index_type<witness_index>().indices().get<by_account>(); const auto& idx = _db.get_index_type<witness_index>().indices().get<by_account>();
const account_id_type account = get_account_from_string(account_id_or_name)->id;
auto itr = idx.find(account); auto itr = idx.find(account);
if( itr != idx.end() ) if( itr != idx.end() )
return *itr; return *itr;
@ -1643,14 +1650,15 @@ vector<optional<committee_member_object>> database_api_impl::get_committee_membe
return result; return result;
} }
fc::optional<committee_member_object> database_api::get_committee_member_by_account(account_id_type account)const fc::optional<committee_member_object> database_api::get_committee_member_by_account(const std::string account_id_or_name)const
{ {
return my->get_committee_member_by_account( account ); return my->get_committee_member_by_account( account_id_or_name );
} }
fc::optional<committee_member_object> database_api_impl::get_committee_member_by_account(account_id_type account) const fc::optional<committee_member_object> database_api_impl::get_committee_member_by_account(const std::string account_id_or_name) const
{ {
const auto& idx = _db.get_index_type<committee_member_index>().indices().get<by_account>(); const auto& idx = _db.get_index_type<committee_member_index>().indices().get<by_account>();
const account_id_type account = get_account_from_string(account_id_or_name)->id;
auto itr = idx.find(account); auto itr = idx.find(account);
if( itr != idx.end() ) if( itr != idx.end() )
return *itr; return *itr;
@ -1992,16 +2000,17 @@ vector< fc::variant > database_api_impl::get_required_fees( const vector<operati
// // // //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
vector<proposal_object> database_api::get_proposed_transactions( account_id_type id )const vector<proposal_object> database_api::get_proposed_transactions( const std::string account_id_or_name )const
{ {
return my->get_proposed_transactions( id ); return my->get_proposed_transactions( account_id_or_name );
} }
/** TODO: add secondary index that will accelerate this process */ /** TODO: add secondary index that will accelerate this process */
vector<proposal_object> database_api_impl::get_proposed_transactions( account_id_type id )const vector<proposal_object> database_api_impl::get_proposed_transactions( const std::string account_id_or_name )const
{ {
const auto& idx = _db.get_index_type<proposal_index>(); const auto& idx = _db.get_index_type<proposal_index>();
vector<proposal_object> result; vector<proposal_object> result;
const account_id_type id = get_account_from_string(account_id_or_name)->id;
idx.inspect_all_objects( [&](const object& obj){ idx.inspect_all_objects( [&](const object& obj){
const proposal_object& p = static_cast<const proposal_object&>(obj); const proposal_object& p = static_cast<const proposal_object&>(obj);
@ -2116,6 +2125,26 @@ vector<tournament_object> database_api_impl::get_tournaments_by_state(tournament
return result; return result;
} }
const account_object* database_api_impl::get_account_from_string( const std::string& name_or_id,
bool throw_if_not_found ) const
{
// TODO cache the result to avoid repeatly fetching from db
FC_ASSERT( name_or_id.size() > 0);
const account_object* account = nullptr;
if (std::isdigit(name_or_id[0]))
account = _db.find(fc::variant(name_or_id, 1).as<account_id_type>(1));
else
{
const auto& idx = _db.get_index_type<account_index>().indices().get<by_name>();
auto itr = idx.find(name_or_id);
if (itr != idx.end())
account = &*itr;
}
if(throw_if_not_found)
FC_ASSERT( account, "no such account" );
return account;
}
vector<tournament_id_type> database_api::get_registered_tournaments(account_id_type account_filter, uint32_t limit) const vector<tournament_id_type> database_api::get_registered_tournaments(account_id_type account_filter, uint32_t limit) const
{ {
return my->get_registered_tournaments(account_filter, limit); return my->get_registered_tournaments(account_filter, limit);

View file

@ -95,31 +95,32 @@ namespace graphene { namespace app {
class history_api class history_api
{ {
public: public:
history_api(application& app):_app(app){} history_api(application& app)
:_app(app), database_api( std::ref(*app.chain_database()), &(app.get_options())) {}
/** /**
* @brief Get operations relevant to the specificed account * @brief Get operations relevant to the specificed account
* @param account The account whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param stop ID of the earliest operation to retrieve * @param stop ID of the earliest operation to retrieve
* @param limit Maximum number of operations to retrieve (must not exceed 100) * @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start ID of the most recent operation to retrieve * @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_account_history(account_id_type account, vector<operation_history_object> get_account_history(const std::string account_id_or_name,
operation_history_id_type stop = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(),
unsigned limit = 100, unsigned limit = 100,
operation_history_id_type start = operation_history_id_type())const; operation_history_id_type start = operation_history_id_type())const;
/** /**
* @brief Get only asked operations relevant to the specified account * @brief Get only asked operations relevant to the specified account
* @param account The account whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param operation_id The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, ...) * @param operation_id The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, ...)
* @param stop ID of the earliest operation to retrieve * @param stop ID of the earliest operation to retrieve
* @param limit Maximum number of operations to retrieve (must not exceed 100) * @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start ID of the most recent operation to retrieve * @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_account_history_operations(account_id_type account, vector<operation_history_object> get_account_history_operations(const std::string account_id_or_name,
int operation_id, int operation_id,
operation_history_id_type start = operation_history_id_type(), operation_history_id_type start = operation_history_id_type(),
operation_history_id_type stop = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(),
@ -129,7 +130,7 @@ namespace graphene { namespace app {
* @breif Get operations relevant to the specified account referenced * @breif Get operations relevant to the specified account referenced
* by an event numbering specific to the account. The current number of operations * by an event numbering specific to the account. The current number of operations
* for the account can be found in the account statistics (or use 0 for start). * for the account can be found in the account statistics (or use 0 for start).
* @param account The account whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param stop Sequence number of earliest operation. 0 is default and will * @param stop Sequence number of earliest operation. 0 is default and will
* query 'limit' number of operations. * query 'limit' number of operations.
* @param limit Maximum number of operations to retrieve (must not exceed 100) * @param limit Maximum number of operations to retrieve (must not exceed 100)
@ -137,7 +138,7 @@ namespace graphene { namespace app {
* 0 is default, which will start querying from the most recent operation. * 0 is default, which will start querying from the most recent operation.
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_relative_account_history( account_id_type account, vector<operation_history_object> get_relative_account_history( const std::string account_id_or_name,
uint32_t stop = 0, uint32_t stop = 0,
unsigned limit = 100, unsigned limit = 100,
uint32_t start = 0) const; uint32_t start = 0) const;
@ -149,6 +150,7 @@ namespace graphene { namespace app {
flat_set<uint32_t> get_market_history_buckets()const; flat_set<uint32_t> get_market_history_buckets()const;
private: private:
application& _app; application& _app;
graphene::app::database_api database_api;
}; };
/** /**

View file

@ -249,13 +249,21 @@ class database_api
////////////// //////////////
/** /**
* @brief Get a list of accounts by ID * @brief Get account object from a name or ID
* @param name_or_id name or ID of the account
* @return Account ID
*
*/
account_id_type get_account_id_from_string(const std::string& name_or_id)const;
/**
* @brief Get a list of accounts by ID or Name
* @param account_ids IDs of the accounts to retrieve * @param account_ids IDs of the accounts to retrieve
* @return The accounts corresponding to the provided IDs * @return The accounts corresponding to the provided IDs
* *
* This function has semantics identical to @ref get_objects * This function has semantics identical to @ref get_objects
*/ */
vector<optional<account_object>> get_accounts(const vector<account_id_type>& account_ids)const; vector<optional<account_object>> get_accounts(const vector<std::string>& account_names_or_ids)const;
/** /**
* @brief Fetch all objects relevant to the specified accounts and subscribe to updates * @brief Fetch all objects relevant to the specified accounts and subscribe to updates
@ -275,7 +283,7 @@ class database_api
/** /**
* @return all accounts that referr to the key or account id in their owner or active authorities. * @return all accounts that referr to the key or account id in their owner or active authorities.
*/ */
vector<account_id_type> get_account_references( account_id_type account_id )const; vector<account_id_type> get_account_references( const std::string account_name_or_id )const;
/** /**
* @brief Get a list of accounts by name * @brief Get a list of accounts by name
@ -304,7 +312,8 @@ class database_api
* @param assets IDs of the assets to get balances of; if empty, get all assets account has a balance in * @param assets IDs of the assets to get balances of; if empty, get all assets account has a balance in
* @return Balances of the account * @return Balances of the account
*/ */
vector<asset> get_account_balances(account_id_type id, const flat_set<asset_id_type>& assets)const; vector<asset> get_account_balances( const std::string& account_name_or_id,
const flat_set<asset_id_type>& assets )const;
/// Semantically equivalent to @ref get_account_balances, but takes a name instead of an ID. /// Semantically equivalent to @ref get_account_balances, but takes a name instead of an ID.
vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const; vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;
@ -314,7 +323,7 @@ class database_api
vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const; vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const;
vector<vesting_balance_object> get_vesting_balances( account_id_type account_id )const; vector<vesting_balance_object> get_vesting_balances( const std::string account_id_or_name )const;
/** /**
* @brief Get the total number of accounts registered with the blockchain * @brief Get the total number of accounts registered with the blockchain
@ -455,7 +464,7 @@ class database_api
/** /**
* @return all open margin positions for a given account id. * @return all open margin positions for a given account id.
*/ */
vector<call_order_object> get_margin_positions( const account_id_type& id )const; vector<call_order_object> get_margin_positions( const std::string account_id_or_name )const;
/** /**
* @brief Request notification when the active orders in the market between two assets changes * @brief Request notification when the active orders in the market between two assets changes
@ -533,7 +542,7 @@ class database_api
* @param account The ID of the account whose witness should be retrieved * @param account The ID of the account whose witness should be retrieved
* @return The witness object, or null if the account does not have a witness * @return The witness object, or null if the account does not have a witness
*/ */
fc::optional<witness_object> get_witness_by_account(account_id_type account)const; fc::optional<witness_object> get_witness_by_account(const std::string account_name_or_id)const;
/** /**
* @brief Get names and IDs for registered witnesses * @brief Get names and IDs for registered witnesses
@ -563,10 +572,10 @@ class database_api
/** /**
* @brief Get the committee_member owned by a given account * @brief Get the committee_member owned by a given account
* @param account The ID of the account whose committee_member should be retrieved * @param account_id_or_name The ID or name of the account whose committee_member should be retrieved
* @return The committee_member object, or null if the account does not have a committee_member * @return The committee_member object, or null if the account does not have a committee_member
*/ */
fc::optional<committee_member_object> get_committee_member_by_account(account_id_type account)const; fc::optional<committee_member_object> get_committee_member_by_account(const std::string account_id_or_name)const;
/** /**
* @brief Get names and IDs for registered committee_members * @brief Get names and IDs for registered committee_members
@ -580,9 +589,11 @@ class database_api
/// WORKERS /// WORKERS
/** /**
* Return the worker objects associated with this account. * @brief Return the worker objects associated with this account.
* @param account_id_or_name The ID or name of the account whose worker should be retrieved
* @return The worker object or null if the account does not have a worker
*/ */
vector<worker_object> get_workers_by_account(account_id_type account)const; vector<worker_object> get_workers_by_account(const std::string account_id_or_name)const;
/////////// ///////////
@ -648,7 +659,7 @@ class database_api
/** /**
* @return the set of proposed transactions relevant to the specified account id. * @return the set of proposed transactions relevant to the specified account id.
*/ */
vector<proposal_object> get_proposed_transactions( account_id_type id )const; vector<proposal_object> get_proposed_transactions( const std::string account_id_or_name )const;
////////////////////// //////////////////////
// Blinded balances // // Blinded balances //
@ -734,6 +745,7 @@ FC_API(graphene::app::database_api,
(is_public_key_registered) (is_public_key_registered)
// Accounts // Accounts
(get_account_id_from_string)
(get_accounts) (get_accounts)
(get_full_accounts) (get_full_accounts)
(get_account_by_name) (get_account_by_name)

View file

@ -355,7 +355,8 @@ private:
for( const fc::optional<graphene::chain::account_object>& optional_account : owner_account_objects ) for( const fc::optional<graphene::chain::account_object>& optional_account : owner_account_objects )
if (optional_account) if (optional_account)
{ {
fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(optional_account->id); std::string account_id = account_id_to_string(optional_account->id);
fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(account_id);
if (witness_obj) if (witness_obj)
claim_registered_witness(optional_account->name); claim_registered_witness(optional_account->name);
} }
@ -729,9 +730,17 @@ public:
{ {
return _remote_db->get_dynamic_global_properties(); return _remote_db->get_dynamic_global_properties();
} }
std::string account_id_to_string(account_id_type id) const
{
std::string account_id = fc::to_string(id.space_id)
+ "." + fc::to_string(id.type_id)
+ "." + fc::to_string(id.instance.value);
return account_id;
}
account_object get_account(account_id_type id) const account_object get_account(account_id_type id) const
{ {
auto rec = _remote_db->get_accounts({id}).front(); std::string account_id = account_id_to_string(id);
auto rec = _remote_db->get_accounts({account_id}).front();
FC_ASSERT(rec); FC_ASSERT(rec);
return *rec; return *rec;
} }
@ -1018,7 +1027,7 @@ public:
("chain_id", _chain_id) ); ("chain_id", _chain_id) );
size_t account_pagination = 100; size_t account_pagination = 100;
vector< account_id_type > account_ids_to_send; vector< std::string > account_ids_to_send;
size_t n = _wallet.my_accounts.size(); size_t n = _wallet.my_accounts.size();
account_ids_to_send.reserve( std::min( account_pagination, n ) ); account_ids_to_send.reserve( std::min( account_pagination, n ) );
auto it = _wallet.my_accounts.begin(); auto it = _wallet.my_accounts.begin();
@ -1033,7 +1042,8 @@ public:
{ {
assert( it != _wallet.my_accounts.end() ); assert( it != _wallet.my_accounts.end() );
old_accounts.push_back( *it ); old_accounts.push_back( *it );
account_ids_to_send.push_back( old_accounts.back().id ); std::string account_id = account_id_to_string(old_accounts.back().id);
account_ids_to_send.push_back( account_id );
++it; ++it;
} }
std::vector< optional< account_object > > accounts = _remote_db->get_accounts(account_ids_to_send); std::vector< optional< account_object > > accounts = _remote_db->get_accounts(account_ids_to_send);
@ -1733,7 +1743,7 @@ public:
committee_member_create_operation committee_member_create_op; committee_member_create_operation committee_member_create_op;
committee_member_create_op.committee_member_account = get_account_id(owner_account); committee_member_create_op.committee_member_account = get_account_id(owner_account);
committee_member_create_op.url = url; committee_member_create_op.url = url;
if (_remote_db->get_committee_member_by_account(committee_member_create_op.committee_member_account)) if (_remote_db->get_committee_member_by_account(owner_account))
FC_THROW("Account ${owner_account} is already a committee_member", ("owner_account", owner_account)); FC_THROW("Account ${owner_account} is already a committee_member", ("owner_account", owner_account));
signed_transaction tx; signed_transaction tx;
@ -1763,7 +1773,7 @@ public:
// then maybe it's the owner account // then maybe it's the owner account
try try
{ {
account_id_type owner_account_id = get_account_id(owner_account); std::string owner_account_id = account_id_to_string(get_account_id(owner_account));
fc::optional<witness_object> witness = _remote_db->get_witness_by_account(owner_account_id); fc::optional<witness_object> witness = _remote_db->get_witness_by_account(owner_account_id);
if (witness) if (witness)
return *witness; return *witness;
@ -1799,7 +1809,7 @@ public:
// then maybe it's the owner account // then maybe it's the owner account
try try
{ {
account_id_type owner_account_id = get_account_id(owner_account); std::string owner_account_id = account_id_to_string(get_account_id(owner_account));
fc::optional<witness_object> witness = _remote_db->get_witness_by_account(owner_account_id); fc::optional<witness_object> witness = _remote_db->get_witness_by_account(owner_account_id);
if (witness) if (witness)
return true; return true;
@ -1834,8 +1844,7 @@ public:
// then maybe it's the owner account // then maybe it's the owner account
try try
{ {
account_id_type owner_account_id = get_account_id(owner_account); fc::optional<committee_member_object> committee_member = _remote_db->get_committee_member_by_account(owner_account);
fc::optional<committee_member_object> committee_member = _remote_db->get_committee_member_by_account(owner_account_id);
if (committee_member) if (committee_member)
return *committee_member; return *committee_member;
else else
@ -1871,7 +1880,7 @@ public:
witness_create_op.initial_secret = enc.result(); witness_create_op.initial_secret = enc.result();
if (_remote_db->get_witness_by_account(witness_create_op.witness_account)) if (_remote_db->get_witness_by_account(account_id_to_string(witness_create_op.witness_account)))
FC_THROW("Account ${owner_account} is already a witness", ("owner_account", owner_account)); FC_THROW("Account ${owner_account} is already a witness", ("owner_account", owner_account));
signed_transaction tx; signed_transaction tx;
@ -2037,12 +2046,7 @@ public:
return result; return result;
} }
// try casting to avoid a round-trip if we were given an account ID vector< vesting_balance_object > vbos = _remote_db->get_vesting_balances( account_name );
fc::optional<account_id_type> acct_id = maybe_id<account_id_type>( account_name );
if( !acct_id )
acct_id = get_account( account_name ).id;
vector< vesting_balance_object > vbos = _remote_db->get_vesting_balances( *acct_id );
if( vbos.size() == 0 ) if( vbos.size() == 0 )
return result; return result;
@ -2110,12 +2114,7 @@ public:
fc::optional<vesting_balance_id_type> vbid = maybe_id<vesting_balance_id_type>(account_name); fc::optional<vesting_balance_id_type> vbid = maybe_id<vesting_balance_id_type>(account_name);
if( !vbid ) if( !vbid )
{ {
//Changes done to retrive user account/witness account based on account name vbos = _remote_db->get_vesting_balances( account_name );
fc::optional<account_id_type> acct_id = maybe_id<account_id_type>( account_name );
if( !acct_id )
acct_id = get_account( account_name ).id;
vbos = _remote_db->get_vesting_balances( *acct_id );
if( vbos.size() == 0 ) if( vbos.size() == 0 )
FC_THROW("Account ${account} has no core TOKEN vested and thus its not allowed to withdraw.", ("account", account_name)); FC_THROW("Account ${account} has no core TOKEN vested and thus its not allowed to withdraw.", ("account", account_name));
} }
@ -2188,8 +2187,7 @@ public:
} }
account_object voting_account_object = get_account(voting_account); account_object voting_account_object = get_account(voting_account);
account_id_type committee_member_owner_account_id = get_account_id(committee_member); fc::optional<committee_member_object> committee_member_obj = _remote_db->get_committee_member_by_account(committee_member);
fc::optional<committee_member_object> committee_member_obj = _remote_db->get_committee_member_by_account(committee_member_owner_account_id);
if (!committee_member_obj) if (!committee_member_obj)
FC_THROW("Account ${committee_member} is not registered as a committee_member", ("committee_member", committee_member)); FC_THROW("Account ${committee_member} is not registered as a committee_member", ("committee_member", committee_member));
@ -2253,9 +2251,8 @@ public:
} }
account_object voting_account_object = get_account(voting_account); account_object voting_account_object = get_account(voting_account);
account_id_type witness_owner_account_id = get_account_id(witness);
fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness_owner_account_id); fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness);
if (!witness_obj) if (!witness_obj)
FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness)); FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness));
@ -2311,8 +2308,7 @@ public:
account_object voting_account_object = get_account(voting_account); account_object voting_account_object = get_account(voting_account);
for (const std::string& witness : witnesses_to_approve) for (const std::string& witness : witnesses_to_approve)
{ {
account_id_type witness_owner_account_id = get_account_id(witness); fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness);
fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness_owner_account_id);
if (!witness_obj) if (!witness_obj)
FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness)); FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness));
auto insert_result = voting_account_object.options.votes.insert(witness_obj->vote_id); auto insert_result = voting_account_object.options.votes.insert(witness_obj->vote_id);
@ -2321,8 +2317,7 @@ public:
} }
for (const std::string& witness : witnesses_to_reject) for (const std::string& witness : witnesses_to_reject)
{ {
account_id_type witness_owner_account_id = get_account_id(witness); fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness);
fc::optional<witness_object> witness_obj = _remote_db->get_witness_by_account(witness_owner_account_id);
if (!witness_obj) if (!witness_obj)
FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness)); FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness));
unsigned votes_removed = voting_account_object.options.votes.erase(witness_obj->vote_id); unsigned votes_removed = voting_account_object.options.votes.erase(witness_obj->vote_id);
@ -3706,8 +3701,8 @@ map<string,account_id_type> wallet_api::list_accounts(const string& lowerbound,
vector<asset> wallet_api::list_account_balances(const string& id) vector<asset> wallet_api::list_account_balances(const string& id)
{ {
if( auto real_id = detail::maybe_id<account_id_type>(id) ) if( auto real_id = detail::maybe_id<account_id_type>(id) )
return my->_remote_db->get_account_balances(*real_id, flat_set<asset_id_type>()); return my->_remote_db->get_account_balances(id, flat_set<asset_id_type>());
return my->_remote_db->get_account_balances(get_account(id).id, flat_set<asset_id_type>()); return my->_remote_db->get_account_balances(id, flat_set<asset_id_type>());
} }
vector<asset_object> wallet_api::list_assets(const string& lowerbound, uint32_t limit)const vector<asset_object> wallet_api::list_assets(const string& lowerbound, uint32_t limit)const
@ -3799,11 +3794,10 @@ vector<operation_detail> wallet_api::get_relative_account_history(string name, u
FC_ASSERT( start > 0 || limit <= 100 ); FC_ASSERT( start > 0 || limit <= 100 );
vector<operation_detail> result; vector<operation_detail> result;
auto account_id = get_account(name).get_id();
while( limit > 0 ) while( limit > 0 )
{ {
vector <operation_history_object> current = my->_remote_hist->get_relative_account_history(account_id, stop, std::min<uint32_t>(100, limit), start); vector <operation_history_object> current = my->_remote_hist->get_relative_account_history(name, stop, std::min<uint32_t>(100, limit), start);
for (auto &o : current) { for (auto &o : current) {
std::stringstream ss; std::stringstream ss;
auto memo = o.op.visit(detail::operation_printer(ss, *my, o.result)); auto memo = o.op.visit(detail::operation_printer(ss, *my, o.result));

View file

@ -55,25 +55,25 @@ BOOST_AUTO_TEST_CASE(get_account_history) {
int account_create_op_id = operation::tag<account_create_operation>::value; int account_create_op_id = operation::tag<account_create_operation>::value;
//account_id_type() did 3 ops and includes id0 //account_id_type() did 3 ops and includes id0
vector<operation_history_object> histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 100, operation_history_id_type()); vector<operation_history_object> histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 100, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u);
BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id);
// 1 account_create op larger than id1 // 1 account_create op larger than id1
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 100, operation_history_id_type()); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 100, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK(histories[0].id.instance() != 0); BOOST_CHECK(histories[0].id.instance() != 0);
BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id);
// Limit 2 returns 2 result // Limit 2 returns 2 result
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 2, operation_history_id_type()); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 2, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK(histories[1].id.instance() != 0); BOOST_CHECK(histories[1].id.instance() != 0);
BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id);
// bob has 1 op // bob has 1 op
histories = hist_api.get_account_history(bob_acc.get_id(), operation_history_id_type(), 100, operation_history_id_type()); histories = hist_api.get_account_history("bob", operation_history_id_type(), 100, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id);
} FC_LOG_AND_RETHROW() } FC_LOG_AND_RETHROW()
@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(zero_id_object) {
graphene::app::history_api hist_api(app); graphene::app::history_api hist_api(app);
// no history at all in the chain // no history at all in the chain
vector<operation_history_object> histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 4, operation_history_id_type(0)); vector<operation_history_object> histories = hist_api.get_account_history("committee-account", operation_history_id_type(0), 4, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
create_bitasset("USD", account_id_type()); // create op 0 create_bitasset("USD", account_id_type()); // create op 0
@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(zero_id_object) {
fc::usleep(fc::milliseconds(2000)); fc::usleep(fc::milliseconds(2000));
// what if the account only has one history entry and it is 0? // what if the account only has one history entry and it is 0?
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type()); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u);
} FC_LOG_AND_RETHROW() } FC_LOG_AND_RETHROW()
@ -107,13 +107,13 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
// account_id_type() and dan share operation id 1(account create) - share can be also in id 0 // account_id_type() and dan share operation id 1(account create) - share can be also in id 0
// no history at all in the chain // no history at all in the chain
vector<operation_history_object> histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 4, operation_history_id_type(0)); vector<operation_history_object> histories = hist_api.get_account_history("committee-account", operation_history_id_type(0), 4, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
create_bitasset("USD", account_id_type()); // create op 0 create_bitasset("USD", account_id_type()); // create op 0
generate_block(); generate_block();
// what if the account only has one history entry and it is 0? // what if the account only has one history entry and it is 0?
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type()); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u);
@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
generate_block(); generate_block();
// f(A, 0, 4, 9) = { 5, 3, 1, 0 } // f(A, 0, 4, 9) = { 5, 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(9)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(9));
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
// f(A, 0, 4, 6) = { 5, 3, 1, 0 } // f(A, 0, 4, 6) = { 5, 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(6)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(6));
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
// f(A, 0, 4, 5) = { 5, 3, 1, 0 } // f(A, 0, 4, 5) = { 5, 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(5)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(5));
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
@ -152,33 +152,33 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
// f(A, 0, 4, 4) = { 3, 1, 0 } // f(A, 0, 4, 4) = { 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(4)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(4));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u);
// f(A, 0, 4, 3) = { 3, 1, 0 } // f(A, 0, 4, 3) = { 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(3)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(3));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u);
// f(A, 0, 4, 2) = { 1, 0 } // f(A, 0, 4, 2) = { 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(2)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
// f(A, 0, 4, 1) = { 1, 0 } // f(A, 0, 4, 1) = { 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type(1)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type(1));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
// f(A, 0, 4, 0) = { 5, 3, 1, 0 } // f(A, 0, 4, 0) = { 5, 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 4, operation_history_id_type()); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 4, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
@ -186,103 +186,103 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
// f(A, 1, 5, 9) = { 5, 3 } // f(A, 1, 5, 9) = { 5, 3 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(9)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(9));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
// f(A, 1, 5, 6) = { 5, 3 } // f(A, 1, 5, 6) = { 5, 3 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(6)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(6));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
// f(A, 1, 5, 5) = { 5, 3 } // f(A, 1, 5, 5) = { 5, 3 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(5)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(5));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
// f(A, 1, 5, 4) = { 3 } // f(A, 1, 5, 4) = { 3 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(4)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(4));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
// f(A, 1, 5, 3) = { 3 } // f(A, 1, 5, 3) = { 3 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(3)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(3));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
// f(A, 1, 5, 2) = { } // f(A, 1, 5, 2) = { }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(2)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// f(A, 1, 5, 1) = { } // f(A, 1, 5, 1) = { }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(1)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(1));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// f(A, 1, 5, 0) = { 5, 3 } // f(A, 1, 5, 0) = { 5, 3 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 5, operation_history_id_type(0)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 5, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
// f(A, 0, 3, 9) = { 5, 3, 1 } // f(A, 0, 3, 9) = { 5, 3, 1 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(9)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(9));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
// f(A, 0, 3, 6) = { 5, 3, 1 } // f(A, 0, 3, 6) = { 5, 3, 1 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(6)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(6));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
// f(A, 0, 3, 5) = { 5, 3, 1 } // f(A, 0, 3, 5) = { 5, 3, 1 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(5)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(5));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
// f(A, 0, 3, 4) = { 3, 1, 0 } // f(A, 0, 3, 4) = { 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(4)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(4));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u);
// f(A, 0, 3, 3) = { 3, 1, 0 } // f(A, 0, 3, 3) = { 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(3)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(3));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u);
// f(A, 0, 3, 2) = { 1, 0 } // f(A, 0, 3, 2) = { 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(2)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
// f(A, 0, 3, 1) = { 1, 0 } // f(A, 0, 3, 1) = { 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type(1)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type(1));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
// f(A, 0, 3, 0) = { 5, 3, 1 } // f(A, 0, 3, 0) = { 5, 3, 1 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(), 3, operation_history_id_type()); histories = hist_api.get_account_history("committee-account", operation_history_id_type(), 3, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
// f(B, 0, 4, 9) = { 6, 4, 2, 1 } // f(B, 0, 4, 9) = { 6, 4, 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(9)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(9));
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
@ -290,7 +290,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u);
// f(B, 0, 4, 6) = { 6, 4, 2, 1 } // f(B, 0, 4, 6) = { 6, 4, 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(6)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(6));
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
@ -298,38 +298,38 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u);
// f(B, 0, 4, 5) = { 4, 2, 1 } // f(B, 0, 4, 5) = { 4, 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(5)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(5));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
// f(B, 0, 4, 4) = { 4, 2, 1 } // f(B, 0, 4, 4) = { 4, 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(4)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(4));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u);
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
// f(B, 0, 4, 3) = { 2, 1 } // f(B, 0, 4, 3) = { 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(3)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(3));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u);
// f(B, 0, 4, 2) = { 2, 1 } // f(B, 0, 4, 2) = { 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(2)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u);
// f(B, 0, 4, 1) = { 1 } // f(B, 0, 4, 1) = { 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type(1)); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(1));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u);
// f(B, 0, 4, 0) = { 6, 4, 2, 1 } // f(B, 0, 4, 0) = { 6, 4, 2, 1 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(), 4, operation_history_id_type()); histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type());
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
@ -337,49 +337,49 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u);
// f(B, 2, 4, 9) = { 6, 4 } // f(B, 2, 4, 9) = { 6, 4 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(9)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(9));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
// f(B, 2, 4, 6) = { 6, 4 } // f(B, 2, 4, 6) = { 6, 4 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(6)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(6));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
// f(B, 2, 4, 5) = { 4 } // f(B, 2, 4, 5) = { 4 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(5)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(5));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
// f(B, 2, 4, 4) = { 4 } // f(B, 2, 4, 4) = { 4 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(4)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(4));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
// f(B, 2, 4, 3) = { } // f(B, 2, 4, 3) = { }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(3)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(3));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// f(B, 2, 4, 2) = { } // f(B, 2, 4, 2) = { }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(2)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// f(B, 2, 4, 1) = { } // f(B, 2, 4, 1) = { }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(1)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(1));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// f(B, 2, 4, 0) = { 6, 4 } // f(B, 2, 4, 0) = { 6, 4 }
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(2), 4, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
// 0 limits // 0 limits
histories = hist_api.get_account_history(dan.get_id(), operation_history_id_type(0), 0, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 0, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(3), 0, operation_history_id_type(9)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(3), 0, operation_history_id_type(9));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// create a new account C = alice { 7 } // create a new account C = alice { 7 }
@ -388,16 +388,16 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
generate_block(); generate_block();
// f(C, 0, 4, 10) = { 7 } // f(C, 0, 4, 10) = { 7 }
histories = hist_api.get_account_history(alice.get_id(), operation_history_id_type(0), 4, operation_history_id_type(10)); histories = hist_api.get_account_history("alice", operation_history_id_type(0), 4, operation_history_id_type(10));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u);
// f(C, 8, 4, 10) = { } // f(C, 8, 4, 10) = { }
histories = hist_api.get_account_history(alice.get_id(), operation_history_id_type(8), 4, operation_history_id_type(10)); histories = hist_api.get_account_history("alice", operation_history_id_type(8), 4, operation_history_id_type(10));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// f(A, 0, 10, 0) = { 7, 5, 3, 1, 0 } // f(A, 0, 10, 0) = { 7, 5, 3, 1, 0 }
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 5u); BOOST_CHECK_EQUAL(histories.size(), 5u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 5u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 5u);
@ -432,23 +432,23 @@ BOOST_AUTO_TEST_CASE(track_account) {
// anything against account_id_type() should be {} // anything against account_id_type() should be {}
vector<operation_history_object> histories = vector<operation_history_object> histories =
hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0)); hist_api.get_account_history("committee-account", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 1, operation_history_id_type(2)); histories = hist_api.get_account_history("committee-account", operation_history_id_type(1), 1, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// anything against alice should be {} // anything against alice should be {}
histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("alice", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 1, operation_history_id_type(2)); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 1, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// dan should have history // dan should have history
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
@ -459,7 +459,7 @@ BOOST_AUTO_TEST_CASE(track_account) {
generate_block( ~database::skip_fork_db ); generate_block( ~database::skip_fork_db );
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
@ -473,7 +473,7 @@ BOOST_AUTO_TEST_CASE(track_account) {
generate_block(); generate_block();
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 3u); BOOST_CHECK_EQUAL(histories.size(), 3u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
@ -508,7 +508,7 @@ BOOST_AUTO_TEST_CASE(track_account2) {
generate_block(); generate_block();
// all account_id_type() should have 4 ops {4,2,1,0} // all account_id_type() should have 4 ops {4,2,1,0}
vector<operation_history_object> histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0)); vector<operation_history_object> histories = hist_api.get_account_history("committee-account", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 4u); BOOST_CHECK_EQUAL(histories.size(), 4u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u);
@ -516,27 +516,27 @@ BOOST_AUTO_TEST_CASE(track_account2) {
BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
// all alice account should have 2 ops {3, 0} // all alice account should have 2 ops {3, 0}
histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("alice", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
// alice first op should be {0} // alice first op should be {0}
histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 1, operation_history_id_type(1)); histories = hist_api.get_account_history("alice", operation_history_id_type(0), 1, operation_history_id_type(1));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u);
// alice second op should be {3} // alice second op should be {3}
histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 1, operation_history_id_type(0)); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 1, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
// anything against dan should be {} // anything against dan should be {}
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(dan_id, operation_history_id_type(1), 10, operation_history_id_type(0)); histories = hist_api.get_account_history("dan", operation_history_id_type(1), 10, operation_history_id_type(0));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
histories = hist_api.get_account_history(dan_id, operation_history_id_type(1), 1, operation_history_id_type(2)); histories = hist_api.get_account_history("dan", operation_history_id_type(1), 1, operation_history_id_type(2));
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
} catch (fc::exception &e) { } catch (fc::exception &e) {
@ -553,7 +553,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) {
int account_create_op_id = operation::tag<account_create_operation>::value; int account_create_op_id = operation::tag<account_create_operation>::value;
// no asset_create operation on account_id_type() should not throw any exception // no asset_create operation on account_id_type() should not throw any exception
vector<operation_history_object> histories = hist_api.get_account_history_operations(account_id_type(), asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); vector<operation_history_object> histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100);
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
//account_id_type() do 3 ops //account_id_type() do 3 ops
@ -565,27 +565,27 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) {
fc::usleep(fc::milliseconds(2000)); fc::usleep(fc::milliseconds(2000));
//account_id_type() did 1 asset_create op //account_id_type() did 1 asset_create op
histories = hist_api.get_account_history_operations(account_id_type(), asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100);
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u);
BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id);
//account_id_type() did 2 account_create ops //account_id_type() did 2 account_create ops
histories = hist_api.get_account_history_operations(account_id_type(), account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100);
BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories.size(), 2u);
BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id);
// No asset_create op larger than id1 // No asset_create op larger than id1
histories = hist_api.get_account_history_operations(account_id_type(), asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 100); histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 100);
BOOST_CHECK_EQUAL(histories.size(), 0u); BOOST_CHECK_EQUAL(histories.size(), 0u);
// Limit 1 returns 1 result // Limit 1 returns 1 result
histories = hist_api.get_account_history_operations(account_id_type(), account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1);
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id);
// alice has 1 op // alice has 1 op
histories = hist_api.get_account_history_operations(get_account("alice").id, account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100); histories = hist_api.get_account_history_operations("alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100);
BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories.size(), 1u);
BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id);

View file

@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_enabled)
INVOKE(put_my_witnesses); INVOKE(put_my_witnesses);
const account_id_type witness1_id= get_account("witness1").id; const account_id_type witness1_id= get_account("witness1").id;
auto witness1_object = db_api1.get_witness_by_account(witness1_id); auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name);
BOOST_CHECK_EQUAL(witness1_object->total_votes, 111); BOOST_CHECK_EQUAL(witness1_object->total_votes, 111);
} FC_LOG_AND_RETHROW() } FC_LOG_AND_RETHROW()
@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_disabled)
INVOKE(put_my_witnesses); INVOKE(put_my_witnesses);
const account_id_type witness1_id= get_account("witness1").id; const account_id_type witness1_id= get_account("witness1").id;
auto witness1_object = db_api1.get_witness_by_account(witness1_id); auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name);
BOOST_CHECK_EQUAL(witness1_object->total_votes, 0); BOOST_CHECK_EQUAL(witness1_object->total_votes, 0);
} FC_LOG_AND_RETHROW() } FC_LOG_AND_RETHROW()
@ -498,7 +498,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_enabled)
INVOKE(put_my_committee_members); INVOKE(put_my_committee_members);
const account_id_type committee1_id= get_account("committee1").id; const account_id_type committee1_id= get_account("committee1").id;
auto committee1_object = db_api1.get_committee_member_by_account(committee1_id); auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name);
BOOST_CHECK_EQUAL(committee1_object->total_votes, 111); BOOST_CHECK_EQUAL(committee1_object->total_votes, 111);
} FC_LOG_AND_RETHROW() } FC_LOG_AND_RETHROW()
@ -513,7 +513,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_disabled)
INVOKE(put_my_committee_members); INVOKE(put_my_committee_members);
const account_id_type committee1_id= get_account("committee1").id; const account_id_type committee1_id= get_account("committee1").id;
auto committee1_object = db_api1.get_committee_member_by_account(committee1_id); auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name);
BOOST_CHECK_EQUAL(committee1_object->total_votes, 0); BOOST_CHECK_EQUAL(committee1_object->total_votes, 0);
} FC_LOG_AND_RETHROW() } FC_LOG_AND_RETHROW()