diff --git a/.github/workflows/build-and-test.win.yml b/.github/workflows/build-and-test.win.yml index cc2fccc1a0..641cd7c497 100644 --- a/.github/workflows/build-and-test.win.yml +++ b/.github/workflows/build-and-test.win.yml @@ -8,7 +8,7 @@ env: BOOST_DOTTED_VERSION: 1.69.0 CURL_VERSION: 7.67.0 OPENSSL_VERSION: 1.1.1d - ZLIB_VERSION: 1.2.12 + ZLIB_VERSION: 1.2.13 jobs: prepare-mingw64-libs: name: Build required 3rd-party libraries diff --git a/libraries/app/CMakeLists.txt b/libraries/app/CMakeLists.txt index 43a2a55254..a4215ea500 100644 --- a/libraries/app/CMakeLists.txt +++ b/libraries/app/CMakeLists.txt @@ -16,8 +16,8 @@ add_library( graphene_app # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_elasticsearch graphene_grouped_orders - graphene_api_helper_indexes graphene_custom_operations - graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness ) + graphene_api_helper_indexes graphene_custom_operations graphene_debug_witness + graphene_chain graphene_net graphene_utilities fc ) target_include_directories( graphene_app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 3cec7094e4..1f252efb87 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -382,8 +382,8 @@ namespace graphene { namespace app { FC_ASSERT(_app.chain_database()); const auto& db = *_app.chain_database(); database_api_helper db_api_helper( _app ); - asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->id; - asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->id; + asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->get_id(); + asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->get_id(); if( a > b ) std::swap(a,b); const auto& history_idx = db.get_index_type().indices().get(); history_key hkey; @@ -426,7 +426,7 @@ namespace graphene { namespace app { account_id_type account; try { database_api_helper db_api_helper( _app ); - account = db_api_helper.get_account_from_string(account_id_or_name)->id; + account = db_api_helper.get_account_from_string(account_id_or_name)->get_id(); } catch(...) { return result; } if(_app.is_plugin_enabled("elasticsearch")) { @@ -479,8 +479,8 @@ namespace graphene { namespace app { account_id_type account; try { database_api_helper db_api_helper( _app ); - account = db_api_helper.get_account_from_string(account_name_or_id)->id; - } catch(...) { return result; } + account = db_api_helper.get_account_from_string(account_name_or_id)->get_id(); + } catch( const fc::exception& ) { return result; } fc::time_point_sec start = ostart.valid() ? *ostart : fc::time_point_sec::maximum(); @@ -490,7 +490,7 @@ namespace graphene { namespace app { return result; const auto& acc_hist_idx = db.get_index_type().indices().get(); - auto itr = acc_hist_idx.lower_bound( boost::make_tuple( account, op_hist_itr->id ) ); + auto itr = acc_hist_idx.lower_bound( boost::make_tuple( account, op_hist_itr->get_id() ) ); auto itr_end = acc_hist_idx.upper_bound( account ); while( itr != itr_end && result.size() < limit ) @@ -521,7 +521,7 @@ namespace graphene { namespace app { account_id_type account; try { database_api_helper db_api_helper( _app ); - account = db_api_helper.get_account_from_string(account_id_or_name)->id; + account = db_api_helper.get_account_from_string(account_id_or_name)->get_id(); } catch(...) { return result; } const auto& stats = account(db).statistics(db); if( stats.most_recent_op == account_history_id_type() ) return result; @@ -541,7 +541,7 @@ namespace graphene { namespace app { else node = &node->next(db); } if( stop.instance.value == 0 && result.size() < limit ) { - auto head = db.find(account_history_id_type()); + const auto* head = db.find(account_history_id_type()); if (head != nullptr && head->account == account && head->operation_id(db).op.which() == operation_type) result.push_back(head->operation_id(db)); } @@ -566,7 +566,7 @@ namespace graphene { namespace app { account_id_type account; try { database_api_helper db_api_helper( _app ); - account = db_api_helper.get_account_from_string(account_id_or_name)->id; + account = db_api_helper.get_account_from_string(account_id_or_name)->get_id(); } catch(...) { return result; } const auto& stats = account(db).statistics(db); if( start == 0 ) @@ -674,8 +674,8 @@ namespace graphene { namespace app { const auto& db = *_app.chain_database(); database_api_helper db_api_helper( _app ); - asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->id; - asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->id; + asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->get_id(); + asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->get_id(); vector result; const auto configured_limit = _app.get_options().api_limit_get_market_history; result.reserve( configured_limit ); @@ -899,7 +899,7 @@ namespace graphene { namespace app { ("configured_limit", configured_limit) ); database_api_helper db_api_helper( _app ); - asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->id; + asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->get_id(); const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); @@ -933,7 +933,7 @@ namespace graphene { namespace app { int64_t asset_api::get_asset_holders_count( const std::string& asset_symbol_or_id ) const { const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); database_api_helper db_api_helper( _app ); - asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->id; + asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->get_id(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); int64_t count = boost::distance(range) - 1; @@ -996,8 +996,8 @@ namespace graphene { namespace app { vector< limit_order_group > result; database_api_helper db_api_helper( _app ); - asset_id_type base_asset_id = db_api_helper.get_asset_from_string( base_asset )->id; - asset_id_type quote_asset_id = db_api_helper.get_asset_from_string( quote_asset )->id; + asset_id_type base_asset_id = db_api_helper.get_asset_from_string( base_asset )->get_id(); + asset_id_type quote_asset_id = db_api_helper.get_asset_from_string( quote_asset )->get_id(); price max_price = price::max( base_asset_id, quote_asset_id ); price min_price = price::min( base_asset_id, quote_asset_id ); @@ -1037,7 +1037,7 @@ namespace graphene { namespace app { if( o_account_name_or_id.valid() ) { const string& account_name_or_id = *o_account_name_or_id; - const account_id_type account_id = db_api_helper.get_account_from_string(account_name_or_id)->id; + const account_id_type account_id = db_api_helper.get_account_from_string(account_name_or_id)->get_id(); if( catalog.valid() ) { if( key.valid() ) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index dd83047566..ddd96aace9 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -61,7 +61,7 @@ database_api_helper::database_api_helper( graphene::chain::database& db, const a { // Nothing else to do } -database_api_helper::database_api_helper( graphene::app::application& app ) +database_api_helper::database_api_helper( const graphene::app::application& app ) :_db( *app.chain_database() ), _app_options( &app.get_options() ) { // Nothing else to do } @@ -486,7 +486,7 @@ bool database_api_impl::is_public_key_registered(string public_key) const account_id_type database_api::get_account_id_from_string(const std::string& name_or_id)const { - return my->get_account_from_string( name_or_id )->id; + return my->get_account_from_string( name_or_id )->get_id(); } vector> database_api::get_accounts( const vector& account_names_or_ids, @@ -573,7 +573,7 @@ std::map database_api_impl::get_full_accounts( const const auto& proposals_by_account = proposal_idx.get_secondary_index< graphene::chain::required_approval_index>(); - auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); + auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->get_id() ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), @@ -591,7 +591,7 @@ std::map database_api_impl::get_full_accounts( const // Add the account's balances const auto& balances = _db.get_index_type< primary_index< account_balance_index > >(). - get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); + get_secondary_index< balances_by_account_index >().get_account_balances( account->get_id() ); for( const auto& balance : balances ) { if(acnt.balances.size() >= api_limit_get_full_accounts_lists) { @@ -603,7 +603,7 @@ std::map database_api_impl::get_full_accounts( const // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get() - .equal_range(account->id); + .equal_range(account->get_id()); for(auto itr = vesting_range.first; itr != vesting_range.second; ++itr) { if(acnt.vesting_balances.size() >= api_limit_get_full_accounts_lists) { @@ -615,7 +615,7 @@ std::map database_api_impl::get_full_accounts( const // Add the account's orders auto order_range = _db.get_index_type().indices().get() - .equal_range(account->id); + .equal_range(account->get_id()); for(auto itr = order_range.first; itr != order_range.second; ++itr) { if(acnt.limit_orders.size() >= api_limit_get_full_accounts_lists) { @@ -624,7 +624,8 @@ std::map database_api_impl::get_full_accounts( const } acnt.limit_orders.emplace_back(*itr); } - auto call_range = _db.get_index_type().indices().get().equal_range(account->id); + auto call_range = _db.get_index_type().indices().get() + .equal_range(account->get_id()); for(auto itr = call_range.first; itr != call_range.second; ++itr) { if(acnt.call_orders.size() >= api_limit_get_full_accounts_lists) { @@ -634,7 +635,7 @@ std::map database_api_impl::get_full_accounts( const acnt.call_orders.emplace_back(*itr); } auto settle_range = _db.get_index_type().indices().get() - .equal_range(account->id); + .equal_range(account->get_id()); for(auto itr = settle_range.first; itr != settle_range.second; ++itr) { if(acnt.settle_orders.size() >= api_limit_get_full_accounts_lists) { @@ -645,19 +646,19 @@ std::map database_api_impl::get_full_accounts( const } // get assets issued by user - auto asset_range = _db.get_index_type().indices().get().equal_range(account->id); + auto asset_range = _db.get_index_type().indices().get().equal_range(account->get_id()); for(auto itr = asset_range.first; itr != asset_range.second; ++itr) { if(acnt.assets.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.assets = true; break; } - acnt.assets.emplace_back(itr->id); + acnt.assets.emplace_back(itr->get_id()); } // get withdraws permissions auto withdraw_indices = _db.get_index_type().indices(); - auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); + auto withdraw_from_range = withdraw_indices.get().equal_range(account->get_id()); for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) { if(acnt.withdraws_from.size() >= api_limit_get_full_accounts_lists) { @@ -666,7 +667,7 @@ std::map database_api_impl::get_full_accounts( const } acnt.withdraws_from.emplace_back(*itr); } - auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); + auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->get_id()); for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { if(acnt.withdraws_to.size() >= api_limit_get_full_accounts_lists) { @@ -677,7 +678,8 @@ std::map database_api_impl::get_full_accounts( const } // get htlcs - auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); + auto htlc_from_range = _db.get_index_type().indices().get() + .equal_range(account->get_id()); for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) { if(acnt.htlcs_from.size() >= api_limit_get_full_accounts_lists) { @@ -686,7 +688,7 @@ std::map database_api_impl::get_full_accounts( const } acnt.htlcs_from.emplace_back(*itr); } - auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); + auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->get_id()); for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) { if(acnt.htlcs_to.size() >= api_limit_get_full_accounts_lists) { @@ -750,7 +752,7 @@ vector database_api_impl::get_account_references( const std::st const auto& idx = _db.get_index_type(); const auto& aidx = dynamic_cast(idx); const auto& refs = aidx.get_secondary_index(); - const account_id_type account_id = get_account_from_string(account_id_or_name)->id; + const account_id_type account_id = get_account_from_string(account_id_or_name)->get_id(); auto itr = refs.account_to_account_memberships.find(account_id); vector result; @@ -834,7 +836,7 @@ vector database_api_impl::get_account_balances( const std::string& accoun const flat_set& assets )const { const account_object* account = get_account_from_string(account_name_or_id); - account_id_type acnt = account->id; + account_id_type acnt = account->get_id(); vector result; if (assets.empty()) { @@ -917,7 +919,7 @@ vector database_api_impl::get_vesting_balances( const st { try { - const account_id_type account_id = get_account_from_string(account_id_or_name)->id; + const account_id_type account_id = get_account_from_string(account_id_or_name)->get_id(); vector result; auto vesting_range = _db.get_index_type().indices().get() .equal_range(account_id); @@ -938,7 +940,7 @@ vector database_api_impl::get_vesting_balances( const st asset_id_type database_api::get_asset_id_from_string(const std::string& symbol_or_id)const { - return my->get_asset_from_string( symbol_or_id )->id; + return my->get_asset_from_string( symbol_or_id )->get_id(); } vector> database_api::get_assets( @@ -1018,10 +1020,10 @@ vector database_api_impl::get_assets_by_issuer(const std: ("configured_limit", configured_limit) ); vector result; - const account_id_type account = get_account_from_string(issuer_name_or_id)->id; + const account_id_type account = get_account_from_string(issuer_name_or_id)->get_id(); const auto& asset_idx = _db.get_index_type().indices().get(); auto asset_index_end = asset_idx.end(); - auto asset_itr = asset_idx.lower_bound(boost::make_tuple(account, start)); + auto asset_itr = asset_idx.lower_bound(boost::make_tuple(account, object_id_type(start))); while(asset_itr != asset_index_end && asset_itr->issuer == account && result.size() < limit) { result.emplace_back( extend_asset( *asset_itr ) ); @@ -1062,8 +1064,8 @@ vector database_api_impl::get_limit_orders( const std::strin "limit can not be greater than ${configured_limit}", ("configured_limit", configured_limit) ); - const asset_id_type asset_a_id = get_asset_from_string(a)->id; - const asset_id_type asset_b_id = get_asset_from_string(b)->id; + const asset_id_type asset_a_id = get_asset_from_string(a)->get_id(); + const asset_id_type asset_b_id = get_asset_from_string(b)->get_id(); return get_limit_orders(asset_a_id, asset_b_id, limit); } @@ -1090,11 +1092,12 @@ vector database_api_impl::get_limit_orders_by_account( const if (account == nullptr) return results; - limit_order_id_type start_id = ostart_id.valid() ? *ostart_id : limit_order_id_type(); + limit_order_id_type start_order_id = ostart_id.valid() ? *ostart_id : limit_order_id_type(); + object_id_type start_id { start_order_id }; const auto& index_by_account = _db.get_index_type().indices().get(); - auto lower_itr = index_by_account.lower_bound( std::make_tuple( account->id, start_id ) ); - auto upper_itr = index_by_account.upper_bound( account->id ); + auto lower_itr = index_by_account.lower_bound( std::make_tuple( account->get_id(), start_id ) ); + auto upper_itr = index_by_account.upper_bound( account->get_id() ); results.reserve( limit ); uint32_t count = 0; @@ -1135,8 +1138,8 @@ vector database_api_impl::get_account_limit_orders( FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + auto base_id = assets[0]->get_id(); + auto quote_id = assets[1]->get_id(); if (ostart_price.valid()) { FC_ASSERT(ostart_price->base.asset_id == base_id, "Base asset inconsistent with start price"); @@ -1150,10 +1153,11 @@ vector database_api_impl::get_account_limit_orders( // if both order_id and price are invalid, query the first page if ( !ostart_id.valid() && !ostart_price.valid() ) { - lower_itr = index_by_account.lower_bound(std::make_tuple(account->id, price::max(base_id, quote_id))); + lower_itr = index_by_account.lower_bound(std::make_tuple(account->get_id(), price::max(base_id, quote_id))); } else if ( ostart_id.valid() ) { + object_id_type start_id { *ostart_id }; // in case of the order been deleted during page querying const limit_order_object *p_loo = _db.find(*ostart_id); @@ -1161,7 +1165,7 @@ vector database_api_impl::get_account_limit_orders( { if ( ostart_price.valid() ) { - lower_itr = index_by_account.lower_bound(std::make_tuple(account->id, *ostart_price, *ostart_id)); + lower_itr = index_by_account.lower_bound(std::make_tuple(account->get_id(), *ostart_price, start_id)); } else { @@ -1178,16 +1182,16 @@ vector database_api_impl::get_account_limit_orders( FC_ASSERT(loo.sell_price.quote.asset_id == quote_id, "Order quote asset inconsistent with order"); FC_ASSERT(loo.seller == account->get_id(), "Order not owned by specified account"); - lower_itr = index_by_account.lower_bound(std::make_tuple(account->id, loo.sell_price, *ostart_id)); + lower_itr = index_by_account.lower_bound(std::make_tuple(account->get_id(), loo.sell_price, start_id)); } } else { // if reach here start_price must be valid - lower_itr = index_by_account.lower_bound(std::make_tuple(account->id, *ostart_price)); + lower_itr = index_by_account.lower_bound(std::make_tuple(account->get_id(), *ostart_price)); } - upper_itr = index_by_account.upper_bound(std::make_tuple(account->id, price::min(base_id, quote_id))); + upper_itr = index_by_account.upper_bound(std::make_tuple(account->get_id(), price::min(base_id, quote_id))); // Add the account's orders for ( ; lower_itr != upper_itr && count < limit; ++lower_itr, ++count) @@ -1243,7 +1247,7 @@ vector database_api_impl::get_call_orders_by_account(const st ("configured_limit", configured_limit) ); vector result; - const account_id_type account = get_account_from_string(account_name_or_id)->id; + const account_id_type account = get_account_from_string(account_name_or_id)->get_id(); const auto& call_idx = _db.get_index_type().indices().get(); auto call_index_end = call_idx.end(); auto call_itr = call_idx.lower_bound(boost::make_tuple(account, start)); @@ -1268,7 +1272,7 @@ vector database_api_impl::get_settle_orders(const std:: "limit can not be greater than ${configured_limit}", ("configured_limit", configured_limit) ); - const asset_id_type asset_a_id = get_asset_from_string(a)->id; + const asset_id_type asset_a_id = get_asset_from_string(a)->get_id(); const auto& settle_index = _db.get_index_type().indices().get(); const asset_object& mia = _db.get(asset_a_id); @@ -1303,10 +1307,10 @@ vector database_api_impl::get_settle_orders_by_account( ("configured_limit", configured_limit) ); vector result; - const account_id_type account = get_account_from_string(account_name_or_id)->id; + const account_id_type account = get_account_from_string(account_name_or_id)->get_id(); const auto& settle_idx = _db.get_index_type().indices().get(); auto settle_index_end = settle_idx.end(); - auto settle_itr = settle_idx.lower_bound(boost::make_tuple(account, start)); + auto settle_itr = settle_idx.lower_bound(boost::make_tuple(account, object_id_type(start))); while(settle_itr != settle_index_end && settle_itr->owner == account && result.size() < limit) { result.push_back(*settle_itr); @@ -1340,7 +1344,7 @@ vector database_api_impl::get_collateral_bids( const std: const asset_object& swan = *get_asset_from_string(asset_id_or_symbol); FC_ASSERT( swan.is_market_issued(), "Asset is not a MPA" ); - const asset_id_type asset_id = swan.id; + const asset_id_type asset_id = swan.get_id(); const auto& idx = _db.get_index_type().indices().get(); auto itr = idx.lower_bound( asset_id ); auto end = idx.upper_bound( asset_id ); @@ -1362,8 +1366,8 @@ void database_api::subscribe_to_market( std::function call void database_api_impl::subscribe_to_market( std::function callback, const std::string& a, const std::string& b ) { - auto asset_a_id = get_asset_from_string(a)->id; - auto asset_b_id = get_asset_from_string(b)->id; + auto asset_a_id = get_asset_from_string(a)->get_id(); + auto asset_b_id = get_asset_from_string(b)->get_id(); if(asset_a_id > asset_b_id) std::swap(asset_a_id,asset_b_id); FC_ASSERT(asset_a_id != asset_b_id); @@ -1377,8 +1381,8 @@ void database_api::unsubscribe_from_market(const std::string& a, const std::stri void database_api_impl::unsubscribe_from_market(const std::string& a, const std::string& b) { - auto asset_a_id = get_asset_from_string(a)->id; - auto asset_b_id = get_asset_from_string(b)->id; + auto asset_a_id = get_asset_from_string(a)->get_id(); + auto asset_b_id = get_asset_from_string(b)->get_id(); if(a > b) std::swap(asset_a_id,asset_b_id); FC_ASSERT(asset_a_id != asset_b_id); @@ -1399,8 +1403,8 @@ market_ticker database_api_impl::get_ticker( const string& base, const string& q FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + auto base_id = assets[0]->get_id(); + auto quote_id = assets[1]->get_id(); if( base_id > quote_id ) std::swap( base_id, quote_id ); const auto& ticker_idx = _db.get_index_type().indices().get(); auto itr = ticker_idx.find( std::make_tuple( base_id, quote_id ) ); @@ -1457,8 +1461,8 @@ order_book database_api_impl::get_order_book( const string& base, const string& FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + auto base_id = assets[0]->get_id(); + auto quote_id = assets[1]->get_id(); auto orders = get_limit_orders( base_id, quote_id, limit ); for( const auto& o : orders ) @@ -1470,7 +1474,7 @@ order_book database_api_impl::get_order_book( const string& base, const string& * o.sell_price.quote.amount.value / o.sell_price.base.amount.value ) ); auto base_amt = assets[0]->amount_to_string( o.for_sale ); - result.bids.emplace_back( order_price, quote_amt, base_amt, o.id, + result.bids.emplace_back( order_price, quote_amt, base_amt, o.get_id(), o.seller, o.seller(_db).name, o.expiration ); } else @@ -1479,7 +1483,7 @@ order_book database_api_impl::get_order_book( const string& base, const string& auto base_amt = assets[0]->amount_to_string( share_type( fc::uint128_t( o.for_sale.value ) * o.sell_price.quote.amount.value / o.sell_price.base.amount.value ) ); - result.asks.emplace_back( order_price, quote_amt, base_amt, o.id, + result.asks.emplace_back( order_price, quote_amt, base_amt, o.get_id(), o.seller, o.seller(_db).name, o.expiration ); } } @@ -1546,8 +1550,8 @@ vector database_api_impl::get_trade_history( const string& base, FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + auto base_id = assets[0]->get_id(); + auto quote_id = assets[1]->get_id(); if( base_id > quote_id ) std::swap( base_id, quote_id ); @@ -1652,8 +1656,8 @@ vector database_api_impl::get_trade_history_by_sequence( FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + auto base_id = assets[0]->get_id(); + auto quote_id = assets[1]->get_id(); if( base_id > quote_id ) std::swap( base_id, quote_id ); const auto& history_idx = _db.get_index_type().indices().get(); @@ -1762,7 +1766,7 @@ vector database_api::get_liquidity_pools_by_asse const optional& start_id, const optional& with_statistics )const { - asset_id_type asset_id = my->get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type asset_id = my->get_asset_from_string(asset_symbol_or_id)->get_id(); return my->get_liquidity_pools_by_asset_x( limit, start_id, @@ -1776,7 +1780,7 @@ vector database_api::get_liquidity_pools_by_asse const optional& start_id, const optional& with_statistics )const { - asset_id_type asset_id = my->get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type asset_id = my->get_asset_from_string(asset_symbol_or_id)->get_id(); return my->get_liquidity_pools_by_asset_x( limit, start_id, @@ -1813,7 +1817,7 @@ vector database_api_impl::get_liquidity_pools_by "limit can not be greater than ${configured_limit}", ("configured_limit", configured_limit) ); - asset_id_type aid = get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type aid = get_asset_from_string(asset_symbol_or_id)->get_id(); FC_ASSERT( asset_in_liquidity_pools_index, "Internal error" ); const auto& pools = asset_in_liquidity_pools_index->get_liquidity_pools_by_asset( aid ); @@ -1843,8 +1847,8 @@ vector database_api::get_liquidity_pools_by_both const optional& start_id, const optional& with_statistics )const { - asset_id_type asset_id_a = my->get_asset_from_string(asset_symbol_or_id_a)->id; - asset_id_type asset_id_b = my->get_asset_from_string(asset_symbol_or_id_b)->id; + asset_id_type asset_id_a = my->get_asset_from_string(asset_symbol_or_id_a)->get_id(); + asset_id_type asset_id_b = my->get_asset_from_string(asset_symbol_or_id_b)->get_id(); if( asset_id_a > asset_id_b ) std::swap( asset_id_a, asset_id_b ); return my->get_liquidity_pools_by_asset_x( @@ -1976,9 +1980,10 @@ vector database_api_impl::get_liquidity_pools_by vector results; - account_id_type owner = get_account_from_string(account_name_or_id)->id; + account_id_type owner = get_account_from_string(account_name_or_id)->get_id(); - asset_id_type start_id = ostart_id.valid() ? *ostart_id : asset_id_type(); + asset_id_type start_asset_id = ostart_id.valid() ? *ostart_id : asset_id_type(); + object_id_type start_id { start_asset_id }; // get assets owned by account const auto& idx = _db.get_index_type().indices().get(); @@ -2019,7 +2024,7 @@ vector database_api::get_samet_funds_by_owner( const optional& limit, const optional& start_id )const { - account_id_type owner = my->get_account_from_string(account_name_or_id)->id; + account_id_type owner = my->get_account_from_string(account_name_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< samet_fund_object, samet_fund_id_type @@ -2032,7 +2037,7 @@ vector database_api::get_samet_funds_by_asset( const optional& limit, const optional& start_id )const { - asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< samet_fund_object, samet_fund_id_type @@ -2063,7 +2068,7 @@ vector database_api::get_credit_offers_by_owner( const optional& limit, const optional& start_id )const { - account_id_type owner = my->get_account_from_string(account_name_or_id)->id; + account_id_type owner = my->get_account_from_string(account_name_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< credit_offer_object, credit_offer_id_type @@ -2076,7 +2081,7 @@ vector database_api::get_credit_offers_by_asset( const optional& limit, const optional& start_id )const { - asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< credit_offer_object, credit_offer_id_type @@ -2112,7 +2117,7 @@ vector database_api::get_credit_deals_by_offer_owner( const optional& limit, const optional& start_id )const { - account_id_type owner = my->get_account_from_string(account_name_or_id)->id; + account_id_type owner = my->get_account_from_string(account_name_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< credit_deal_object, credit_deal_id_type @@ -2125,7 +2130,7 @@ vector database_api::get_credit_deals_by_borrower( const optional& limit, const optional& start_id )const { - account_id_type borrower = my->get_account_from_string(account_name_or_id)->id; + account_id_type borrower = my->get_account_from_string(account_name_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< credit_deal_object, credit_deal_id_type @@ -2138,7 +2143,7 @@ vector database_api::get_credit_deals_by_debt_asset( const optional& limit, const optional& start_id )const { - asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< credit_deal_object, credit_deal_id_type @@ -2151,7 +2156,7 @@ vector database_api::get_credit_deals_by_collateral_asset( const optional& limit, const optional& start_id )const { - asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->id; + asset_id_type asset_type = my->get_asset_from_string(asset_symbol_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< credit_deal_object, credit_deal_id_type @@ -2191,7 +2196,7 @@ fc::optional database_api::get_witness_by_account(const std::str fc::optional database_api_impl::get_witness_by_account(const std::string& account_id_or_name) const { const auto& idx = _db.get_index_type().indices().get(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); auto itr = idx.find(account); if( itr != idx.end() ) return *itr; @@ -2225,7 +2230,7 @@ map database_api_impl::lookup_witness_accounts( const s for (const witness_object& witness : witnesses_by_id) if (auto account_iter = _db.find(witness.witness_account)) if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name - witnesses_by_account_name.insert(std::make_pair(account_iter->name, witness.id)); + witnesses_by_account_name.insert(std::make_pair(account_iter->name, witness.get_id())); auto end_iter = witnesses_by_account_name.begin(); while( end_iter != witnesses_by_account_name.end() && limit > 0 ) @@ -2282,7 +2287,7 @@ fc::optional database_api_impl::get_committee_member_by const std::string& account_id_or_name )const { const auto& idx = _db.get_index_type().indices().get(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); auto itr = idx.find(account); if( itr != idx.end() ) return *itr; @@ -2314,9 +2319,9 @@ map database_api_impl::lookup_committee_member // TODO optimize std::map committee_members_by_account_name; for (const committee_member_object& committee_member : committee_members_by_id) - if (auto account_iter = _db.find(committee_member.committee_member_account)) - if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name - committee_members_by_account_name.insert(std::make_pair(account_iter->name, committee_member.id)); + if (auto account_iter = _db.find(committee_member.committee_member_account)) + if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name + committee_members_by_account_name.insert(std::make_pair(account_iter->name, committee_member.get_id())); auto end_iter = committee_members_by_account_name.begin(); while( end_iter != committee_members_by_account_name.end() && limit > 0 ) @@ -2388,7 +2393,7 @@ vector database_api_impl::get_workers_by_account(const std::strin vector result; const auto& workers_idx = _db.get_index_type().indices().get(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); auto range = workers_idx.equal_range(account); for(auto itr = range.first; itr != range.second; ++itr) { @@ -2642,7 +2647,7 @@ bool database_api_impl::verify_account_authority( const string& account_name_or_ { // create a dummy transfer transfer_operation op; - op.from = get_account_from_string(account_name_or_id)->id; + op.from = get_account_from_string(account_name_or_id)->get_id(); std::vector ops; ops.emplace_back(op); @@ -2779,7 +2784,7 @@ vector database_api_impl::get_proposed_transactions( const std: const auto& proposals_by_account = proposal_idx.get_secondary_index(); vector result; - const account_id_type id = get_account_from_string(account_id_or_name)->id; + const account_id_type id = get_account_from_string(account_id_or_name)->get_id(); auto required_approvals_itr = proposals_by_account._account_to_proposals.find( id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) @@ -2849,8 +2854,8 @@ vector database_api_impl::get_withdraw_permissions_b const auto& withdraw_idx = _db.get_index_type().indices().get(); auto withdraw_index_end = withdraw_idx.end(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; - auto withdraw_itr = withdraw_idx.lower_bound(boost::make_tuple(account, start)); + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); + auto withdraw_itr = withdraw_idx.lower_bound(boost::make_tuple(account, object_id_type(start))); while( withdraw_itr != withdraw_index_end && withdraw_itr->withdraw_from_account == account && result.size() < limit ) { @@ -2883,8 +2888,8 @@ vector database_api_impl::get_withdraw_permissions_b const auto& withdraw_idx = _db.get_index_type().indices().get(); auto withdraw_index_end = withdraw_idx.end(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; - auto withdraw_itr = withdraw_idx.lower_bound(boost::make_tuple(account, start)); + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); + auto withdraw_itr = withdraw_idx.lower_bound(boost::make_tuple(account, object_id_type(start))); while(withdraw_itr != withdraw_index_end && withdraw_itr->authorized_account == account && result.size() < limit) { result.push_back(*withdraw_itr); @@ -2906,7 +2911,7 @@ optional database_api::get_htlc( htlc_id_type id, optional su fc::optional database_api_impl::get_htlc( htlc_id_type id, optional subscribe )const { - auto obj = get_objects( { id }, subscribe ).front(); + auto obj = get_objects( { object_id_type(id) }, subscribe ).front(); if ( !obj.is_null() ) { return fc::optional(obj.template as(GRAPHENE_MAX_NESTED_OBJECTS)); @@ -2933,8 +2938,8 @@ vector database_api_impl::get_htlc_by_from( const std::string accou const auto& htlc_idx = _db.get_index_type< htlc_index >().indices().get< by_from_id >(); auto htlc_index_end = htlc_idx.end(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; - auto htlc_itr = htlc_idx.lower_bound(boost::make_tuple(account, start)); + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); + auto htlc_itr = htlc_idx.lower_bound(boost::make_tuple(account, object_id_type(start))); while(htlc_itr != htlc_index_end && htlc_itr->transfer.from == account && result.size() < limit) { @@ -2963,8 +2968,8 @@ vector database_api_impl::get_htlc_by_to( const std::string account const auto& htlc_idx = _db.get_index_type< htlc_index >().indices().get< by_to_id >(); auto htlc_index_end = htlc_idx.end(); - const account_id_type account = get_account_from_string(account_id_or_name)->id; - auto htlc_itr = htlc_idx.lower_bound(boost::make_tuple(account, start)); + const account_id_type account = get_account_from_string(account_id_or_name)->get_id(); + auto htlc_itr = htlc_idx.lower_bound(boost::make_tuple(account, object_id_type(start))); while(htlc_itr != htlc_index_end && htlc_itr->transfer.to == account && result.size() < limit) { @@ -2989,7 +2994,7 @@ vector database_api_impl::list_htlcs(const htlc_id_type start, uint vector result; const auto& htlc_idx = _db.get_index_type().indices().get(); - auto itr = htlc_idx.lower_bound(start); + auto itr = htlc_idx.lower_bound(object_id_type(start)); while(itr != htlc_idx.end() && result.size() < limit) { result.push_back(*itr); @@ -3020,7 +3025,7 @@ vector database_api::get_tickets_by_account( const optional& limit, const optional& start_id )const { - account_id_type account = my->get_account_from_string(account_name_or_id)->id; + account_id_type account = my->get_account_from_string(account_name_or_id)->get_id(); const auto& idx = my->_db.get_index_type().indices().get(); return my->get_objects_by_x< ticket_object, ticket_id_type @@ -3253,15 +3258,15 @@ void database_api_impl::handle_object_changed( bool force_notify, for(auto id : ids) { - if( id.is() ) + if( id.is() ) { enqueue_if_subscribed_to_market( find_object(id), broadcast_queue, full_object ); } - else if( id.is() ) + else if( id.is() ) { enqueue_if_subscribed_to_market( find_object(id), broadcast_queue, full_object ); } - else if( id.is() ) + else if( id.is() ) { enqueue_if_subscribed_to_market( find_object(id), broadcast_queue, full_object ); diff --git a/libraries/app/database_api_helper.hxx b/libraries/app/database_api_helper.hxx index 1c2898b42f..4b71a421c2 100644 --- a/libraries/app/database_api_helper.hxx +++ b/libraries/app/database_api_helper.hxx @@ -29,7 +29,7 @@ class database_api_helper { public: database_api_helper( graphene::chain::database& db, const application_options* app_options ); - explicit database_api_helper( graphene::app::application& app ); + explicit database_api_helper( const graphene::app::application& app ); // Member variables graphene::chain::database& _db; @@ -78,15 +78,17 @@ public: vector results; - OBJ_ID_TYPE start_id = ostart_id.valid() ? *ostart_id : OBJ_ID_TYPE(); + OBJ_ID_TYPE start_obj_id = ostart_id.valid() ? *ostart_id : OBJ_ID_TYPE(); + object_id_type start_id { start_obj_id }; auto lower_itr = idx.lower_bound( make_tuple_if_multiple( x..., start_id ) ); auto upper_itr = call_end_or_upper_bound( idx, x... ); results.reserve( limit ); - for ( ; lower_itr != upper_itr && results.size() < limit; ++lower_itr ) + while( lower_itr != upper_itr && results.size() < limit ) { results.emplace_back( *lower_itr ); + ++lower_itr; } return results; diff --git a/libraries/app/database_api_impl.hxx b/libraries/app/database_api_impl.hxx index 86a4c31d80..04f9f92a24 100644 --- a/libraries/app/database_api_impl.hxx +++ b/libraries/app/database_api_impl.hxx @@ -230,7 +230,7 @@ class database_api_impl : public std::enable_shared_from_this template extended_asset_object extend_asset( ASSET&& a )const { - asset_id_type id = a.id; + asset_id_type id = a.get_id(); extended_asset_object result = extended_asset_object( std::forward( a ) ); if( amount_in_collateral_index ) { @@ -260,12 +260,12 @@ class database_api_impl : public std::enable_shared_from_this template extended_liquidity_pool_object extend_liquidity_pool( LP&& a, bool with_stats )const { - liquidity_pool_id_type id = a.id; + liquidity_pool_id_type id = a.get_id(); extended_liquidity_pool_object result = extended_liquidity_pool_object( std::forward( a ) ); if( with_stats && _app_options && _app_options->has_market_history_plugin ) { liquidity_pool_ticker_id_type ticker_id( id.instance ); - const liquidity_pool_ticker_object* ticker = _db.find( ticker_id ); + const liquidity_pool_ticker_object* ticker = _db.find( ticker_id ); if( ticker ) result.statistics = *ticker; } @@ -291,7 +291,8 @@ class database_api_impl : public std::enable_shared_from_this vector results; - liquidity_pool_id_type start_id = ostart_id.valid() ? *ostart_id : liquidity_pool_id_type(); + liquidity_pool_id_type start_pool_id = ostart_id.valid() ? *ostart_id : liquidity_pool_id_type(); + object_id_type start_id { start_pool_id }; const auto& idx = _db.get_index_type().indices().get(); @@ -341,7 +342,7 @@ class database_api_impl : public std::enable_shared_from_this if( !_subscribe_callback ) return; - vector key = get_subscription_key( item ); + vector key = get_subscription_key( object_id_type(item) ); if( !_subscribe_filter.contains( key.data(), key.size() ) ) { _subscribe_filter.insert( key.data(), key.size() ); @@ -354,7 +355,7 @@ class database_api_impl : public std::enable_shared_from_this if( !_subscribe_callback ) return false; - vector key = get_subscription_key( item ); + vector key = get_subscription_key( object_id_type(item) ); return _subscribe_filter.contains( key.data(), key.size() ); } diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index c13440f5d1..e15a02a032 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -77,7 +77,7 @@ add_library( graphene_chain ) add_dependencies( graphene_chain build_hardfork_hpp ) -target_link_libraries( graphene_chain fc graphene_db graphene_protocol ) +target_link_libraries( graphene_chain graphene_db graphene_protocol fc ) target_include_directories( graphene_chain PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" ) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 7fc5dda0ec..dbcbbdf22a 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -48,7 +48,7 @@ void verify_authority_accounts( const database& db, const authority& a ) "Maximum authority membership exceeded" ); for( const auto& acnt : a.account_auths ) { - GRAPHENE_ASSERT( db.find_object( acnt.first ) != nullptr, + GRAPHENE_ASSERT( db.find( acnt.first ) != nullptr, internal_verify_auth_account_not_found, "Account ${a} specified in authority does not exist", ("a", acnt.first) ); @@ -69,7 +69,7 @@ void verify_account_votes( const database& db, const account_options& options ) FC_ASSERT( options.num_committee <= chain_params.maximum_committee_count, "Voted for more committee members than currently allowed (${c})", ("c", chain_params.maximum_committee_count) ); - FC_ASSERT( db.find_object(options.voting_account), "Invalid proxy account specified." ); + FC_ASSERT( db.find(options.voting_account), "Invalid proxy account specified." ); uint32_t max_vote_id = gpo.next_available_vote_id; bool has_worker_votes = false; diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 7137801475..f031f6a2f1 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -138,36 +138,38 @@ void account_member_index::object_inserted(const object& obj) { assert( dynamic_cast(&obj) ); // for debug only const account_object& a = static_cast(obj); + const account_id_type account_id = a.get_id(); auto account_members = get_account_members(a); for( auto item : account_members ) - account_to_account_memberships[item].insert(obj.id); + account_to_account_memberships[item].insert(account_id); auto key_members = get_key_members(a); for( auto item : key_members ) - account_to_key_memberships[item].insert(obj.id); + account_to_key_memberships[item].insert(account_id); auto address_members = get_address_members(a); for( auto item : address_members ) - account_to_address_memberships[item].insert(obj.id); + account_to_address_memberships[item].insert(account_id); } void account_member_index::object_removed(const object& obj) { assert( dynamic_cast(&obj) ); // for debug only const account_object& a = static_cast(obj); + const account_id_type account_id = a.get_id(); auto key_members = get_key_members(a); for( auto item : key_members ) - account_to_key_memberships[item].erase( obj.id ); + account_to_key_memberships[item].erase( account_id ); auto address_members = get_address_members(a); for( auto item : address_members ) - account_to_address_memberships[item].erase( obj.id ); + account_to_address_memberships[item].erase( account_id ); auto account_members = get_account_members(a); for( auto item : account_members ) - account_to_account_memberships[item].erase( obj.id ); + account_to_account_memberships[item].erase( account_id ); } void account_member_index::about_to_modify(const object& before) @@ -185,65 +187,72 @@ void account_member_index::object_modified(const object& after) { assert( dynamic_cast(&after) ); // for debug only const account_object& a = static_cast(after); + const account_id_type account_id = a.get_id(); { set after_account_members = get_account_members(a); - vector removed; removed.reserve(before_account_members.size()); + vector removed; + removed.reserve(before_account_members.size()); std::set_difference(before_account_members.begin(), before_account_members.end(), after_account_members.begin(), after_account_members.end(), std::inserter(removed, removed.end())); for( auto itr = removed.begin(); itr != removed.end(); ++itr ) - account_to_account_memberships[*itr].erase(after.id); + account_to_account_memberships[*itr].erase(account_id); - vector added; added.reserve(after_account_members.size()); + vector added; + added.reserve(after_account_members.size()); std::set_difference(after_account_members.begin(), after_account_members.end(), before_account_members.begin(), before_account_members.end(), std::inserter(added, added.end())); for( auto itr = added.begin(); itr != added.end(); ++itr ) - account_to_account_memberships[*itr].insert(after.id); + account_to_account_memberships[*itr].insert(account_id); } { set after_key_members = get_key_members(a); - vector removed; removed.reserve(before_key_members.size()); + vector removed; + removed.reserve(before_key_members.size()); std::set_difference(before_key_members.begin(), before_key_members.end(), after_key_members.begin(), after_key_members.end(), std::inserter(removed, removed.end())); for( auto itr = removed.begin(); itr != removed.end(); ++itr ) - account_to_key_memberships[*itr].erase(after.id); + account_to_key_memberships[*itr].erase(account_id); - vector added; added.reserve(after_key_members.size()); + vector added; + added.reserve(after_key_members.size()); std::set_difference(after_key_members.begin(), after_key_members.end(), before_key_members.begin(), before_key_members.end(), std::inserter(added, added.end())); for( auto itr = added.begin(); itr != added.end(); ++itr ) - account_to_key_memberships[*itr].insert(after.id); + account_to_key_memberships[*itr].insert(account_id); } { set
after_address_members = get_address_members(a); - vector
removed; removed.reserve(before_address_members.size()); + vector
removed; + removed.reserve(before_address_members.size()); std::set_difference(before_address_members.begin(), before_address_members.end(), after_address_members.begin(), after_address_members.end(), std::inserter(removed, removed.end())); for( auto itr = removed.begin(); itr != removed.end(); ++itr ) - account_to_address_memberships[*itr].erase(after.id); + account_to_address_memberships[*itr].erase(account_id); - vector
added; added.reserve(after_address_members.size()); + vector
added; + added.reserve(after_address_members.size()); std::set_difference(after_address_members.begin(), after_address_members.end(), before_address_members.begin(), before_address_members.end(), std::inserter(added, added.end())); for( auto itr = added.begin(); itr != added.end(); ++itr ) - account_to_address_memberships[*itr].insert(after.id); + account_to_address_memberships[*itr].insert(account_id); } } diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index e17b4b8fdf..17ab836be9 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -220,9 +220,9 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o // Check that all authorities do exist for( auto id : op.common_options.whitelist_authorities ) - d.get_object(id); + d.get(id); for( auto id : op.common_options.blacklist_authorities ) - d.get_object(id); + d.get(id); auto& asset_indx = d.get_index_type().indices().get(); auto asset_symbol_itr = asset_indx.find( op.symbol ); @@ -428,7 +428,7 @@ void_result asset_fund_fee_pool_evaluator::do_apply(const asset_fund_fee_pool_op static void validate_new_issuer( const database& d, const asset_object& a, account_id_type new_issuer ) { try { - FC_ASSERT(d.find_object(new_issuer)); + FC_ASSERT(d.find(new_issuer), "New issuer account does not exist"); if( a.is_market_issued() && new_issuer == GRAPHENE_COMMITTEE_ACCOUNT ) { const asset_object& backing = a.bitasset_data(d).options.short_backing_asset(d); @@ -587,10 +587,10 @@ void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o) FC_ASSERT( o.new_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities ); for( auto id : o.new_options.whitelist_authorities ) - d.get_object(id); + d.get(id); FC_ASSERT( o.new_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities ); for( auto id : o.new_options.blacklist_authorities ) - d.get_object(id); + d.get(id); return void_result(); } FC_CAPTURE_AND_RETHROW((o)) } @@ -1064,7 +1064,7 @@ void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_updat // Make sure all producers exist. Check these after asset because account lookup is more expensive for( auto id : o.new_feed_producers ) - d.get_object(id); + d.get(id); return void_result(); } FC_CAPTURE_AND_RETHROW( (o) ) } diff --git a/libraries/chain/db_balance.cpp b/libraries/chain/db_balance.cpp index bcd5d1004a..75040dd716 100644 --- a/libraries/chain/db_balance.cpp +++ b/libraries/chain/db_balance.cpp @@ -60,7 +60,7 @@ void database::adjust_balance(account_id_type account, asset delta ) auto abo = index.get_account_balance( account, delta.asset_id ); if( !abo ) { - FC_ASSERT( delta.amount > 0, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", + FC_ASSERT( delta.amount > 0, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", ("a",account(*this).name) ("b",to_pretty_string(asset(0,delta.asset_id))) ("r",to_pretty_string(-delta))); @@ -207,9 +207,14 @@ void database::deposit_cashback(const account_object& acct, share_type amount, b if( amount == 0 ) return; - if( acct.get_id() == GRAPHENE_COMMITTEE_ACCOUNT || acct.get_id() == GRAPHENE_WITNESS_ACCOUNT || - acct.get_id() == GRAPHENE_RELAXED_COMMITTEE_ACCOUNT || acct.get_id() == GRAPHENE_NULL_ACCOUNT || - acct.get_id() == GRAPHENE_TEMP_ACCOUNT ) + account_id_type acct_id = acct.get_id(); + + // Note: missing 'PROXY_TO_SELF' here + bool is_reserved_account = ( acct_id == GRAPHENE_COMMITTEE_ACCOUNT || acct_id == GRAPHENE_WITNESS_ACCOUNT || + acct_id == GRAPHENE_RELAXED_COMMITTEE_ACCOUNT ); + is_reserved_account = ( is_reserved_account || acct_id == GRAPHENE_NULL_ACCOUNT || + acct_id == GRAPHENE_TEMP_ACCOUNT ); + if( is_reserved_account ) { // The blockchain's accounts do not get cashback; it simply goes to the reserve pool. modify( get_core_dynamic_data(), [amount](asset_dynamic_data_object& d) { @@ -223,7 +228,7 @@ void database::deposit_cashback(const account_object& acct, share_type amount, b amount, get_global_properties().parameters.cashback_vesting_period_seconds, vesting_balance_type::cashback, - acct.id, + acct_id, require_vesting ); if( new_vbid.valid() ) diff --git a/libraries/chain/db_debug.cpp b/libraries/chain/db_debug.cpp index 4ac73bc613..6f4a6872d1 100644 --- a/libraries/chain/db_debug.cpp +++ b/libraries/chain/db_debug.cpp @@ -90,7 +90,7 @@ void database::debug_dump() } for( const asset_object& asset_obj : db.get_index_type().indices() ) { - total_balances[asset_obj.id] += asset_obj.dynamic_asset_data_id(db).accumulated_fees; + total_balances[asset_obj.get_id()] += asset_obj.dynamic_asset_data_id(db).accumulated_fees; total_balances[asset_id_type()] += asset_obj.dynamic_asset_data_id(db).fee_pool; // edump((total_balances[asset_obj.id])(asset_obj.dynamic_asset_data_id(db).current_supply ) ); } diff --git a/libraries/chain/db_genesis.cpp b/libraries/chain/db_genesis.cpp index 4624c16d81..95411a3654 100644 --- a/libraries/chain/db_genesis.cpp +++ b/libraries/chain/db_genesis.cpp @@ -345,7 +345,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) // Create initial assets for( const genesis_state_type::initial_asset_type& asst : genesis_state.initial_assets ) { - asset_id_type new_asset_id = get_index_type().get_next_id(); + asset_id_type new_asset_id { get_index_type().get_next_id() }; total_supplies[ new_asset_id ] = 0; asset_dynamic_data_id_type dynamic_data_id; @@ -362,7 +362,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) cop.registrar = GRAPHENE_TEMP_ACCOUNT; cop.owner = authority(1, collateral_rec.owner, 1); cop.active = cop.owner; - account_id_type owner_account_id = apply_operation(genesis_eval_state, cop).get(); + account_id_type owner_account_id { apply_operation(genesis_eval_state, cop).get() }; modify( owner_account_id(*this).statistics(*this), [&collateral_rec]( account_statistics_object& o ) { o.total_core_in_orders = collateral_rec.collateral; @@ -374,7 +374,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) c.collateral = collateral_rec.collateral; c.debt = collateral_rec.debt; c.call_price = price::call_price(chain::asset(c.debt, new_asset_id), - chain::asset(c.collateral, core_asset.id), + chain::asset(c.collateral, core_asset.get_id()), GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO); }); @@ -464,8 +464,8 @@ void database::init_genesis(const genesis_state_type& genesis_state) { if( it->bitasset_data_id.valid() ) { - auto supply_itr = total_supplies.find( it->id ); - auto debt_itr = total_debts.find( it->id ); + auto supply_itr = total_supplies.find( it->get_id() ); + auto debt_itr = total_debts.find( it->get_id() ); FC_ASSERT( supply_itr != total_supplies.end() ); FC_ASSERT( debt_itr != total_debts.end() ); if( supply_itr->second != debt_itr->second ) diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index 8bdcfd8b30..f159b58e8e 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -117,10 +117,10 @@ vector database::get_viable_custom_authorities( if (result.success) results.emplace_back(cust_auth.get().auth); else if (rejected_authorities != nullptr) - rejected_authorities->insert(std::make_pair(cust_auth.get().id, std::move(result))); + rejected_authorities->insert(std::make_pair(cust_auth.get().get_id(), std::move(result))); } catch (fc::exception& e) { if (rejected_authorities != nullptr) - rejected_authorities->insert(std::make_pair(cust_auth.get().id, std::move(e))); + rejected_authorities->insert(std::make_pair(cust_auth.get().get_id(), std::move(e))); } } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 5e2a459589..527902aa52 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -77,7 +77,8 @@ namespace graphene { namespace chain { void database::initialize_evaluators() { - _operation_evaluators.resize(255); + constexpr size_t max_num_of_evaluators = 255; + _operation_evaluators.resize(max_num_of_evaluators); register_evaluator(); register_evaluator(); register_evaluator(); diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index cd4c36b46d..0eb0c22183 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -301,7 +301,7 @@ void database::update_active_witnesses() std::transform(wits.begin(), wits.end(), std::inserter(gp.active_witnesses, gp.active_witnesses.end()), [](const witness_object& w) { - return w.id; + return w.get_id(); }); }); @@ -410,7 +410,7 @@ void database::update_active_committee_members() gp.active_committee_members.clear(); std::transform(committee_members.begin(), committee_members.end(), std::inserter(gp.active_committee_members, gp.active_committee_members.begin()), - [](const committee_member_object& d) { return d.id; }); + [](const committee_member_object& d) { return d.get_id(); }); }); } FC_CAPTURE_AND_RETHROW() } @@ -734,7 +734,7 @@ void create_buyback_orders( database& db ) continue; } - for( const auto& entry : bal_idx.get_account_balances( buyback_account.id ) ) + for( const auto& entry : bal_idx.get_account_balances( buyback_account.get_id() ) ) { const auto* it = entry.second; asset_id_type asset_to_sell = it->asset_type; @@ -759,11 +759,11 @@ void create_buyback_orders( database& db ) create_vop.fee = asset( 0, asset_id_type() ); create_vop.seller = buyback_account.id; create_vop.amount_to_sell = asset( amount_to_sell, asset_to_sell ); - create_vop.min_to_receive = asset( 1, asset_to_buy.id ); + create_vop.min_to_receive = asset( 1, asset_to_buy.get_id() ); create_vop.expiration = time_point_sec::maximum(); create_vop.fill_or_kill = false; - limit_order_id_type order_id = db.apply_operation( buyback_context, create_vop ).get< object_id_type >(); + limit_order_id_type order_id{ db.apply_operation( buyback_context, create_vop ).get< object_id_type >() }; if( db.find( order_id ) != nullptr ) { diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 09c9bbeca7..05c78c0b54 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -497,7 +497,7 @@ void database::cancel_settle_order( const force_settlement_object& order ) { adjust_balance(order.owner, order.balance); - push_applied_operation( asset_settle_cancel_operation( order.id, order.owner, order.balance ) ); + push_applied_operation( asset_settle_cancel_operation( order.get_id(), order.owner, order.balance ) ); remove(order); } diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index 47958336a7..1e43bcdc00 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -414,7 +414,7 @@ static void get_relevant_accounts( const object* obj, flat_set& case base_object_type: return; case account_object_type: - accounts.insert( obj->id ); + accounts.insert( account_id_type(obj->id) ); break; case asset_object_type:{ const auto* aobj = dynamic_cast(obj); diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index a6d27ee5c2..e13b51a9dc 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -588,7 +588,7 @@ void database::clear_expired_htlcs() const auto amount = asset(obj.transfer.amount, obj.transfer.asset_id); adjust_balance( obj.transfer.from, amount ); // notify related parties - htlc_refund_operation vop( obj.id, obj.transfer.from, obj.transfer.to, amount, + htlc_refund_operation vop( obj.get_id(), obj.transfer.from, obj.transfer.to, amount, obj.conditions.hash_lock.preimage_hash, obj.conditions.hash_lock.preimage_size ); push_applied_operation( vop ); remove( obj ); @@ -750,7 +750,7 @@ void database::update_credit_offers_and_deals() // Notify related parties push_applied_operation( credit_deal_expired_operation ( - deal.id, deal.offer_id, deal.offer_owner, deal.borrower, + deal.get_id(), deal.offer_id, deal.offer_owner, deal.borrower, asset( deal.debt_amount, deal.debt_asset ), asset( deal.collateral_amount, deal.collateral_asset ), deal.fee_rate ) ); diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index a793163fe5..42b7f82c1d 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -105,7 +105,7 @@ database& generic_evaluator::db()const { return trx_state->db(); } void generic_evaluator::pay_fba_fee( uint64_t fba_id ) { database& d = db(); - const fba_accumulator_object& fba = d.get< fba_accumulator_object >( fba_accumulator_id_type( fba_id ) ); + const fba_accumulator_object& fba = d.get( fba_accumulator_id_type( fba_id ) ); if( !fba.is_configured(d) ) { generic_evaluator::pay_fee(); diff --git a/libraries/chain/htlc_evaluator.cpp b/libraries/chain/htlc_evaluator.cpp index 339c2fc4bb..270b8d41ae 100644 --- a/libraries/chain/htlc_evaluator.cpp +++ b/libraries/chain/htlc_evaluator.cpp @@ -27,22 +27,22 @@ #include #include -namespace graphene { +namespace graphene { namespace chain { namespace detail { - void check_htlc_create_hf_bsip64(const fc::time_point_sec& block_time, + void check_htlc_create_hf_bsip64(const fc::time_point_sec& block_time, const htlc_create_operation& op, const asset_object& asset_to_transfer) { if (block_time < HARDFORK_CORE_BSIP64_TIME) { // memo field added at harfork BSIP64 // NOTE: both of these checks can be removed after hardfork time - FC_ASSERT( !op.extensions.value.memo.valid(), + FC_ASSERT( !op.extensions.value.memo.valid(), "Memo unavailable until after HARDFORK BSIP64"); // HASH160 added at hardfork BSIP64 FC_ASSERT( !op.preimage_hash.is_type(), - "HASH160 unavailable until after HARDFORK BSIP64" ); + "HASH160 unavailable until after HARDFORK BSIP64" ); } else { @@ -50,18 +50,18 @@ namespace graphene { // IF there were no restricted transfers before HF_BSIP64 FC_ASSERT( !asset_to_transfer.is_transfer_restricted() || op.from == asset_to_transfer.issuer || op.to == asset_to_transfer.issuer, - "Asset ${asset} cannot be transfered.", ("asset", asset_to_transfer.id) ); + "Asset ${asset} cannot be transfered.", ("asset", asset_to_transfer.id) ); } } - void check_htlc_redeem_hf_bsip64(const fc::time_point_sec& block_time, + void check_htlc_redeem_hf_bsip64(const fc::time_point_sec& block_time, const htlc_redeem_operation& op, const htlc_object* htlc_obj) { - // TODO: The hardfork portion of this check can be removed if no HTLC redemptions are + // TODO: The hardfork portion of this check can be removed if no HTLC redemptions are // attempted on an HTLC with a 0 preimage size before the hardfork date. - if ( htlc_obj->conditions.hash_lock.preimage_size > 0U || + if ( htlc_obj->conditions.hash_lock.preimage_size > 0U || block_time < HARDFORK_CORE_BSIP64_TIME ) - FC_ASSERT(op.preimage.size() == htlc_obj->conditions.hash_lock.preimage_size, + FC_ASSERT(op.preimage.size() == htlc_obj->conditions.hash_lock.preimage_size, "Preimage size mismatch."); } } // end of graphene::chain::details @@ -79,10 +79,10 @@ namespace graphene { FC_ASSERT(htlc_options, "HTLC Committee options are not set."); // make sure the expiration is reasonable - FC_ASSERT( o.claim_period_seconds <= htlc_options->max_timeout_secs, + FC_ASSERT( o.claim_period_seconds <= htlc_options->max_timeout_secs, "HTLC Timeout exceeds allowed length" ); // make sure the preimage length is reasonable - FC_ASSERT( o.preimage_size <= htlc_options->max_preimage_size, + FC_ASSERT( o.preimage_size <= htlc_options->max_preimage_size, "HTLC preimage length exceeds allowed length" ); // make sure the sender has the funds for the HTLC FC_ASSERT( d.get_balance( o.from, o.amount.asset_id) >= (o.amount), "Insufficient funds") ; @@ -90,11 +90,11 @@ namespace graphene { const auto& from_account = o.from( d ); const auto& to_account = o.to( d ); detail::check_htlc_create_hf_bsip64(d.head_block_time(), o, asset_to_transfer); - FC_ASSERT( is_authorized_asset( d, from_account, asset_to_transfer ), - "Asset ${asset} is not authorized for account ${acct}.", + FC_ASSERT( is_authorized_asset( d, from_account, asset_to_transfer ), + "Asset ${asset} is not authorized for account ${acct}.", ( "asset", asset_to_transfer.id )( "acct", from_account.id ) ); - FC_ASSERT( is_authorized_asset( d, to_account, asset_to_transfer ), - "Asset ${asset} is not authorized for account ${acct}.", + FC_ASSERT( is_authorized_asset( d, to_account, asset_to_transfer ), + "Asset ${asset} is not authorized for account ${acct}.", ( "asset", asset_to_transfer.id )( "acct", to_account.id ) ); return void_result(); } @@ -141,11 +141,11 @@ namespace graphene { void_result htlc_redeem_evaluator::do_evaluate(const htlc_redeem_operation& o) { auto& d = db(); - htlc_obj = &d.get(o.htlc_id); + htlc_obj = &d.get(o.htlc_id); detail::check_htlc_redeem_hf_bsip64(d.head_block_time(), o, htlc_obj); const htlc_redeem_visitor vtor( o.preimage ); - FC_ASSERT( htlc_obj->conditions.hash_lock.preimage_hash.visit( vtor ), + FC_ASSERT( htlc_obj->conditions.hash_lock.preimage_hash.visit( vtor ), "Provided preimage does not generate correct hash."); return void_result(); @@ -156,7 +156,8 @@ namespace graphene { const auto amount = asset(htlc_obj->transfer.amount, htlc_obj->transfer.asset_id); db().adjust_balance(htlc_obj->transfer.to, amount); // notify related parties - htlc_redeemed_operation virt_op( htlc_obj->id, htlc_obj->transfer.from, htlc_obj->transfer.to, o.redeemer, + htlc_redeemed_operation virt_op( htlc_obj->get_id(), htlc_obj->transfer.from, htlc_obj->transfer.to, + o.redeemer, amount, htlc_obj->conditions.hash_lock.preimage_hash, htlc_obj->conditions.hash_lock.preimage_size, o.preimage ); db().push_applied_operation( virt_op ); @@ -166,14 +167,14 @@ namespace graphene { void_result htlc_extend_evaluator::do_evaluate(const htlc_extend_operation& o) { - htlc_obj = &db().get(o.htlc_id); + htlc_obj = &db().get(o.htlc_id); FC_ASSERT(o.update_issuer == htlc_obj->transfer.from, "HTLC may only be extended by its creator."); optional htlc_options = get_committee_htlc_options(db()); - FC_ASSERT( htlc_obj->conditions.time_lock.expiration.sec_since_epoch() - + static_cast(o.seconds_to_add) < fc::time_point_sec::maximum().sec_since_epoch(), + FC_ASSERT( htlc_obj->conditions.time_lock.expiration.sec_since_epoch() + + static_cast(o.seconds_to_add) < fc::time_point_sec::maximum().sec_since_epoch(), "Extension would cause an invalid date"); FC_ASSERT( htlc_obj->conditions.time_lock.expiration + o.seconds_to_add - <= db().head_block_time() + htlc_options->max_timeout_secs, + <= db().head_block_time() + htlc_options->max_timeout_secs, "Extension pushes contract too far into the future" ); return void_result(); } diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 66aefa2dcd..b25d6f48d7 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -43,12 +43,10 @@ namespace graphene { namespace chain { * separating the account data that changes frequently from the account data that is mostly static, which will * minimize the amount of data that must be backed up as part of the undo history everytime a transfer is made. */ - class account_statistics_object : public graphene::db::abstract_object + class account_statistics_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_account_statistics_object_type; - account_id_type owner; string name; ///< redundantly store account name here for better maintenance performance @@ -155,12 +153,10 @@ namespace graphene { namespace chain { * This object is indexed on owner and asset_type so that black swan * events in asset_type can be processed quickly. */ - class account_balance_object : public abstract_object + class account_balance_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_account_balance_object_type; - account_id_type owner; asset_id_type asset_type; share_type balance; @@ -179,12 +175,9 @@ namespace graphene { namespace chain { * Accounts are the primary unit of authority on the graphene system. Users must have an account in order to use * assets, trade in the markets, vote for committee_members, etc. */ - class account_object : public graphene::db::abstract_object + class account_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = account_object_type; - /** * The time at which this account's membership expires. * If set to any time in the past, the account is a basic account. @@ -326,8 +319,6 @@ namespace graphene { namespace chain { { return !is_basic_account(now); } - - account_id_type get_id()const { return id; } }; /** diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 3dd11bb344..f93a3e4993 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -53,12 +53,10 @@ namespace graphene { namespace chain { * This object exists as an implementation detail and its ID should never be referenced by * a blockchain operation. */ - class asset_dynamic_data_object : public abstract_object + class asset_dynamic_data_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_asset_dynamic_data_object_type; - /// The number of shares currently in existence share_type current_supply; share_type confidential_supply; ///< total asset held in confidential balances @@ -74,12 +72,9 @@ namespace graphene { namespace chain { * All assets have a globally unique symbol name that controls how they are traded and an issuer who * has authority over the parameters of the asset. */ - class asset_object : public graphene::db::abstract_object + class asset_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = asset_object_type; - /// This function does not check if any registered asset has this symbol or not; it simply checks whether the /// symbol would be valid. /// @return true if symbol is a valid ticker symbol; false otherwise. @@ -116,7 +111,7 @@ namespace graphene { namespace chain { bool can_bid_collateral()const { return (0 == (options.flags & disable_collateral_bidding)); } /// Helper function to get an asset object with the given amount in this asset's type - asset amount(share_type a)const { return asset(a, id); } + asset amount(share_type a)const { return asset(a, asset_id_type(id)); } /// Convert a string amount (i.e. "123.45") to an asset object with this asset's type /// The string may have a decimal and/or a negative sign. asset amount_from_string(string amount_string)const; @@ -156,8 +151,6 @@ namespace graphene { namespace chain { /// The time when the asset object was created time_point_sec creation_time; - asset_id_type get_id()const { return id; } - void validate()const { // UIAs may not be prediction markets, have force settlement, or global settlements @@ -259,12 +252,10 @@ namespace graphene { namespace chain { * @ingroup object * @ingroup implementation */ - class asset_bitasset_data_object : public abstract_object + class asset_bitasset_data_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_asset_bitasset_data_object_type; - /// The asset this object belong to asset_id_type asset_id; diff --git a/libraries/chain/include/graphene/chain/balance_object.hpp b/libraries/chain/include/graphene/chain/balance_object.hpp index 478f78be39..0dafb72d9c 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -27,12 +27,9 @@ namespace graphene { namespace chain { - class balance_object : public abstract_object + class balance_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = balance_object_type; - bool is_vesting_balance()const { return vesting_policy.valid(); } asset available(fc::time_point_sec now)const diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 3486b993b4..fa13bf1369 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -37,12 +37,10 @@ namespace graphene { namespace chain { * so we can calculate whether the current transaction is valid and at * what time it should expire. */ - class block_summary_object : public abstract_object + class block_summary_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_block_summary_object_type; - block_id_type block_id; }; diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index 84ada7a816..192ed7e9af 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -63,12 +63,10 @@ struct budget_record share_type current_supply; }; -class budget_record_object : public graphene::db::abstract_object +class budget_record_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_budget_record_object_type; - fc::time_point_sec time; budget_record record; }; diff --git a/libraries/chain/include/graphene/chain/buyback_object.hpp b/libraries/chain/include/graphene/chain/buyback_object.hpp index 6724c9453e..5db9df8313 100644 --- a/libraries/chain/include/graphene/chain/buyback_object.hpp +++ b/libraries/chain/include/graphene/chain/buyback_object.hpp @@ -40,12 +40,10 @@ namespace graphene { namespace chain { * This class is an implementation detail. */ -class buyback_object : public graphene::db::abstract_object< buyback_object > +class buyback_object : public graphene::db::abstract_object< buyback_object, + implementation_ids, impl_buyback_object_type > { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_buyback_object_type; - asset_id_type asset_to_buy; }; diff --git a/libraries/chain/include/graphene/chain/chain_property_object.hpp b/libraries/chain/include/graphene/chain/chain_property_object.hpp index 28542c231e..b697ba6c9c 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -30,12 +30,10 @@ namespace graphene { namespace chain { /** * Contains invariants which are set at genesis and never changed. */ -class chain_property_object : public abstract_object +class chain_property_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_chain_property_object_type; - chain_id_type chain_id; immutable_chain_parameters immutable_parameters; }; diff --git a/libraries/chain/include/graphene/chain/committee_member_object.hpp b/libraries/chain/include/graphene/chain/committee_member_object.hpp index 9c0cef0816..f0a81a8a08 100644 --- a/libraries/chain/include/graphene/chain/committee_member_object.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_object.hpp @@ -40,12 +40,10 @@ namespace graphene { namespace chain { * committee_members were separated into a separate object to make iterating over * the set of committee_member easy. */ - class committee_member_object : public abstract_object + class committee_member_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = committee_member_object_type; - account_id_type committee_member_account; vote_id_type vote_id; uint64_t total_votes = 0; diff --git a/libraries/chain/include/graphene/chain/confidential_object.hpp b/libraries/chain/include/graphene/chain/confidential_object.hpp index 02057e46b5..bc9d849dfc 100644 --- a/libraries/chain/include/graphene/chain/confidential_object.hpp +++ b/libraries/chain/include/graphene/chain/confidential_object.hpp @@ -38,12 +38,10 @@ namespace graphene { namespace chain { * @ingroup object * @ingroup protocol */ -class blinded_balance_object : public graphene::db::abstract_object +class blinded_balance_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_blinded_balance_object_type; - fc::ecc::commitment_type commitment; asset_id_type asset_id; authority owner; diff --git a/libraries/chain/include/graphene/chain/credit_offer_object.hpp b/libraries/chain/include/graphene/chain/credit_offer_object.hpp index 24b26479f0..a8d427e7ce 100644 --- a/libraries/chain/include/graphene/chain/credit_offer_object.hpp +++ b/libraries/chain/include/graphene/chain/credit_offer_object.hpp @@ -36,12 +36,9 @@ namespace graphene { namespace chain { * @ingroup protocol * */ -class credit_offer_object : public abstract_object +class credit_offer_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = credit_offer_object_type; - account_id_type owner_account; ///< Owner of the fund asset_id_type asset_type; ///< Asset type in the fund share_type total_balance; ///< Total size of the fund @@ -104,12 +101,9 @@ using credit_offer_index = generic_index +class credit_deal_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = credit_deal_object_type; - account_id_type borrower; ///< Borrower credit_offer_id_type offer_id; ///< ID of the credit offer account_id_type offer_owner; ///< Owner of the credit offer, redundant info for ease of querying @@ -186,12 +180,10 @@ using credit_deal_index = generic_index +class credit_deal_summary_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_credit_deal_summary_object_type; - account_id_type borrower; ///< Borrower credit_offer_id_type offer_id; ///< ID of the credit offer account_id_type offer_owner; ///< Owner of the credit offer, redundant info for ease of querying diff --git a/libraries/chain/include/graphene/chain/custom_authority_object.hpp b/libraries/chain/include/graphene/chain/custom_authority_object.hpp index d73194a11a..e38404f0ed 100644 --- a/libraries/chain/include/graphene/chain/custom_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/custom_authority_object.hpp @@ -36,15 +36,14 @@ namespace graphene { namespace chain { * @ingroup object * */ - class custom_authority_object : public abstract_object { + class custom_authority_object : public abstract_object + { /// Unreflected field to store a cache of the predicate function /// Note that this cache can be modified when the object is const! mutable optional predicate_cache; public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = custom_authority_object_type; - account_id_type account; bool enabled; time_point_sec valid_from; diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index b953f4fdba..2535feb247 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -72,7 +72,7 @@ namespace graphene { namespace chain { //////////////////// db_management.cpp //////////////////// public: database(); - virtual ~database(); + ~database() override; enum validation_steps { @@ -234,8 +234,12 @@ namespace graphene { namespace chain { template void register_evaluator() { - _operation_evaluators[operation::tag::value] - = std::make_unique>(); + const auto op_type = operation::tag::value; + FC_ASSERT( op_type >= 0, "Negative operation type" ); + FC_ASSERT( op_type < _operation_evaluators.size(), + "The operation type (${a}) must be smaller than the size of _operation_evaluators (${b})", + ("a", op_type)("b", _operation_evaluators.size()) ); + _operation_evaluators[op_type] = std::make_unique>(); } ///@} diff --git a/libraries/chain/include/graphene/chain/fba_object.hpp b/libraries/chain/include/graphene/chain/fba_object.hpp index 3b5b2f7eb1..8397ad235a 100644 --- a/libraries/chain/include/graphene/chain/fba_object.hpp +++ b/libraries/chain/include/graphene/chain/fba_object.hpp @@ -34,12 +34,10 @@ class database; * fba_accumulator_object accumulates fees to be paid out via buyback or other FBA mechanism. */ -class fba_accumulator_object : public graphene::db::abstract_object< fba_accumulator_object > +class fba_accumulator_object : public graphene::db::abstract_object< fba_accumulator_object, + implementation_ids, impl_fba_accumulator_object_type > { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_fba_accumulator_object_type; - share_type accumulated_fba_fees; optional< asset_id_type > designated_asset; diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index a7fe629872..9d7079e624 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -37,12 +37,10 @@ namespace graphene { namespace chain { * * This is an implementation detail. The values here are set by committee_members to tune the blockchain parameters. */ - class global_property_object : public graphene::db::abstract_object + class global_property_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_global_property_object_type; - chain_parameters parameters; optional pending_parameters; @@ -61,12 +59,10 @@ namespace graphene { namespace chain { * This is an implementation detail. The values here are calculated during normal chain operations and reflect the * current values of global blockchain properties. */ - class dynamic_global_property_object : public abstract_object + class dynamic_global_property_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_dynamic_global_property_object_type; - uint32_t head_block_number = 0; block_id_type head_block_id; time_point_sec time; diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index ab84d58565..47934f6418 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -37,12 +37,9 @@ namespace graphene { namespace chain { * This object is stored in the database while an HTLC is active. The HTLC will * become inactive at expiration or when unlocked via the preimage. */ - class htlc_object : public graphene::db::abstract_object { + class htlc_object : public graphene::db::abstract_object + { public: - // uniquely identify this object in the database - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = htlc_object_type; - struct transfer_info { account_id_type from; account_id_type to; diff --git a/libraries/chain/include/graphene/chain/liquidity_pool_object.hpp b/libraries/chain/include/graphene/chain/liquidity_pool_object.hpp index 2853e6c087..7769a33fca 100644 --- a/libraries/chain/include/graphene/chain/liquidity_pool_object.hpp +++ b/libraries/chain/include/graphene/chain/liquidity_pool_object.hpp @@ -41,12 +41,9 @@ using namespace graphene::db; * @ingroup protocol * */ -class liquidity_pool_object : public abstract_object +class liquidity_pool_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = liquidity_pool_object_type; - asset_id_type asset_a; ///< Type of the first asset in the pool asset_id_type asset_b; ///< Type of the second asset in the pool share_type balance_a; ///< The balance of the first asset in the pool diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 3f62130a50..724be9c25b 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -41,12 +41,9 @@ using namespace graphene::db; * * The objects are indexed by @ref expiration and are automatically deleted on the first block after expiration. */ -class limit_order_object : public abstract_object +class limit_order_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = limit_order_object_type; - time_point_sec expiration; account_id_type seller; share_type for_sale; ///< asset id is sell_price.base.asset_id @@ -125,12 +122,9 @@ typedef generic_index limit_or * There should only be one call_order_object per asset pair per account and * they will all have the same call price. */ -class call_order_object : public abstract_object +class call_order_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = call_order_object_type; - asset get_collateral()const { return asset( collateral, call_price.base.asset_id ); } asset get_debt()const { return asset( debt, debt_type() ); } asset amount_to_receive()const { return get_debt(); } @@ -175,12 +169,10 @@ class call_order_object : public abstract_object * On the @ref settlement_date the @ref balance will be converted to the collateral asset * and paid to @ref owner and then this object will be deleted. */ -class force_settlement_object : public abstract_object +class force_settlement_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = force_settlement_object_type; - account_id_type owner; asset balance; time_point_sec settlement_date; @@ -196,12 +188,10 @@ class force_settlement_object : public abstract_object * There should only be one collateral_bid_object per asset per account, and * only for smartcoin assets that have a global settlement_price. */ -class collateral_bid_object : public abstract_object +class collateral_bid_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_collateral_bid_object_type; - asset get_additional_collateral()const { return inv_swan_price.base; } asset get_debt_covered()const { return inv_swan_price.quote; } asset_id_type debt_type()const { return inv_swan_price.quote.asset_id; } diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index df959152dc..3cf82787d0 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -45,14 +45,12 @@ namespace graphene { namespace chain { * * @note this object is READ ONLY it can never be modified */ - class operation_history_object : public abstract_object + class operation_history_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = operation_history_object_type; - explicit operation_history_object( const operation& o ):op(o){} - operation_history_object(){} + operation_history_object() = default; operation_history_object( const operation& o, uint32_t bn, uint16_t tib, uint16_t oit, uint32_t vo, bool iv, const time_point_sec& bt ) : op(o), block_num(bn), trx_in_block(tib), op_in_trx(oit), virtual_op(vo), is_virtual(iv), block_time(bt) {} @@ -94,11 +92,10 @@ namespace graphene { namespace chain { * linked list can be traversed with relatively effecient disk access because * of the use of a memory mapped stack. */ - class account_history_object : public abstract_object + class account_history_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_account_history_object_type; account_id_type account; /// the account this operation applies to operation_history_id_type operation_id; uint64_t sequence = 0; /// the operation position within the given account diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index 0a49bc05da..dde9cedf74 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -37,12 +37,9 @@ namespace graphene { namespace chain { * @ingroup object * @ingroup protocol */ -class proposal_object : public abstract_object +class proposal_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = proposal_object_type; - time_point_sec expiration_time; optional review_period_time; transaction proposed_transaction; diff --git a/libraries/chain/include/graphene/chain/samet_fund_object.hpp b/libraries/chain/include/graphene/chain/samet_fund_object.hpp index f1301d0822..2c6e2dbaf9 100644 --- a/libraries/chain/include/graphene/chain/samet_fund_object.hpp +++ b/libraries/chain/include/graphene/chain/samet_fund_object.hpp @@ -36,12 +36,9 @@ namespace graphene { namespace chain { * @ingroup protocol * */ -class samet_fund_object : public abstract_object +class samet_fund_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = samet_fund_object_type; - account_id_type owner_account; ///< Owner of the fund asset_id_type asset_type; ///< Asset type in the fund share_type balance; ///< Usable amount in the fund diff --git a/libraries/chain/include/graphene/chain/special_authority_object.hpp b/libraries/chain/include/graphene/chain/special_authority_object.hpp index cbd8103eb4..2b58f42528 100644 --- a/libraries/chain/include/graphene/chain/special_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/special_authority_object.hpp @@ -39,12 +39,10 @@ namespace graphene { namespace chain { * This class is an implementation detail. */ -class special_authority_object : public graphene::db::abstract_object +class special_authority_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_special_authority_object_type; - account_id_type account; }; diff --git a/libraries/chain/include/graphene/chain/ticket_object.hpp b/libraries/chain/include/graphene/chain/ticket_object.hpp index 16610dccf7..d42858c417 100644 --- a/libraries/chain/include/graphene/chain/ticket_object.hpp +++ b/libraries/chain/include/graphene/chain/ticket_object.hpp @@ -59,12 +59,9 @@ enum ticket_version * @ingroup protocol * */ -class ticket_object : public abstract_object +class ticket_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = ticket_object_type; - account_id_type account; ///< The account who owns the ticket ticket_type target_type; ///< The target type of the ticket asset amount; ///< The token type and amount in the ticket diff --git a/libraries/chain/include/graphene/chain/transaction_history_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp index b5844c2f82..237988bbde 100644 --- a/libraries/chain/include/graphene/chain/transaction_history_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -41,12 +41,10 @@ namespace graphene { namespace chain { * in a block a transaction_history_object is added. At the end of block processing all transaction_history_objects that * have expired can be removed from the index. */ - class transaction_history_object : public abstract_object + class transaction_history_object : public abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_transaction_history_object_type; - signed_transaction trx; transaction_id_type trx_id; diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 3e91d9cf9c..1ec58bfb50 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -148,12 +148,10 @@ namespace graphene { namespace chain { /** * Vesting balance object is a balance that is locked by the blockchain for a period of time. */ - class vesting_balance_object : public abstract_object + class vesting_balance_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = vesting_balance_object_type; - /// Account which owns and may withdraw from this vesting balance account_id_type owner; /// Total amount remaining in this vesting balance diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_evaluator.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_evaluator.hpp index 25bc4b1bc7..920e8468a1 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_evaluator.hpp @@ -30,37 +30,37 @@ namespace graphene { namespace chain { class withdraw_permission_create_evaluator : public evaluator { public: - typedef withdraw_permission_create_operation operation_type; + using operation_type = withdraw_permission_create_operation; - void_result do_evaluate( const operation_type& op ); - object_id_type do_apply( const operation_type& op ); + void_result do_evaluate( const operation_type& op ) const; + object_id_type do_apply( const operation_type& op ) const; }; class withdraw_permission_claim_evaluator : public evaluator { public: - typedef withdraw_permission_claim_operation operation_type; + using operation_type = withdraw_permission_claim_operation; - void_result do_evaluate( const operation_type& op ); - void_result do_apply( const operation_type& op ); + void_result do_evaluate( const operation_type& op ) const; + void_result do_apply( const operation_type& op ) const; }; class withdraw_permission_update_evaluator : public evaluator { public: - typedef withdraw_permission_update_operation operation_type; + using operation_type = withdraw_permission_update_operation; - void_result do_evaluate( const operation_type& op ); - void_result do_apply( const operation_type& op ); + void_result do_evaluate( const operation_type& op ) const; + void_result do_apply( const operation_type& op ) const; }; class withdraw_permission_delete_evaluator : public evaluator { public: - typedef withdraw_permission_delete_operation operation_type; + using operation_type = withdraw_permission_delete_operation; - void_result do_evaluate( const operation_type& op ); - void_result do_apply( const operation_type& op ); + void_result do_evaluate( const operation_type& op ) const; + void_result do_apply( const operation_type& op ) const; }; } } // graphene::chain diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index a16bcd1156..3ba50a2932 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -42,12 +42,10 @@ namespace graphene { namespace chain { * this. Any number of withdrawals may be made so long as the total amount withdrawn per period does not exceed the * limit for any given period. */ - class withdraw_permission_object : public graphene::db::abstract_object + class withdraw_permission_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = withdraw_permission_object_type; - /// The account authorizing @ref authorized_account to withdraw from it account_id_type withdraw_from_account; /// The account authorized to make withdrawals from @ref withdraw_from_account diff --git a/libraries/chain/include/graphene/chain/witness_object.hpp b/libraries/chain/include/graphene/chain/witness_object.hpp index 29810eed2d..fbc3c483be 100644 --- a/libraries/chain/include/graphene/chain/witness_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_object.hpp @@ -29,23 +29,18 @@ namespace graphene { namespace chain { using namespace graphene::db; - class witness_object : public abstract_object + class witness_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = witness_object_type; - account_id_type witness_account; uint64_t last_aslot = 0; public_key_type signing_key; optional< vesting_balance_id_type > pay_vb; - vote_id_type vote_id; + vote_id_type vote_id { vote_id_type::witness }; uint64_t total_votes = 0; string url; int64_t total_missed = 0; uint32_t last_confirmed_block_num = 0; - - witness_object() : vote_id(vote_id_type::witness) {} }; struct by_account; diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 080e76551d..8509c68d5a 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -27,12 +27,10 @@ namespace graphene { namespace chain { -class witness_schedule_object : public graphene::db::abstract_object +class witness_schedule_object : public graphene::db::abstract_object { public: - static constexpr uint8_t space_id = implementation_ids; - static constexpr uint8_t type_id = impl_witness_schedule_object_type; - vector< witness_id_type > current_shuffled_witnesses; }; diff --git a/libraries/chain/include/graphene/chain/worker_object.hpp b/libraries/chain/include/graphene/chain/worker_object.hpp index 2836b0a382..2acccb4b2e 100644 --- a/libraries/chain/include/graphene/chain/worker_object.hpp +++ b/libraries/chain/include/graphene/chain/worker_object.hpp @@ -104,12 +104,9 @@ typedef static_variant< /** * @brief Worker object contains the details of a blockchain worker. See @ref workers for details. */ -class worker_object : public abstract_object +class worker_object : public abstract_object { public: - static constexpr uint8_t space_id = protocol_ids; - static constexpr uint8_t type_id = worker_object_type; - /// ID of the account which owns this worker account_id_type worker_account; /// Time at which this worker begins receiving pay, if elected diff --git a/libraries/chain/is_authorized_asset.cpp b/libraries/chain/is_authorized_asset.cpp index 8eeff66a1c..e35eb29318 100644 --- a/libraries/chain/is_authorized_asset.cpp +++ b/libraries/chain/is_authorized_asset.cpp @@ -47,7 +47,7 @@ bool _is_authorized_asset( if( acct.allowed_assets.valid() ) { - if( acct.allowed_assets->find( asset_obj.id ) == acct.allowed_assets->end() ) + if( acct.allowed_assets->find( asset_obj.get_id() ) == acct.allowed_assets->end() ) return false; // must still pass other checks even if it is in allowed_assets } diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 28fe567ec4..11aee840a5 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -47,14 +47,14 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o if( _sell_asset->options.whitelist_markets.size() ) { - GRAPHENE_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) + GRAPHENE_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->get_id()) != _sell_asset->options.whitelist_markets.end(), limit_order_create_market_not_whitelisted, "This market has not been whitelisted by the selling asset", ); } if( _sell_asset->options.blacklist_markets.size() ) { - GRAPHENE_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) + GRAPHENE_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->get_id()) == _sell_asset->options.blacklist_markets.end(), limit_order_create_market_blacklisted, "This market has been blacklisted by the selling asset", ); @@ -119,7 +119,7 @@ object_id_type limit_order_create_evaluator::do_apply(const limit_order_create_o obj.deferred_fee = _deferred_fee; obj.deferred_paid_fee = _deferred_paid_fee; }); - limit_order_id_type order_id = new_order_object.id; // save this because we may remove the object by filling it + object_id_type order_id = new_order_object.id; // save this because we may remove the object by filling it bool filled; if( db().get_dynamic_global_properties().next_maintenance_time <= HARDFORK_CORE_625_TIME ) filled = db().apply_order_before_hardfork_625( new_order_object ); @@ -346,7 +346,7 @@ object_id_type call_order_update_evaluator::do_apply(const call_order_update_ope }); } - call_order_id_type call_order_id = call_ptr->id; + object_id_type call_order_id = call_ptr->id; if( _bitasset_data->is_prediction_market ) return call_order_id; @@ -381,7 +381,7 @@ object_id_type call_order_update_evaluator::do_apply(const call_order_update_ope // the first call order may be unable to be updated if the second one is undercollateralized. // Note: check call orders, don't allow black swan, not for new limit order bool called_some = d.check_call_orders( *_debt_asset, false, false, _bitasset_data ); - call_ptr = d.find(call_order_id); + call_ptr = d.find(call_order_id); if( called_some ) { // before hard fork core-583: if we filled at least one call order, we are OK if we totally filled. diff --git a/libraries/chain/proposal_object.cpp b/libraries/chain/proposal_object.cpp index 3c5244d62c..9659d32b65 100644 --- a/libraries/chain/proposal_object.cpp +++ b/libraries/chain/proposal_object.cpp @@ -61,15 +61,16 @@ void required_approval_index::object_inserted( const object& obj ) { assert( dynamic_cast(&obj) ); const proposal_object& p = static_cast(obj); + const proposal_id_type proposal_id = p.get_id(); for( const auto& a : p.required_active_approvals ) - _account_to_proposals[a].insert( p.id ); + _account_to_proposals[a].insert( proposal_id ); for( const auto& a : p.required_owner_approvals ) - _account_to_proposals[a].insert( p.id ); + _account_to_proposals[a].insert( proposal_id ); for( const auto& a : p.available_active_approvals ) - _account_to_proposals[a].insert( p.id ); + _account_to_proposals[a].insert( proposal_id ); for( const auto& a : p.available_owner_approvals ) - _account_to_proposals[a].insert( p.id ); + _account_to_proposals[a].insert( proposal_id ); } void required_approval_index::remove( account_id_type a, proposal_id_type p ) @@ -87,15 +88,16 @@ void required_approval_index::object_removed( const object& obj ) { assert( dynamic_cast(&obj) ); const proposal_object& p = static_cast(obj); + const proposal_id_type proposal_id = p.get_id(); for( const auto& a : p.required_active_approvals ) - remove( a, p.id ); + remove( a, proposal_id ); for( const auto& a : p.required_owner_approvals ) - remove( a, p.id ); + remove( a, proposal_id ); for( const auto& a : p.available_active_approvals ) - remove( a, p.id ); + remove( a, proposal_id ); for( const auto& a : p.available_owner_approvals ) - remove( a, p.id ); + remove( a, proposal_id ); } void required_approval_index::insert_or_remove_delta( proposal_id_type p, @@ -134,8 +136,9 @@ void required_approval_index::about_to_modify( const object& before ) void required_approval_index::object_modified( const object& after ) { const proposal_object& p = static_cast(after); - insert_or_remove_delta( p.id, available_active_before_modify, p.available_active_approvals ); - insert_or_remove_delta( p.id, available_owner_before_modify, p.available_owner_approvals ); + const proposal_id_type proposal_id = p.get_id(); + insert_or_remove_delta( proposal_id, available_active_before_modify, p.available_active_approvals ); + insert_or_remove_delta( proposal_id, available_owner_before_modify, p.available_owner_approvals ); } } } // graphene::chain diff --git a/libraries/chain/withdraw_permission_evaluator.cpp b/libraries/chain/withdraw_permission_evaluator.cpp index ce3981348e..3daf6dc599 100644 --- a/libraries/chain/withdraw_permission_evaluator.cpp +++ b/libraries/chain/withdraw_permission_evaluator.cpp @@ -31,12 +31,12 @@ namespace graphene { namespace chain { -void_result withdraw_permission_create_evaluator::do_evaluate(const operation_type& op) +void_result withdraw_permission_create_evaluator::do_evaluate(const operation_type& op)const { try { database& d = db(); - FC_ASSERT(d.find_object(op.withdraw_from_account)); - FC_ASSERT(d.find_object(op.authorized_account)); - FC_ASSERT(d.find_object(op.withdrawal_limit.asset_id)); + FC_ASSERT(d.find(op.withdraw_from_account)); + FC_ASSERT(d.find(op.authorized_account)); + FC_ASSERT(d.find(op.withdrawal_limit.asset_id)); FC_ASSERT(op.period_start_time > d.head_block_time()); FC_ASSERT(op.period_start_time + op.periods_until_expiration * op.withdrawal_period_sec > d.head_block_time()); FC_ASSERT(op.withdrawal_period_sec >= d.get_global_properties().parameters.block_interval); @@ -44,7 +44,7 @@ void_result withdraw_permission_create_evaluator::do_evaluate(const operation_ty return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -object_id_type withdraw_permission_create_evaluator::do_apply(const operation_type& op) +object_id_type withdraw_permission_create_evaluator::do_apply(const operation_type& op)const { try { return db().create([&op](withdraw_permission_object& p) { p.withdraw_from_account = op.withdraw_from_account; @@ -56,7 +56,8 @@ object_id_type withdraw_permission_create_evaluator::do_apply(const operation_ty }).id; } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_permission_claim_evaluator::operation_type& op) +void_result withdraw_permission_claim_evaluator::do_evaluate( + const withdraw_permission_claim_evaluator::operation_type& op)const { try { const database& d = db(); time_point_sec head_block_time = d.head_block_time(); @@ -79,8 +80,8 @@ void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_perm const account_object& to = permit.authorized_account(d); FC_ASSERT( is_authorized_asset( d, to, _asset ), - "Account ${acct} '${name}' is unauthorized to transact asset ${a} '${sym}' due to whitelist / blacklist", - ("acct", to.id)("name", to.name)("a", _asset.id)("sym", _asset.symbol) ); + "Account ${acct} '${name}' is unauthorized to transact asset ${a} '${sym}' due to whitelist / blacklist", + ("acct", to.id)("name", to.name)("a", _asset.id)("sym", _asset.symbol) ); const account_object& from = op.withdraw_from_account(d); bool from_is_authorized = ( is_authorized_asset( d, from, _asset ) ); @@ -91,7 +92,8 @@ void_result withdraw_permission_claim_evaluator::do_evaluate(const withdraw_perm return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result withdraw_permission_claim_evaluator::do_apply(const withdraw_permission_claim_evaluator::operation_type& op) +void_result withdraw_permission_claim_evaluator::do_apply( + const withdraw_permission_claim_evaluator::operation_type& op)const { try { database& d = db(); @@ -111,14 +113,15 @@ void_result withdraw_permission_claim_evaluator::do_apply(const withdraw_permiss return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result withdraw_permission_update_evaluator::do_evaluate(const withdraw_permission_update_evaluator::operation_type& op) +void_result withdraw_permission_update_evaluator::do_evaluate( + const withdraw_permission_update_evaluator::operation_type& op)const { try { database& d = db(); const withdraw_permission_object& permit = op.permission_to_update(d); FC_ASSERT(permit.authorized_account == op.authorized_account); FC_ASSERT(permit.withdraw_from_account == op.withdraw_from_account); - FC_ASSERT(d.find_object(op.withdrawal_limit.asset_id)); + FC_ASSERT(d.find(op.withdrawal_limit.asset_id)); FC_ASSERT(op.period_start_time >= d.head_block_time()); FC_ASSERT(op.period_start_time + op.periods_until_expiration * op.withdrawal_period_sec > d.head_block_time()); FC_ASSERT(op.withdrawal_period_sec >= d.get_global_properties().parameters.block_interval); @@ -126,7 +129,8 @@ void_result withdraw_permission_update_evaluator::do_evaluate(const withdraw_per return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result withdraw_permission_update_evaluator::do_apply(const withdraw_permission_update_evaluator::operation_type& op) +void_result withdraw_permission_update_evaluator::do_apply( + const withdraw_permission_update_evaluator::operation_type& op)const { try { database& d = db(); @@ -140,7 +144,8 @@ void_result withdraw_permission_update_evaluator::do_apply(const withdraw_permis return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result withdraw_permission_delete_evaluator::do_evaluate(const withdraw_permission_delete_evaluator::operation_type& op) +void_result withdraw_permission_delete_evaluator::do_evaluate( + const withdraw_permission_delete_evaluator::operation_type& op)const { try { database& d = db(); @@ -151,7 +156,8 @@ void_result withdraw_permission_delete_evaluator::do_evaluate(const withdraw_per return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result withdraw_permission_delete_evaluator::do_apply(const withdraw_permission_delete_evaluator::operation_type& op) +void_result withdraw_permission_delete_evaluator::do_apply( + const withdraw_permission_delete_evaluator::operation_type& op)const { try { db().remove(db().get(op.withdrawal_permission)); return void_result(); diff --git a/libraries/db/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index 812a6587d1..556e2c0834 100644 --- a/libraries/db/include/graphene/db/generic_index.hpp +++ b/libraries/db/include/graphene/db/generic_index.hpp @@ -43,29 +43,31 @@ namespace graphene { namespace db { class generic_index : public index { public: - typedef MultiIndexType index_type; - typedef ObjectType object_type; + using index_type = MultiIndexType; + using object_type = ObjectType; - virtual const object& insert( object&& obj )override + const object& insert( object&& obj )override { assert( nullptr != dynamic_cast(&obj) ); auto insert_result = _indices.insert( std::move( static_cast(obj) ) ); - FC_ASSERT( insert_result.second, "Could not insert object, most likely a uniqueness constraint was violated" ); + FC_ASSERT( insert_result.second, + "Could not insert object, most likely a uniqueness constraint was violated" ); return *insert_result.first; } - virtual const object& create(const std::function& constructor )override + const object& create(const std::function& constructor )override { ObjectType item; item.id = get_next_id(); constructor( item ); auto insert_result = _indices.insert( std::move(item) ); - FC_ASSERT(insert_result.second, "Could not create object! Most likely a uniqueness constraint is violated."); + FC_ASSERT( insert_result.second, + "Could not create object! Most likely a uniqueness constraint is violated."); use_next_id(); return *insert_result.first; } - virtual void modify( const object& obj, const std::function& m )override + void modify( const object& obj, const std::function& m )override { assert(nullptr != dynamic_cast(&obj)); std::exception_ptr exc; @@ -88,12 +90,12 @@ namespace graphene { namespace db { FC_ASSERT(ok, "Could not modify object, most likely an index constraint was violated"); } - virtual void remove( const object& obj )override + void remove( const object& obj )override { _indices.erase( _indices.iterator_to( static_cast(obj) ) ); } - virtual const object* find( object_id_type id )const override + const object* find( object_id_type id )const override { static_assert(std::is_same::value, "First index of MultiIndexType MUST be object_id_type!"); @@ -102,7 +104,7 @@ namespace graphene { namespace db { return &*itr; } - virtual void inspect_all_objects(std::function inspector)const override + void inspect_all_objects(std::function inspector)const override { try { for( const auto& ptr : _indices ) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index e6cf0d8cbf..95437c6a55 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -34,7 +34,6 @@ namespace graphene { namespace db { class object_database; - using fc::path; /** * @class index_observer @@ -43,7 +42,7 @@ namespace graphene { namespace db { class index_observer { public: - virtual ~index_observer(){} + virtual ~index_observer() = default; /** called just after the object is added */ virtual void on_add( const object& obj ){} /** called just before obj is removed */ @@ -71,7 +70,7 @@ namespace graphene { namespace db { class index { public: - virtual ~index(){} + virtual ~index() = default; virtual uint8_t object_space_id()const = 0; virtual uint8_t object_type_id()const = 0; @@ -126,20 +125,21 @@ namespace graphene { namespace db { */ template void modify( const Object& obj, const Lambda& l ) { - modify( static_cast(obj), std::function( [&]( object& o ){ l( static_cast(o) ); } ) ); + modify( static_cast(obj), + std::function( [&l]( object& o ){ l( static_cast(o) ); } ) ); } - virtual void inspect_all_objects(std::function inspector)const = 0; - virtual void add_observer( const shared_ptr& ) = 0; + virtual void inspect_all_objects(std::function inspector)const = 0; + virtual void add_observer( const std::shared_ptr& ) = 0; - virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0; - virtual void object_default( object& obj )const = 0; + virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0; + virtual void object_default( object& obj )const = 0; }; class secondary_index { public: - virtual ~secondary_index(){}; + virtual ~secondary_index() = default; virtual void object_inserted( const object& obj ){}; virtual void object_removed( const object& obj ){}; virtual void about_to_modify( const object& before ){}; @@ -152,7 +152,9 @@ namespace graphene { namespace db { class base_primary_index { public: - base_primary_index( object_database& db ):_db(db){} + explicit base_primary_index( object_database& db ):_db(db){} + + virtual ~base_primary_index() = default; /** called just before obj is modified */ void save_undo( const object& obj ); @@ -185,8 +187,8 @@ namespace graphene { namespace db { } protected: - vector< shared_ptr > _observers; - vector< unique_ptr > _sindex; + std::vector< std::shared_ptr > _observers; + std::vector< std::unique_ptr > _sindex; private: object_database& _db; @@ -210,7 +212,7 @@ namespace graphene { namespace db { static const size_t MAX_HOLE = 100; static const size_t _mask = ((1ULL << chunkbits) - 1); uint64_t next = 0; - vector< vector< const Object* > > content; + std::vector< std::vector< const Object* > > content; std::stack< object_id_type > ids_being_modified; public: @@ -218,9 +220,7 @@ namespace graphene { namespace db { FC_ASSERT( (1ULL << chunkbits) > MAX_HOLE, "Small chunkbits is inefficient." ); } - virtual ~direct_index(){} - - virtual void object_inserted( const object& obj ) + void object_inserted( const object& obj ) override { uint64_t instance = obj.id.instance(); if( instance == next ) @@ -233,10 +233,12 @@ namespace graphene { namespace db { next++; } else if( instance < next ) - FC_ASSERT( !content[instance >> chunkbits][instance & _mask], "Overwriting insert at {id}!", ("id",obj.id) ); + FC_ASSERT( !content[instance >> chunkbits][instance & _mask], + "Overwriting insert at {id}!", ("id",obj.id) ); else // instance > next, allow small "holes" { - FC_ASSERT( instance <= next + MAX_HOLE, "Out-of-order insert: {id} > {next}!", ("id",obj.id)("next",next) ); + FC_ASSERT( instance <= next + MAX_HOLE, + "Out-of-order insert: {id} > {next}!", ("id",obj.id)("next",next) ); if( 0 == (next & _mask) || (next & (~_mask)) != (instance & (~_mask)) ) { content.resize((instance >> chunkbits) + 1); @@ -252,21 +254,22 @@ namespace graphene { namespace db { content[instance >> chunkbits][instance & _mask] = static_cast( &obj ); } - virtual void object_removed( const object& obj ) + void object_removed( const object& obj ) override { FC_ASSERT( nullptr != dynamic_cast(&obj), "Wrong object type!" ); uint64_t instance = obj.id.instance(); FC_ASSERT( instance < next, "Removing out-of-range object: {id} > {next}!", ("id",obj.id)("next",next) ); - FC_ASSERT( content[instance >> chunkbits][instance & _mask], "Removing non-existent object {id}!", ("id",obj.id) ); + FC_ASSERT( content[instance >> chunkbits][instance & _mask], + "Removing non-existent object {id}!", ("id",obj.id) ); content[instance >> chunkbits][instance & _mask] = nullptr; } - virtual void about_to_modify( const object& before ) + void about_to_modify( const object& before ) override { ids_being_modified.emplace( before.id ); } - virtual void object_modified( const object& after ) + void object_modified( const object& after ) override { FC_ASSERT( ids_being_modified.top() == after.id, "Modification of ID is not supported!"); ids_being_modified.pop(); @@ -309,27 +312,27 @@ namespace graphene { namespace db { class primary_index : public DerivedIndex, public base_primary_index { public: - typedef typename DerivedIndex::object_type object_type; + using object_type = typename DerivedIndex::object_type; - primary_index( object_database& db ) + explicit primary_index( object_database& db ) :base_primary_index(db),_next_id(object_type::space_id,object_type::type_id,0) { if( DirectBits > 0 ) _direct_by_id = add_secondary_index< direct_index< object_type, DirectBits > >(); } - virtual uint8_t object_space_id()const override + uint8_t object_space_id()const override { return object_type::space_id; } - virtual uint8_t object_type_id()const override + uint8_t object_type_id()const override { return object_type::type_id; } - virtual object_id_type get_next_id()const override { return _next_id; } - virtual void use_next_id()override { ++_next_id.number; } - virtual void set_next_id( object_id_type id )override { _next_id = id; } + object_id_type get_next_id()const override { return _next_id; } + void use_next_id()override { ++_next_id.number; } + void set_next_id( object_id_type id )override { _next_id = id; } /** @return the object with id or nullptr if not found */ - virtual const object* find( object_id_type id )const override + const object* find( object_id_type id )const override { if( DirectBits > 0 ) return _direct_by_id->find( id ); @@ -338,12 +341,12 @@ namespace graphene { namespace db { fc::sha256 get_object_version()const { - std::string desc = "1.0";//get_type_description(); + std::string desc = "1.0"; return fc::sha256::hash(desc); } - virtual void open( const path& db )override - { + void open( const fc::path& db )override + { if( !fc::exists( db ) ) return; fc::file_mapping fm( db.generic_string().c_str(), fc::read_only ); fc::mapped_region mr( fm, fc::read_only, 0, fc::file_size(db) ); @@ -352,8 +355,9 @@ namespace graphene { namespace db { fc::raw::unpack(ds, _next_id); fc::raw::unpack(ds, open_ver); - FC_ASSERT( open_ver == get_object_version(), "Incompatible Version, the serialization of objects in this index has changed" ); - vector tmp; + FC_ASSERT( open_ver == get_object_version(), + "Incompatible Version, the serialization of objects in this index has changed" ); + std::vector tmp; while( ds.remaining() > 0 ) { fc::raw::unpack( ds, tmp ); @@ -361,22 +365,22 @@ namespace graphene { namespace db { } } - virtual void save( const path& db ) override + void save( const fc::path& db ) override { - std::ofstream out( db.generic_string(), + std::ofstream out( db.generic_string(), std::ofstream::binary | std::ofstream::out | std::ofstream::trunc ); FC_ASSERT( out ); auto ver = get_object_version(); fc::raw::pack( out, _next_id ); fc::raw::pack( out, ver ); - this->inspect_all_objects( [&]( const object& o ) { + this->inspect_all_objects( [&out]( const object& o ) { auto vec = fc::raw::pack( static_cast(o) ); auto packed_vec = fc::raw::pack( vec ); out.write( packed_vec.data(), packed_vec.size() ); }); } - virtual const object& load( const std::vector& data )override + const object& load( const std::vector& data )override { const auto& result = DerivedIndex::insert( fc::raw::unpack( data ) ); for( const auto& item : _sindex ) @@ -385,7 +389,7 @@ namespace graphene { namespace db { } - virtual const object& create(const std::function& constructor )override + const object& create(const std::function& constructor )override { const auto& result = DerivedIndex::create( constructor ); for( const auto& item : _sindex ) @@ -394,7 +398,7 @@ namespace graphene { namespace db { return result; } - virtual const object& insert( object&& obj ) override + const object& insert( object&& obj ) override { const auto& result = DerivedIndex::insert( std::move( obj ) ); for( const auto& item : _sindex ) @@ -403,7 +407,7 @@ namespace graphene { namespace db { return result; } - virtual void remove( const object& obj ) override + void remove( const object& obj ) override { for( const auto& item : _sindex ) item->object_removed( obj ); @@ -411,7 +415,7 @@ namespace graphene { namespace db { DerivedIndex::remove(obj); } - virtual void modify( const object& obj, const std::function& m )override + void modify( const object& obj, const std::function& m )override { save_undo( obj ); for( const auto& item : _sindex ) @@ -422,12 +426,12 @@ namespace graphene { namespace db { on_modify( obj ); } - virtual void add_observer( const shared_ptr& o ) override + void add_observer( const std::shared_ptr& o ) override { _observers.emplace_back( o ); } - virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const override + void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const override { object_id_type id = obj.id; object_type* result = dynamic_cast( &obj ); @@ -436,7 +440,7 @@ namespace graphene { namespace db { obj.id = id; } - virtual void object_default( object& obj )const override + void object_default( object& obj )const override { object_id_type id = obj.id; object_type* result = dynamic_cast( &obj ); diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index 125ff4293e..bc03841511 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -30,7 +30,6 @@ #define MAX_NESTING (200) namespace graphene { namespace db { - /** * @brief base for all database objects * @@ -62,51 +61,66 @@ namespace graphene { namespace db { class object { public: - object(){} - virtual ~object(){} + object() = default; + object( uint8_t space_id, uint8_t type_id ) : id( space_id, type_id, 0 ) {} + virtual ~object() = default; // serialized object_id_type id; - /// these methods are implemented for derived classes by inheriting abstract_object - virtual unique_ptr clone()const = 0; - virtual void move_from( object& obj ) = 0; - virtual variant to_variant()const = 0; - virtual vector pack()const = 0; + /// these methods are implemented for derived classes by inheriting base_abstract_object + /// @{ + virtual std::unique_ptr clone()const = 0; + virtual void move_from( object& obj ) = 0; + virtual fc::variant to_variant()const = 0; + virtual std::vector pack()const = 0; + /// @} }; /** - * @class abstract_object + * @class base_abstract_object * @brief Use the Curiously Recurring Template Pattern to automatically add the ability to * clone, serialize, and move objects polymorphically. * * http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ template - class abstract_object : public object + class base_abstract_object : public object { public: - virtual unique_ptr clone()const + using object::object; // constructors + std::unique_ptr clone()const override { - return unique_ptr( std::make_unique( *static_cast(this) ) ); + return std::make_unique( *static_cast(this) ); } - virtual void move_from( object& obj ) + void move_from( object& obj ) override { static_cast(*this) = std::move( static_cast(obj) ); } - virtual variant to_variant()const { return variant( static_cast(*this), MAX_NESTING ); } - virtual vector pack()const { return fc::raw::pack( static_cast(*this) ); } + fc::variant to_variant()const override + { return fc::variant( static_cast(*this), MAX_NESTING ); } + std::vector pack()const override { return fc::raw::pack( static_cast(*this) ); } + }; + + template + class abstract_object : public base_abstract_object + { + public: + static constexpr uint8_t space_id = SpaceID; + static constexpr uint8_t type_id = TypeID; + abstract_object() : base_abstract_object( space_id, type_id ) {} + object_id get_id() const { return object_id( this->id ); } }; - typedef flat_map annotation_map; + using annotation_map = fc::flat_map; /** * @class annotated_object * @brief An object that is easily extended by providing pointers to other objects, one for each space. */ template - class annotated_object : public abstract_object + class annotated_object : public base_abstract_object { public: /** return object_id_type() if no anotation is found for id_space */ @@ -139,4 +153,5 @@ struct is_restricted_conversion : public mpl::true_ {}; FC_REFLECT_TYPENAME( graphene::db::annotation_map ) FC_REFLECT( graphene::db::object, (id) ) -FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object, (graphene::db::object), (annotations) ) +FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object, (graphene::db::object), + (annotations) ) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index d189cd1b1a..8596ba3859 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -40,9 +40,15 @@ namespace graphene { namespace db { { public: object_database(); - ~object_database(); + virtual ~object_database() = default; - void reset_indexes() { _index.clear(); _index.resize(255); } + static constexpr uint8_t _index_size = 255; + + void reset_indexes() + { + _index.clear(); + _index.resize(_index_size); + } void open(const fc::path& data_dir ); @@ -64,23 +70,26 @@ namespace graphene { namespace db { } )); } - ///These methods are used to retrieve indexes on the object_database. All public index accessors are const-access only. + /// These methods are used to retrieve indexes on the object_database. All public index accessors are + /// const-access only. /// @{ template const IndexType& get_index_type()const { static_assert( std::is_base_of::value, "Type must be an index type" ); - return static_cast( get_index( IndexType::object_type::space_id, IndexType::object_type::type_id ) ); + return static_cast( get_index( IndexType::object_type::space_id, + IndexType::object_type::type_id ) ); } template const index& get_index()const { return get_index(T::space_id,T::type_id); } const index& get_index(uint8_t space_id, uint8_t type_id)const; - const index& get_index(object_id_type id)const { return get_index(id.space(),id.type()); } + const index& get_index(const object_id_type& id)const { return get_index(id.space(),id.type()); } /// @} - const object& get_object( object_id_type id )const; - const object* find_object( object_id_type id )const; + const object& get_object( const object_id_type& id )const; + const object* find_object( const object_id_type& id )const; - /// These methods are mutators of the object_database. You must use these methods to make changes to the object_database, + /// These methods are mutators of the object_database. + /// You must use these methods to make changes to the object_database, /// in order to maintain proper undo history. ///@{ @@ -107,14 +116,14 @@ namespace graphene { namespace db { } template - const T& get( object_id_type id )const + const T& get( const object_id_type& id )const { const object& obj = get_object( id ); assert( nullptr != dynamic_cast(&obj) ); return static_cast(obj); } template - const T* find( object_id_type id )const + const T* find( const object_id_type& id )const { const object* obj = find_object( id ); assert( !obj || nullptr != dynamic_cast(obj) ); @@ -122,31 +131,35 @@ namespace graphene { namespace db { } template - auto find( object_id id )const -> const object_downcast_t* { - return find>(id); + auto find( const object_id& id )const -> const object_downcast_t* { + return find>(object_id_type(id)); } template - auto get( object_id id )const -> const object_downcast_t& { - return get>(id); + auto get( const object_id& id )const -> const object_downcast_t& { + return get>(object_id_type(id)); } template IndexType* add_index() { - typedef typename IndexType::object_type ObjectType; - if( _index[ObjectType::space_id].size() <= ObjectType::type_id ) - _index[ObjectType::space_id].resize( 255 ); - assert(!_index[ObjectType::space_id][ObjectType::type_id]); - unique_ptr indexptr( std::make_unique(*this) ); - _index[ObjectType::space_id][ObjectType::type_id] = std::move(indexptr); - return static_cast(_index[ObjectType::space_id][ObjectType::type_id].get()); + using ObjectType = typename IndexType::object_type; + const auto space_id = ObjectType::space_id; + const auto type_id = ObjectType::type_id; + FC_ASSERT( space_id < _index.size(), "Space ID ${s} overflow", ("s",space_id) ); + if( _index[space_id].size() <= type_id ) + _index[space_id].resize( _index_size ); + FC_ASSERT( type_id < _index[space_id].size(), "Type ID ${t} overflow", ("t",type_id) ); + FC_ASSERT( !_index[space_id][type_id], "Index ${s}.${t} already exists", ("s",space_id)("t",type_id) ); + _index[space_id][type_id] = std::make_unique(*this); + return static_cast(_index[space_id][type_id].get()); } template SecondaryIndexType* add_secondary_index( Args... args ) { - return get_mutable_index_type().template add_secondary_index(args...); + return get_mutable_index_type().template + add_secondary_index(args...); } void pop_undo(); @@ -159,11 +172,12 @@ namespace graphene { namespace db { template IndexType& get_mutable_index_type() { static_assert( std::is_base_of::value, "Type must be an index type" ); - return static_cast( get_mutable_index( IndexType::object_type::space_id, IndexType::object_type::type_id ) ); + return static_cast( get_mutable_index( IndexType::object_type::space_id, + IndexType::object_type::type_id ) ); } template - index& get_mutable_index() { return get_mutable_index(T::space_id,T::type_id); } - index& get_mutable_index(object_id_type id) { return get_mutable_index(id.space(),id.type()); } + index& get_mutable_index() { return get_mutable_index(T::space_id,T::type_id); } + index& get_mutable_index(const object_id_type& id) { return get_mutable_index(id.space(),id.type()); } index& get_mutable_index(uint8_t space_id, uint8_t type_id); private: @@ -175,7 +189,7 @@ namespace graphene { namespace db { void save_undo_remove( const object& obj ); fc::path _data_dir; - vector< vector< unique_ptr > > _index; + std::vector< std::vector< std::unique_ptr > > _index; }; } } // graphene::db diff --git a/libraries/db/include/graphene/db/simple_index.hpp b/libraries/db/include/graphene/db/simple_index.hpp index 7cbdb538f1..3d80fe77fd 100644 --- a/libraries/db/include/graphene/db/simple_index.hpp +++ b/libraries/db/include/graphene/db/simple_index.hpp @@ -38,7 +38,7 @@ namespace graphene { namespace db { class simple_index : public index { public: - typedef T object_type; + using object_type = T; virtual const object& create( const std::function& constructor ) override { @@ -102,10 +102,10 @@ namespace graphene { namespace db { class const_iterator { public: - const_iterator( const vector>& objects ):_objects(objects) {} + explicit const_iterator( const std::vector>& objects ):_objects(objects) {} const_iterator( - const vector>& objects, - const vector>::const_iterator& a ):_itr(a),_objects(objects){} + const std::vector>& objects, + const std::vector>::const_iterator& a ):_itr(a),_objects(objects){} friend bool operator==( const const_iterator& a, const const_iterator& b ) { return a._itr == b._itr; } friend bool operator!=( const const_iterator& a, const const_iterator& b ) { return a._itr != b._itr; } const T& operator*()const { return static_cast(*_itr->get()); } @@ -122,21 +122,21 @@ namespace graphene { namespace db { ++_itr; return *this; } - typedef std::forward_iterator_tag iterator_category; - typedef vector >::value_type value_type; - typedef vector >::difference_type difference_type; - typedef vector >::pointer pointer; - typedef vector >::reference reference; + using iterator_category = std::forward_iterator_tag; + using value_type = std::vector >::value_type; + using difference_type = std::vector >::difference_type; + using pointer = std::vector >::pointer; + using reference = std::vector >::reference; private: - vector>::const_iterator _itr; - const vector>& _objects; + std::vector>::const_iterator _itr; + const std::vector>& _objects; }; const_iterator begin()const { return const_iterator(_objects, _objects.begin()); } const_iterator end()const { return const_iterator(_objects, _objects.end()); } size_t size()const { return _objects.size(); } private: - vector< unique_ptr > _objects; + std::vector< std::unique_ptr > _objects; }; } } // graphene::db diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index 5234ac65aa..ed9a5f3e2e 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -28,16 +28,14 @@ namespace graphene { namespace db { - using std::unordered_map; - using fc::flat_set; class object_database; struct undo_state { - unordered_map > old_values; - unordered_map old_index_next_ids; - std::unordered_set new_ids; - unordered_map > removed; + std::unordered_map > old_values; + std::unordered_map old_index_next_ids; + std::unordered_set new_ids; + std::unordered_map > removed; }; @@ -49,7 +47,7 @@ namespace graphene { namespace db { class undo_database { public: - undo_database( object_database& db ):_db(db){} + explicit undo_database( object_database& db ):_db(db){} class session { @@ -75,7 +73,10 @@ namespace graphene { namespace db { private: friend class undo_database; - session(undo_database& db, bool disable_on_exit = false): _db(db),_disable_on_exit(disable_on_exit) {} + + explicit session(undo_database& db, bool disable_on_exit = false) + : _db(db),_disable_on_exit(disable_on_exit) {} + undo_database& _db; bool _apply_undo = true; bool _disable_on_exit = false; diff --git a/libraries/db/object_database.cpp b/libraries/db/object_database.cpp index 5e91c7c87d..25ffcbe54f 100644 --- a/libraries/db/object_database.cpp +++ b/libraries/db/object_database.cpp @@ -32,21 +32,19 @@ namespace graphene { namespace db { object_database::object_database() :_undo_db(*this) { - _index.resize(255); + _index.resize(_index_size); _undo_db.enable(); } -object_database::~object_database(){} - void object_database::close() { } -const object* object_database::find_object( object_id_type id )const +const object* object_database::find_object( const object_id_type& id )const { return get_index(id.space(),id.type()).find( id ); } -const object& object_database::get_object( object_id_type id )const +const object& object_database::get_object( const object_id_type& id )const { return get_index(id.space(),id.type()).get( id ); } diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index b533e61a35..d8b55288f9 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -12,7 +12,7 @@ set(SOURCES node.cpp add_library( graphene_net ${SOURCES} ${HEADERS} ) target_link_libraries( graphene_net - PUBLIC fc graphene_db graphene_protocol ) + PUBLIC graphene_db graphene_protocol fc ) target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PRIVATE "${CMAKE_SOURCE_DIR}/libraries/chain/include" diff --git a/libraries/plugins/account_history/CMakeLists.txt b/libraries/plugins/account_history/CMakeLists.txt index 4af81abb12..69509ed528 100644 --- a/libraries/plugins/account_history/CMakeLists.txt +++ b/libraries/plugins/account_history/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_account_history account_history_plugin.cpp ) -target_link_libraries( graphene_account_history graphene_chain graphene_app ) +target_link_libraries( graphene_account_history graphene_app graphene_chain ) target_include_directories( graphene_account_history PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/account_history/account_history_plugin.cpp b/libraries/plugins/account_history/account_history_plugin.cpp index 58a6119c63..de00dfff02 100644 --- a/libraries/plugins/account_history/account_history_plugin.cpp +++ b/libraries/plugins/account_history/account_history_plugin.cpp @@ -161,7 +161,7 @@ void account_history_plugin_impl::update_account_histories( const signed_block& MUST_IGNORE_CUSTOM_OP_REQD_AUTHS( db.head_block_time() ) ); if( op.op.is_type< account_create_operation >() ) - impacted.insert( op.result.get() ); + impacted.insert( account_id_type( op.result.get() ) ); // https://github.com/bitshares/bitshares-core/issues/265 if( HARDFORK_CORE_265_PASSED(b.timestamp) || !op.op.is_type< account_create_operation >() ) @@ -306,7 +306,7 @@ void account_history_plugin_impl::check_and_remove_op_history_obj( const operati graphene::chain::database& db = database(); const auto& his_idx = db.get_index_type(); const auto& by_opid_idx = his_idx.indices().get(); - if( by_opid_idx.find( op.id ) == by_opid_idx.end() ) + if( by_opid_idx.find( op.get_id() ) == by_opid_idx.end() ) { // if no reference, remove db.remove( op ); diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp index d0cd598281..68ef3ed58c 100644 --- a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp +++ b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp @@ -50,11 +50,9 @@ enum account_history_object_type }; /// This struct tracks accounts that have exceeded the max-ops-per-account limit -struct exceeded_account_object : public abstract_object +struct exceeded_account_object : public abstract_object { - static constexpr uint8_t space_id = ACCOUNT_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = exceeded_account_object_type; - /// The ID of the account account_id_type account_id; /// The height of the block containing the oldest (not yet removed) operation related to this account diff --git a/libraries/plugins/api_helper_indexes/CMakeLists.txt b/libraries/plugins/api_helper_indexes/CMakeLists.txt index 26c1f16699..648e93a8fe 100644 --- a/libraries/plugins/api_helper_indexes/CMakeLists.txt +++ b/libraries/plugins/api_helper_indexes/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_api_helper_indexes api_helper_indexes.cpp ) -target_link_libraries( graphene_api_helper_indexes graphene_chain graphene_app ) +target_link_libraries( graphene_api_helper_indexes graphene_app graphene_chain ) target_include_directories( graphene_api_helper_indexes PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/api_helper_indexes/api_helper_indexes.cpp b/libraries/plugins/api_helper_indexes/api_helper_indexes.cpp index 2e1530f2cb..e6cd8100f6 100644 --- a/libraries/plugins/api_helper_indexes/api_helper_indexes.cpp +++ b/libraries/plugins/api_helper_indexes/api_helper_indexes.cpp @@ -97,15 +97,17 @@ share_type amount_in_collateral_index::get_backing_collateral( const asset_id_ty void asset_in_liquidity_pools_index::object_inserted( const object& objct ) { try { const auto& o = static_cast( objct ); - asset_in_pools_map[ o.asset_a ].insert( o.id ); // Note: [] operator will create an entry if not found - asset_in_pools_map[ o.asset_b ].insert( o.id ); + const liquidity_pool_id_type pool_id = o.get_id(); + asset_in_pools_map[ o.asset_a ].insert( pool_id ); // Note: [] operator will create an entry if not found + asset_in_pools_map[ o.asset_b ].insert( pool_id ); } FC_CAPTURE_AND_RETHROW( (objct) ) } void asset_in_liquidity_pools_index::object_removed( const object& objct ) { try { const auto& o = static_cast( objct ); - asset_in_pools_map[ o.asset_a ].erase( o.id ); - asset_in_pools_map[ o.asset_b ].erase( o.id ); + const liquidity_pool_id_type pool_id = o.get_id(); + asset_in_pools_map[ o.asset_a ].erase( pool_id ); + asset_in_pools_map[ o.asset_b ].erase( pool_id ); // Note: do not erase entries with an empty set from the map in order to avoid read/write race conditions } FC_CAPTURE_AND_RETHROW( (objct) ) } @@ -224,12 +226,11 @@ void api_helper_indexes::refresh_next_ids() // Assuming that all indexes have been created when processing the first block, // for better performance, only do this twice, one on plugin startup, the other on the first block. - constexpr uint8_t max = 255; size_t count = 0; size_t failed_count = 0; - for( uint8_t space = 0; space < max; ++space ) + for( uint8_t space = 0; space < chain::database::_index_size; ++space ) { - for( uint8_t type = 0; type < max; ++type ) + for( uint8_t type = 0; type < chain::database::_index_size; ++type ) { try { diff --git a/libraries/plugins/custom_operations/CMakeLists.txt b/libraries/plugins/custom_operations/CMakeLists.txt index 4202f740c8..246c2ae577 100644 --- a/libraries/plugins/custom_operations/CMakeLists.txt +++ b/libraries/plugins/custom_operations/CMakeLists.txt @@ -6,7 +6,7 @@ add_library( graphene_custom_operations custom_evaluators.cpp ) -target_link_libraries( graphene_custom_operations graphene_chain graphene_app ) +target_link_libraries( graphene_custom_operations graphene_app graphene_chain ) target_include_directories( graphene_custom_operations PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/custom_operations/include/graphene/custom_operations/custom_objects.hpp b/libraries/plugins/custom_operations/include/graphene/custom_operations/custom_objects.hpp index 2a550ac46d..81351cea8d 100644 --- a/libraries/plugins/custom_operations/include/graphene/custom_operations/custom_objects.hpp +++ b/libraries/plugins/custom_operations/include/graphene/custom_operations/custom_objects.hpp @@ -38,11 +38,9 @@ enum class custom_operations_object_types { account_map = 0 }; -struct account_storage_object : public abstract_object +struct account_storage_object : public abstract_object( custom_operations_object_types::account_map )> { - static constexpr uint8_t space_id = CUSTOM_OPERATIONS_SPACE_ID; - static constexpr uint8_t type_id = static_cast( custom_operations_object_types::account_map ); - account_id_type account; string catalog; string key; diff --git a/libraries/plugins/debug_witness/CMakeLists.txt b/libraries/plugins/debug_witness/CMakeLists.txt index c512066981..a8f53bc74e 100644 --- a/libraries/plugins/debug_witness/CMakeLists.txt +++ b/libraries/plugins/debug_witness/CMakeLists.txt @@ -5,7 +5,7 @@ add_library( graphene_debug_witness debug_witness.cpp ) -target_link_libraries( graphene_debug_witness graphene_chain graphene_app ) +target_link_libraries( graphene_debug_witness graphene_app graphene_chain ) target_include_directories( graphene_debug_witness PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/delayed_node/CMakeLists.txt b/libraries/plugins/delayed_node/CMakeLists.txt index 63dd73e53c..2dfce0541f 100644 --- a/libraries/plugins/delayed_node/CMakeLists.txt +++ b/libraries/plugins/delayed_node/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_delayed_node delayed_node_plugin.cpp ) -target_link_libraries( graphene_delayed_node graphene_chain graphene_app ) +target_link_libraries( graphene_delayed_node graphene_app graphene_chain ) target_include_directories( graphene_delayed_node PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/elasticsearch/CMakeLists.txt b/libraries/plugins/elasticsearch/CMakeLists.txt index 971de3a191..25d69d5807 100644 --- a/libraries/plugins/elasticsearch/CMakeLists.txt +++ b/libraries/plugins/elasticsearch/CMakeLists.txt @@ -7,7 +7,7 @@ add_library( graphene_elasticsearch if(MSVC) set_source_files_properties(elasticsearch_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) endif(MSVC) -target_link_libraries( graphene_elasticsearch graphene_chain graphene_app ) +target_link_libraries( graphene_elasticsearch graphene_app graphene_chain ) target_include_directories( graphene_elasticsearch PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index c62c3ef87c..2831b6bc5f 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -101,7 +101,7 @@ class elasticsearch_plugin_impl void doBlock(uint32_t trx_in_block, const signed_block& b, block_struct& bs) const; void doVisitor(const optional & oho, visitor_struct& vs) const; void checkState(const fc::time_point_sec& block_time); - void cleanObjects(const account_history_id_type& ath, const account_id_type& account_id); + void cleanObjects(const account_history_object& ath, const account_id_type& account_id); void init_program_options(const boost::program_options::variables_map& options); }; @@ -181,7 +181,7 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b MUST_IGNORE_CUSTOM_OP_REQD_AUTHS( db.head_block_time() ) ); if( op.op.is_type< account_create_operation >() ) - impacted.insert( op.result.get() ); + impacted.insert( account_id_type( op.result.get() ) ); // https://github.com/bitshares/bitshares-core/issues/265 if( HARDFORK_CORE_265_PASSED(b.timestamp) || !op.op.is_type< account_create_operation >() ) @@ -438,10 +438,10 @@ void elasticsearch_plugin_impl::add_elasticsearch( const account_id_type& accoun if( bulk_lines.size() >= limit_documents ) send_bulk(); } - cleanObjects(ath.id, account_id); + cleanObjects(ath, account_id); } -void elasticsearch_plugin_impl::cleanObjects( const account_history_id_type& ath_id, +void elasticsearch_plugin_impl::cleanObjects( const account_history_object& ath, const account_id_type& account_id ) { graphene::chain::database& db = database(); @@ -449,7 +449,7 @@ void elasticsearch_plugin_impl::cleanObjects( const account_history_id_type& ath const auto &his_idx = db.get_index_type(); const auto &by_seq_idx = his_idx.indices().get(); auto itr = by_seq_idx.lower_bound(boost::make_tuple(account_id, 0)); - if (itr != by_seq_idx.end() && itr->account == account_id && itr->id != ath_id) { + if (itr != by_seq_idx.end() && itr->account == account_id && itr->id != ath.id) { // if found, remove the entry const auto remove_op_id = itr->operation_id; const auto itr_remove = itr; @@ -459,7 +459,7 @@ void elasticsearch_plugin_impl::cleanObjects( const account_history_id_type& ath // this should be always true, but just have a check here if( itr != by_seq_idx.end() && itr->account == account_id ) { - db.modify( *itr, [&]( account_history_object& obj ){ + db.modify( *itr, []( account_history_object& obj ){ obj.next = account_history_id_type(); }); } diff --git a/libraries/plugins/es_objects/CMakeLists.txt b/libraries/plugins/es_objects/CMakeLists.txt index 926e157f44..99980acb71 100644 --- a/libraries/plugins/es_objects/CMakeLists.txt +++ b/libraries/plugins/es_objects/CMakeLists.txt @@ -8,7 +8,7 @@ if(MSVC) set_source_files_properties(es_objects.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) endif(MSVC) -target_link_libraries( graphene_es_objects graphene_chain graphene_app ) +target_link_libraries( graphene_es_objects graphene_app graphene_chain ) target_include_directories( graphene_es_objects PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/grouped_orders/CMakeLists.txt b/libraries/plugins/grouped_orders/CMakeLists.txt index 4ec9f64d27..4a22b8d2bb 100644 --- a/libraries/plugins/grouped_orders/CMakeLists.txt +++ b/libraries/plugins/grouped_orders/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_grouped_orders grouped_orders_plugin.cpp ) -target_link_libraries( graphene_grouped_orders graphene_chain graphene_app ) +target_link_libraries( graphene_grouped_orders graphene_app graphene_chain ) target_include_directories( graphene_grouped_orders PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/market_history/CMakeLists.txt b/libraries/plugins/market_history/CMakeLists.txt index 47410d7488..9acb4d76bc 100644 --- a/libraries/plugins/market_history/CMakeLists.txt +++ b/libraries/plugins/market_history/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_market_history market_history_plugin.cpp ) -target_link_libraries( graphene_market_history graphene_chain graphene_app ) +target_link_libraries( graphene_market_history graphene_app graphene_chain ) target_include_directories( graphene_market_history PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp index bc70ae8794..6bdaccf1f3 100644 --- a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp +++ b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp @@ -55,9 +55,10 @@ enum market_history_object_type bucket_object_type = 1, market_ticker_object_type = 2, market_ticker_meta_object_type = 3, - liquidity_pool_history_object_type = 4, - liquidity_pool_ticker_meta_object_type = 5, - liquidity_pool_ticker_object_type = 6 + // LP = liquidity pool + lp_history_object_type = 4, + lp_ticker_meta_object_type = 5, + lp_ticker_object_type = 6 }; struct bucket_key @@ -81,11 +82,8 @@ struct bucket_key } }; -struct bucket_object : public abstract_object +struct bucket_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = bucket_object_type; - price high()const { return asset( high_base, key.base ) / asset( high_quote, key.quote ); } price low()const { return asset( low_base, key.base ) / asset( low_quote, key.quote ); } @@ -114,36 +112,32 @@ struct history_key { return std::tie( a.base, a.quote, a.sequence ) == std::tie( b.base, b.quote, b.sequence ); } }; -struct order_history_object : public abstract_object +struct order_history_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = order_history_object_type; - history_key key; fc::time_point_sec time; fill_order_operation op; }; struct order_history_object_key_base_extractor { - typedef asset_id_type result_type; + using result_type = asset_id_type; result_type operator()(const order_history_object& o)const { return o.key.base; } }; struct order_history_object_key_quote_extractor { - typedef asset_id_type result_type; + using result_type = asset_id_type; result_type operator()(const order_history_object& o)const { return o.key.quote; } }; struct order_history_object_key_sequence_extractor { - typedef int64_t result_type; + using result_type = int64_t; result_type operator()(const order_history_object& o)const { return o.key.sequence; } }; -struct market_ticker_object : public abstract_object +struct market_ticker_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = market_ticker_object_type; - asset_id_type base; asset_id_type quote; share_type last_day_base; @@ -154,26 +148,24 @@ struct market_ticker_object : public abstract_object fc::uint128_t quote_volume; }; -struct market_ticker_meta_object : public abstract_object +struct market_ticker_meta_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = market_ticker_meta_object_type; - object_id_type rolling_min_order_his_id; bool skip_min_order_his_id = false; }; struct by_key; -typedef multi_index_container< +using bucket_object_multi_index_type = multi_index_container< bucket_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, ordered_unique< tag, member< bucket_object, bucket_key, &bucket_object::key > > > -> bucket_object_multi_index_type; +>; struct by_market_time; -typedef multi_index_container< +using order_history_multi_index_type = multi_index_container< order_history_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, @@ -195,11 +187,11 @@ typedef multi_index_container< > > > -> order_history_multi_index_type; +>; struct by_market; struct by_volume; -typedef multi_index_container< +using market_ticker_obj_mlti_idx_type = multi_index_container< market_ticker_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, @@ -214,19 +206,17 @@ typedef multi_index_container< > > > -> market_ticker_object_multi_index_type; +>; -typedef generic_index bucket_index; -typedef generic_index history_index; -typedef generic_index market_ticker_index; +using bucket_index = generic_index; +using history_index = generic_index; +using market_ticker_index = generic_index; /** Stores operation histories related to liquidity pools */ -struct liquidity_pool_history_object : public abstract_object +struct liquidity_pool_history_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = liquidity_pool_history_object_type; - liquidity_pool_id_type pool; uint64_t sequence = 0; fc::time_point_sec time; @@ -239,7 +229,7 @@ struct by_pool_time; struct by_pool_op_type_seq; struct by_pool_op_type_time; -typedef multi_index_container< +using lp_history_multi_index_type = multi_index_container< liquidity_pool_history_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, @@ -292,30 +282,25 @@ typedef multi_index_container< > > > -> liquidity_pool_history_multi_index_type; +>; -typedef generic_index< liquidity_pool_history_object, - liquidity_pool_history_multi_index_type > liquidity_pool_history_index; +using liquidity_pool_history_index = generic_index< liquidity_pool_history_object, lp_history_multi_index_type >; /// Stores meta data for liquidity pool tickers -struct liquidity_pool_ticker_meta_object : public abstract_object +struct lp_ticker_meta_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = liquidity_pool_ticker_meta_object_type; - object_id_type rolling_min_lp_his_id; bool skip_min_lp_his_id = false; }; -using liquidity_pool_ticker_id_type = object_id; +using liquidity_pool_ticker_id_type = object_id; /// Stores ticker data for liquidity pools -struct liquidity_pool_ticker_object : public abstract_object +struct liquidity_pool_ticker_object : public abstract_object { - static constexpr uint8_t space_id = MARKET_HISTORY_SPACE_ID; - static constexpr uint8_t type_id = liquidity_pool_ticker_object_type; - uint32_t _24h_deposit_count = 0; fc::uint128_t _24h_deposit_amount_a = 0; fc::uint128_t _24h_deposit_amount_b = 0; @@ -356,15 +341,14 @@ struct liquidity_pool_ticker_object : public abstract_object, member< object, object_id_type, &object::id > > > -> liquidity_pool_ticker_multi_index_type; +>; -typedef generic_index< liquidity_pool_ticker_object, - liquidity_pool_ticker_multi_index_type > liquidity_pool_ticker_index; +using liquidity_pool_ticker_index = generic_index< liquidity_pool_ticker_object, lp_ticker_multi_index_type >; namespace detail @@ -373,9 +357,9 @@ namespace detail } /** - * The market history plugin can be configured to track any number of intervals via its configuration. Once per block it - * will scan the virtual operations and look for fill_order_operations and then adjust the appropriate bucket objects for - * each fill order. + * The market history plugin can be configured to track any number of intervals via its configuration. + * Once per block it will scan the virtual operations and look for fill_order_operations and then adjust + * the appropriate bucket objects for each fill order. */ class market_history_plugin : public graphene::app::plugin { @@ -402,6 +386,9 @@ class market_history_plugin : public graphene::app::plugin } } //graphene::market_history +// Other objects aren't mapped here because they are not used +MAP_OBJECT_ID_TO_TYPE( graphene::market_history::liquidity_pool_ticker_object ) + FC_REFLECT( graphene::market_history::history_key, (base)(quote)(sequence) ) FC_REFLECT_DERIVED( graphene::market_history::order_history_object, (graphene::db::object), (key)(time)(op) ) FC_REFLECT( graphene::market_history::bucket_key, (base)(quote)(seconds)(open) ) @@ -421,7 +408,7 @@ FC_REFLECT_DERIVED( graphene::market_history::market_ticker_meta_object, (graphe (rolling_min_order_his_id)(skip_min_order_his_id) ) FC_REFLECT_DERIVED( graphene::market_history::liquidity_pool_history_object, (graphene::db::object), (pool)(sequence)(time)(op_type)(op) ) -FC_REFLECT_DERIVED( graphene::market_history::liquidity_pool_ticker_meta_object, (graphene::db::object), +FC_REFLECT_DERIVED( graphene::market_history::lp_ticker_meta_object, (graphene::db::object), (rolling_min_lp_his_id)(skip_min_lp_his_id) ) FC_REFLECT_DERIVED( graphene::market_history::liquidity_pool_ticker_object, (graphene::db::object), (_24h_deposit_count) diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index 29699b1eba..382ed4fc62 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -53,7 +53,7 @@ class market_history_plugin_impl /// process all operations related to liquidity pools void update_liquidity_pool_histories( time_point_sec time, const operation_history_object& oho, - const liquidity_pool_ticker_meta_object*& lp_meta ); + const lp_ticker_meta_object*& lp_meta ); graphene::chain::database& database() { @@ -302,8 +302,8 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b if( meta_idx.size() > 0 ) _meta = &( *meta_idx.begin() ); - const liquidity_pool_ticker_meta_object* _lp_meta = nullptr; - const auto& lp_meta_idx = db.get_index_type>(); + const lp_ticker_meta_object* _lp_meta = nullptr; + const auto& lp_meta_idx = db.get_index_type>(); if( lp_meta_idx.size() > 0 ) _lp_meta = &( *lp_meta_idx.begin() ); @@ -407,7 +407,7 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b else { liquidity_pool_ticker_id_type ticker_id( history_itr->pool.instance ); - const liquidity_pool_ticker_object* ticker = db.find( ticker_id ); + const liquidity_pool_ticker_object* ticker = db.find( ticker_id ); if( ticker != nullptr ) // should always be true { const operation_history_object& oho = history_itr->op; @@ -475,7 +475,7 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b { if( history_itr->id != _lp_meta->rolling_min_lp_his_id ) // if rolled out some { - db.modify( *_lp_meta, [history_itr]( liquidity_pool_ticker_meta_object& mtm ) { + db.modify( *_lp_meta, [history_itr]( lp_ticker_meta_object& mtm ) { mtm.rolling_min_lp_his_id = history_itr->id; mtm.skip_min_lp_his_id = false; }); @@ -486,7 +486,7 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b if( !_lp_meta->skip_min_lp_his_id || last_min_his_id != _lp_meta->rolling_min_lp_his_id ) // if rolled out some { - db.modify( *_lp_meta, [last_min_his_id]( liquidity_pool_ticker_meta_object& mtm ) { + db.modify( *_lp_meta, [last_min_his_id]( lp_ticker_meta_object& mtm ) { mtm.rolling_min_lp_his_id = last_min_his_id; mtm.skip_min_lp_his_id = true; }); @@ -530,7 +530,7 @@ struct get_liquidity_pool_id_visitor void market_history_plugin_impl::update_liquidity_pool_histories( time_point_sec time, const operation_history_object& oho, - const liquidity_pool_ticker_meta_object*& lp_meta ) + const lp_ticker_meta_object*& lp_meta ) { try { optional pool; @@ -574,10 +574,9 @@ void market_history_plugin_impl::update_liquidity_pool_histories( // save a reference to the ticker meta object if( lp_meta == nullptr ) { - const auto& lp_meta_idx = db.get_index_type>(); + const auto& lp_meta_idx = db.get_index_type>(); if( lp_meta_idx.size() == 0 ) - lp_meta = &db.create( [&new_his_obj]( - liquidity_pool_ticker_meta_object& lptm ) { + lp_meta = &db.create( [&new_his_obj]( lp_ticker_meta_object& lptm ) { lptm.rolling_min_lp_his_id = new_his_obj.id; lptm.skip_min_lp_his_id = false; }); @@ -632,7 +631,7 @@ void market_history_plugin_impl::update_liquidity_pool_histories( else { liquidity_pool_ticker_id_type ticker_id( pool->instance ); - const liquidity_pool_ticker_object* ticker = db.find( ticker_id ); + const liquidity_pool_ticker_object* ticker = db.find( ticker_id ); if( ticker != nullptr ) { if( oho.op.is_type< liquidity_pool_deposit_operation >() ) @@ -775,7 +774,7 @@ void market_history_plugin::plugin_initialize(const boost::program_options::vari database().add_index< primary_index< simple_index< market_ticker_meta_object > > >(); database().add_index< primary_index< liquidity_pool_history_index > >(); - database().add_index< primary_index< simple_index< liquidity_pool_ticker_meta_object > > >(); + database().add_index< primary_index< simple_index< lp_ticker_meta_object > > >(); database().add_index< primary_index< liquidity_pool_ticker_index, 8 > >(); // 256 pools per chunk if( options.count( "bucket-size" ) > 0 ) diff --git a/libraries/plugins/snapshot/CMakeLists.txt b/libraries/plugins/snapshot/CMakeLists.txt index 227c386047..6e2f250b4b 100644 --- a/libraries/plugins/snapshot/CMakeLists.txt +++ b/libraries/plugins/snapshot/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_snapshot snapshot.cpp ) -target_link_libraries( graphene_snapshot graphene_chain graphene_app ) +target_link_libraries( graphene_snapshot graphene_app graphene_chain ) target_include_directories( graphene_snapshot PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/template_plugin/CMakeLists.txt b/libraries/plugins/template_plugin/CMakeLists.txt index a8a14584fc..d68c996139 100644 --- a/libraries/plugins/template_plugin/CMakeLists.txt +++ b/libraries/plugins/template_plugin/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_template_plugin template_plugin.cpp ) -target_link_libraries( graphene_template_plugin graphene_chain graphene_app ) +target_link_libraries( graphene_template_plugin graphene_app graphene_chain ) target_include_directories( graphene_template_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/plugins/witness/CMakeLists.txt b/libraries/plugins/witness/CMakeLists.txt index 3d4a9d272d..b7801e084a 100644 --- a/libraries/plugins/witness/CMakeLists.txt +++ b/libraries/plugins/witness/CMakeLists.txt @@ -4,7 +4,7 @@ add_library( graphene_witness witness.cpp ) -target_link_libraries( graphene_witness graphene_chain graphene_app ) +target_link_libraries( graphene_witness graphene_app graphene_chain ) target_include_directories( graphene_witness PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp index 0e7c3bafff..09a7bab33c 100644 --- a/libraries/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -80,7 +80,7 @@ share_type asset_issue_operation::calculate_fee(const fee_parameters_type& k)con } share_type asset_create_operation::calculate_fee( const asset_create_operation::fee_parameters_type& param, - optional sub_asset_creation_fee )const + const optional& sub_asset_creation_fee )const { share_type core_fee_required = param.long_symbol; diff --git a/libraries/protocol/include/graphene/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp index 180c10fce0..f2515f4fed 100644 --- a/libraries/protocol/include/graphene/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -220,7 +220,8 @@ namespace graphene { namespace protocol { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee( const fee_parameters_type& k, optional sub_asset_creation_fee )const; + share_type calculate_fee( const fee_parameters_type& k, + const optional& sub_asset_creation_fee )const; }; /** diff --git a/libraries/protocol/include/graphene/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp index b91aaf478d..1d7a8ff091 100644 --- a/libraries/protocol/include/graphene/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -154,7 +154,7 @@ namespace graphene { namespace protocol { asset receives; asset fee; // paid by receiving account price fill_price; - bool is_maker; + bool is_maker = true; pair get_market()const { diff --git a/libraries/protocol/include/graphene/protocol/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp index ba04e079d3..2fda3cf742 100644 --- a/libraries/protocol/include/graphene/protocol/object_id.hpp +++ b/libraries/protocol/include/graphene/protocol/object_id.hpp @@ -24,31 +24,30 @@ #pragma once #include #include -#include -#define GRAPHENE_DB_MAX_INSTANCE_ID (uint64_t(-1)>>16) namespace graphene { namespace db { - using std::shared_ptr; - using std::unique_ptr; - using std::vector; - using fc::flat_map; - using fc::variant; - using fc::unsigned_int; struct object_id_type { - object_id_type( uint8_t s, uint8_t t, uint64_t i ) + static constexpr uint8_t instance_bits = 48; + static constexpr uint8_t type_and_instance_bits = 56; + static constexpr uint64_t one_byte_mask = 0x00ff; + static constexpr uint64_t max_instance = 0x0000ffffffffffff; + + object_id_type() = default; + object_id_type( uint8_t s, uint8_t t, uint64_t i ){ reset( s, t, i ); } + + void reset( uint8_t s, uint8_t t, uint64_t i ) { - FC_ASSERT( i >> 48 == 0, "instance overflow", ("instance",i) ); - number = (uint64_t(s)<<56) | (uint64_t(t)<<48) | i; + FC_ASSERT( i >> instance_bits == 0, "instance overflow", ("instance",i) ); + number = ( (uint64_t(s) << type_and_instance_bits) | (uint64_t(t) << instance_bits) ) | i; } - object_id_type(){ number = 0; } - uint8_t space()const { return number >> 56; } - uint8_t type()const { return number >> 48 & 0x00ff; } - uint16_t space_type()const { return number >> 48; } - uint64_t instance()const { return number & GRAPHENE_DB_MAX_INSTANCE_ID; } - bool is_null()const { return number == 0; } + uint8_t space()const { return number >> type_and_instance_bits; } + uint8_t type()const { return (number >> instance_bits) & one_byte_mask; } + uint16_t space_type()const { return number >> instance_bits; } + uint64_t instance()const { return number & max_instance; } + bool is_null()const { return 0 == number; } explicit operator uint64_t()const { return number; } friend bool operator == ( const object_id_type& a, const object_id_type& b ) { return a.number == b.number; } @@ -61,18 +60,18 @@ namespace graphene { namespace db { friend object_id_type operator+(const object_id_type& a, int64_t delta ) { return object_id_type( a.space(), a.type(), a.instance() + delta ); } - friend size_t hash_value( object_id_type v ) { return std::hash()(v.number); } + friend size_t hash_value( const object_id_type& v ) { return std::hash()(v.number); } template< typename T > bool is() const { - return (number >> 48) == ( ((uint64_t)(((uint64_t)T::space_id) << 8)) | ((uint64_t)(T::type_id)) ); + return space_type() == T::space_type; } + template< typename T > T as() const { - FC_ASSERT( is() ); return T( *this ); } @@ -81,7 +80,7 @@ namespace graphene { namespace db { return fc::to_string(space()) + "." + fc::to_string(type()) + "." + fc::to_string(instance()); } - uint64_t number; + uint64_t number = 0; }; class object; @@ -94,8 +93,8 @@ namespace graphene { namespace db { #define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ namespace graphene { namespace db { \ template<> \ - struct object_downcast> { using type = OBJECT; }; \ + struct object_downcast&> { using type = OBJECT; }; \ } } template using object_downcast_t = typename object_downcast::type; @@ -103,29 +102,50 @@ namespace graphene { namespace db { template struct object_id { + static constexpr uint8_t type_bits = 8; + static constexpr uint8_t instance_bits = 48; + static constexpr uint64_t max_instance = 0x0000ffffffffffff; + static constexpr uint8_t space_id = SpaceID; static constexpr uint8_t type_id = TypeID; - static constexpr uint16_t space_type = uint16_t(uint16_t(space_id) << 8) | uint16_t(type_id); + static constexpr uint16_t space_type = uint16_t(uint16_t(space_id) << type_bits) | uint16_t(type_id); static constexpr object_id max() { - return object_id( 0xffffffffffff ); + return object_id( max_instance ); } object_id() = default; - object_id( unsigned_int i ):instance(i){} + explicit object_id( const fc::unsigned_int& i ):instance(i) + { + validate(); + } explicit object_id( uint64_t i ):instance(i) { - FC_ASSERT( (i >> 48) == 0 ); + validate(); } - object_id( object_id_type id ):instance(id.instance()) + explicit object_id( const object_id_type& id ):instance(id.instance()) + { + // Won't overflow, but need to check space and type + FC_ASSERT( id.is>(), "space or type mismatch" ); + } + + void validate()const + { + FC_ASSERT( (instance.value >> instance_bits) == 0, "instance overflow", ("instance",instance) ); + } + + object_id& operator=( const object_id_type& o ) { + *this = object_id(o); + return *this; } - friend object_id operator+(const object_id a, int64_t delta ) { return object_id( uint64_t(a.instance.value+delta) ); } + friend object_id operator+(const object_id& a, int64_t delta ) + { return object_id( uint64_t(a.instance.value+delta) ); } - operator object_id_type()const { return object_id_type( SpaceID, TypeID, instance.value ); } + explicit operator object_id_type()const { return object_id_type( SpaceID, TypeID, instance.value ); } explicit operator uint64_t()const { return object_id_type( *this ).number; } template @@ -142,17 +162,19 @@ namespace graphene { namespace db { friend bool operator == ( const fc::unsigned_int& a, const object_id& b ) { return a == b.instance; } friend bool operator != ( const fc::unsigned_int& a, const object_id& b ) { return a != b.instance; } - friend bool operator < ( const object_id& a, const object_id& b ) { return a.instance.value < b.instance.value; } - friend bool operator > ( const object_id& a, const object_id& b ) { return a.instance.value > b.instance.value; } + friend bool operator < ( const object_id& a, const object_id& b ) + { return a.instance.value < b.instance.value; } + friend bool operator > ( const object_id& a, const object_id& b ) + { return a.instance.value > b.instance.value; } - friend size_t hash_value( object_id v ) { return std::hash()(v.instance.value); } + friend size_t hash_value( const object_id& v ) { return std::hash()(v.instance.value); } explicit operator std::string() const { return fc::to_string(space_id) + "." + fc::to_string(type_id) + "." + fc::to_string(instance.value); } - unsigned_int instance; + fc::unsigned_int instance; // default is 0 }; } } // graphene::db @@ -166,7 +188,8 @@ struct get_typename> { static const char* name() { return typeid(get_typename).name(); - static std::string _str = string("graphene::db::object_id<")+fc::to_string(SpaceID) + ":" + fc::to_string(TypeID)+">"; + static std::string _str = string("graphene::db::object_id<") + fc::to_string(SpaceID) + ":" + + fc::to_string(TypeID) + ">"; return _str.c_str(); } }; @@ -174,8 +197,8 @@ struct get_typename> template struct reflector > { - typedef graphene::db::object_id type; - typedef std::true_type is_defined; + using type = graphene::db::object_id; + using is_defined = std::true_type; using native_members = typelist::list>; using inherited_members = typelist::list<>; using members = native_members; @@ -187,7 +210,7 @@ struct reflector > template static inline void visit( const Visitor& visitor ) { - typedef decltype(((type*)nullptr)->instance) member_type; + using member_type = decltype(((type*)nullptr)->instance); visitor.TEMPLATE operator()( "instance" ); } }; @@ -204,19 +227,19 @@ struct member_name, 0> { static constexpr const cha inline void from_variant( const fc::variant& var, graphene::db::object_id_type& vo, uint32_t max_depth = 1 ) { try { - vo.number = 0; const auto& s = var.get_string(); auto first_dot = s.find('.'); + FC_ASSERT( first_dot != std::string::npos, "Missing the first dot" ); + FC_ASSERT( first_dot != 0, "Missing the space part" ); auto second_dot = s.find('.',first_dot+1); - FC_ASSERT( first_dot != second_dot ); - FC_ASSERT( first_dot != 0 && first_dot != std::string::npos ); - vo.number = fc::to_uint64(s.substr( second_dot+1 )); - FC_ASSERT( vo.number <= GRAPHENE_DB_MAX_INSTANCE_ID ); + FC_ASSERT( second_dot != std::string::npos, "Missing the second dot" ); + FC_ASSERT( second_dot != first_dot+1, "Missing the type part" ); auto space_id = fc::to_uint64( s.substr( 0, first_dot ) ); - FC_ASSERT( space_id <= 0xff ); - auto type_id = fc::to_uint64( s.substr( first_dot+1, second_dot-first_dot-1 ) ); - FC_ASSERT( type_id <= 0xff ); - vo.number |= (space_id << 56) | (type_id << 48); + FC_ASSERT( space_id <= graphene::db::object_id_type::one_byte_mask, "space overflow" ); + auto type_id = fc::to_uint64( s.substr( first_dot+1, (second_dot-first_dot)-1 ) ); + FC_ASSERT( type_id <= graphene::db::object_id_type::one_byte_mask, "type overflow"); + auto instance = fc::to_uint64(s.substr( second_dot+1 )); + vo.reset( static_cast(space_id), static_cast(type_id), instance ); } FC_CAPTURE_AND_RETHROW( (var) ) } template void to_variant( const graphene::db::object_id& var, fc::variant& vo, uint32_t max_depth = 1 ) @@ -228,13 +251,17 @@ struct member_name, 0> { static constexpr const cha { try { const auto& s = var.get_string(); auto first_dot = s.find('.'); + FC_ASSERT( first_dot != std::string::npos, "Missing the first dot" ); + FC_ASSERT( first_dot != 0, "Missing the space part" ); auto second_dot = s.find('.',first_dot+1); - FC_ASSERT( first_dot != second_dot ); - FC_ASSERT( first_dot != 0 && first_dot != std::string::npos ); + FC_ASSERT( second_dot != std::string::npos, "Missing the second dot" ); + FC_ASSERT( second_dot != first_dot+1, "Missing the type part" ); FC_ASSERT( fc::to_uint64( s.substr( 0, first_dot ) ) == SpaceID && - fc::to_uint64( s.substr( first_dot+1, second_dot-first_dot-1 ) ) == TypeID, - "Space.Type.0 (${SpaceID}.${TypeID}.0) doesn't match expected value ${var}", ("TypeID",TypeID)("SpaceID",SpaceID)("var",var) ); - vo.instance = fc::to_uint64(s.substr( second_dot+1 )); + fc::to_uint64( s.substr( first_dot+1, (second_dot-first_dot)-1 ) ) == TypeID, + "Space.Type.0 (${SpaceID}.${TypeID}.0) doesn't match expected value ${var}", + ("TypeID",TypeID)("SpaceID",SpaceID)("var",var) ); + graphene::db::object_id tmp { fc::to_uint64(s.substr( second_dot+1 )) }; + vo = tmp; } FC_CAPTURE_AND_RETHROW( (var) ) } } // namespace fc diff --git a/libraries/protocol/include/graphene/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp index de1e4bce86..cc52d08bd7 100644 --- a/libraries/protocol/include/graphene/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -50,8 +50,9 @@ namespace graphene { namespace protocol { */ struct vote_id_type { - /// Lower 8 bits are type; upper 24 bits are instance - uint32_t content; + /// Lower 8 bits are type; upper 24 bits are instance. + /// By default type and instance are both set to 0. + uint32_t content = 0; friend size_t hash_value( vote_id_type v ) { return std::hash()(v.content); } enum vote_type @@ -62,10 +63,9 @@ struct vote_id_type VOTE_TYPE_COUNT }; - /// Default constructor. Sets type and instance to 0 - vote_id_type():content(0){} + vote_id_type() = default; /// Construct this vote_id_type with provided type and instance - vote_id_type(vote_type type, uint32_t instance = 0) + explicit vote_id_type(vote_type type, uint32_t instance = 0) : content(instance<<8 | type) {} /// Construct this vote_id_type from a serial string in the form "type:instance" diff --git a/libraries/wallet/CMakeLists.txt b/libraries/wallet/CMakeLists.txt index c268c362a7..09a72fc118 100644 --- a/libraries/wallet/CMakeLists.txt +++ b/libraries/wallet/CMakeLists.txt @@ -46,7 +46,8 @@ set( SOURCES ) add_library( graphene_wallet ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp ${HEADERS} ) -target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_net graphene_chain graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) +target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_chain graphene_utilities fc + ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) if(MSVC) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index f19a0ef4d9..1cd1b1976d 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -279,7 +279,7 @@ class wallet_api * @param htlc_id the id of the HTLC object. * @returns the information about the HTLC object */ - fc::optional get_htlc(string htlc_id) const; + fc::optional get_htlc(const htlc_id_type& htlc_id) const; /** Lookup the id of a named account. * @param account_name_or_id the name or ID of the account to look up @@ -1062,7 +1062,7 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction canceling the order */ - signed_transaction cancel_order(object_id_type order_id, bool broadcast = false); + signed_transaction cancel_order(const limit_order_id_type& order_id, bool broadcast = false) const; /** Creates a new user-issued or market-issued asset. * @@ -1477,9 +1477,10 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction * @return the signed transaction */ - signed_transaction htlc_create( string source, string destination, string amount, string asset_symbol_or_id, - string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, - const uint32_t claim_period_seconds, const std::string& memo, bool broadcast = false ); + signed_transaction htlc_create( const string& source, const string& destination, + const string& amount, const string& asset_symbol_or_id, const string& hash_algorithm, + const string& preimage_hash, uint32_t preimage_size, + uint32_t claim_period_seconds, const string& memo, bool broadcast = false) const; /**** * Update a hashed time lock contract @@ -1489,8 +1490,8 @@ class wallet_api * @param preimage the preimage that should evaluate to the preimage_hash * @return the signed transaction */ - signed_transaction htlc_redeem( string htlc_id, string issuer, const std::string& preimage, - bool broadcast = false ); + signed_transaction htlc_redeem( const htlc_id_type& htlc_id, const string& issuer, const std::string& preimage, + bool broadcast = false ) const; /***** * Increase the timelock on an existing HTLC @@ -1501,8 +1502,8 @@ class wallet_api * @param broadcast true to broadcast to the network * @return the signed transaction */ - signed_transaction htlc_extend(string htlc_id, string issuer, const uint32_t seconds_to_add, - bool broadcast = false); + signed_transaction htlc_extend( const htlc_id_type& htlc_id, const string& issuer, uint32_t seconds_to_add, + bool broadcast = false) const; /** * Get information about a vesting balance object or vesting balance objects owned by an account. diff --git a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp index 4c1a19fb7d..7d5b33dff9 100644 --- a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp @@ -166,7 +166,7 @@ struct wallet_data bool update_account(const account_object& acct) { auto& idx = my_accounts.get(); - auto itr = idx.find(acct.get_id()); + auto itr = idx.find(acct.id); if( itr != idx.end() ) { idx.replace(itr, acct); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 5ae5507406..0067bae1be 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -199,15 +199,16 @@ uint64_t wallet_api::get_asset_count()const return my->_remote_db->get_asset_count(); } -signed_transaction wallet_api::htlc_create( string source, string destination, string amount, string asset_symbol, - string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, - const uint32_t claim_period_seconds, const std::string& memo, bool broadcast) +signed_transaction wallet_api::htlc_create( const string& source, const string& destination, + const string& amount, const string& asset_symbol, const string& hash_algorithm, + const string& preimage_hash, uint32_t preimage_size, + uint32_t claim_period_seconds, const string& memo, bool broadcast ) const { return my->htlc_create(source, destination, amount, asset_symbol, hash_algorithm, preimage_hash, preimage_size, claim_period_seconds, memo, broadcast); } -fc::optional wallet_api::get_htlc(std::string htlc_id) const +fc::optional wallet_api::get_htlc(const htlc_id_type& htlc_id) const { fc::optional optional_obj = my->get_htlc(htlc_id); if ( optional_obj.valid() ) @@ -263,15 +264,15 @@ fc::optional wallet_api::get_htlc(std::string htlc_id) const return fc::optional(); } -signed_transaction wallet_api::htlc_redeem( std::string htlc_id, std::string issuer, const std::string& preimage, - bool broadcast) +signed_transaction wallet_api::htlc_redeem( const htlc_id_type& htlc_id, const string& issuer, + const string& preimage, bool broadcast ) const { return my->htlc_redeem(htlc_id, issuer, std::vector(preimage.begin(), preimage.end()), broadcast); } -signed_transaction wallet_api::htlc_extend ( std::string htlc_id, std::string issuer, const uint32_t seconds_to_add, - bool broadcast) +signed_transaction wallet_api::htlc_extend( const htlc_id_type& htlc_id, const string& issuer, + uint32_t seconds_to_add, bool broadcast ) const { return my->htlc_extend(htlc_id, issuer, seconds_to_add, broadcast); } @@ -1327,7 +1328,7 @@ signed_transaction wallet_api::borrow_asset_ext( string seller_name, string amou amount_of_collateral, extensions, broadcast); } -signed_transaction wallet_api::cancel_order(object_id_type order_id, bool broadcast) +signed_transaction wallet_api::cancel_order(const limit_order_id_type& order_id, bool broadcast) const { FC_ASSERT(!is_locked()); return my->cancel_order(order_id, broadcast); diff --git a/libraries/wallet/wallet_account.cpp b/libraries/wallet/wallet_account.cpp index cb1b782e72..4b8f123f20 100644 --- a/libraries/wallet/wallet_account.cpp +++ b/libraries/wallet/wallet_account.cpp @@ -35,14 +35,6 @@ namespace graphene { namespace wallet { namespace detail { - std::string wallet_api_impl::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; - } - signed_transaction wallet_api_impl::register_account(string name, public_key_type owner, public_key_type active, string registrar_account, string referrer_account, uint32_t referrer_percent, bool broadcast ) @@ -61,7 +53,7 @@ namespace graphene { namespace wallet { namespace detail { this->get_account( registrar_account ); FC_ASSERT( registrar_account_object.is_lifetime_member() ); - account_id_type registrar_account_id = registrar_account_object.id; + account_id_type registrar_account_id = registrar_account_object.get_id(); account_object referrer_account_object = this->get_account( referrer_account ); @@ -122,7 +114,7 @@ namespace graphene { namespace wallet { namespace detail { { FC_ASSERT( !self.is_locked() ); - account_id_type account_id = get_account(account).id; + account_id_type account_id = get_account(account).get_id(); custom_operation op; account_storage_map store; @@ -194,7 +186,7 @@ namespace graphene { namespace wallet { namespace detail { account_object wallet_api_impl::get_account(account_id_type id) const { - std::string account_id = account_id_to_string(id); + auto account_id = std::string(id); auto rec = _remote_db->get_accounts({account_id}, {}).front(); FC_ASSERT(rec); @@ -241,7 +233,7 @@ namespace graphene { namespace wallet { namespace detail { account_object registrar_account_object = get_account( registrar_account ); - account_id_type registrar_account_id = registrar_account_object.id; + account_id_type registrar_account_id = registrar_account_object.get_id(); account_object referrer_account_object = get_account( referrer_account ); account_create_op.referrer = referrer_account_object.id; @@ -329,7 +321,7 @@ namespace graphene { namespace wallet { namespace detail { { if( has_wildcard ) continue; - for( const public_key_type& pub : _wallet.extra_keys[ claimer.id ] ) + for( const public_key_type& pub : _wallet.extra_keys[ claimer.get_id() ] ) { addrs.push_back( address(pub) ); auto it = _keys.find( pub ); diff --git a/libraries/wallet/wallet_api_impl.cpp b/libraries/wallet/wallet_api_impl.cpp index c246e3b22a..6350ae3215 100644 --- a/libraries/wallet/wallet_api_impl.cpp +++ b/libraries/wallet/wallet_api_impl.cpp @@ -188,7 +188,7 @@ namespace graphene { namespace wallet { namespace detail { fc::async([this]{resync();}, "Resync after block"); } - void wallet_api_impl::set_operation_fees( signed_transaction& tx, const fee_schedule& s ) + void wallet_api_impl::set_operation_fees( signed_transaction& tx, const fee_schedule& s ) const { for( auto& op : tx.operations ) s.set_fee(op); @@ -341,7 +341,7 @@ namespace graphene { namespace wallet { namespace detail { for( const fc::optional& optional_account : owner_account_objects ) if (optional_account) { - std::string account_id = account_id_to_string(optional_account->id); + auto account_id = std::string(optional_account->id); fc::optional witness_obj = _remote_db->get_witness_by_account(account_id); if (witness_obj) claim_registered_witness(optional_account->name); @@ -386,7 +386,7 @@ namespace graphene { namespace wallet { namespace detail { { assert( it != _wallet.my_accounts.end() ); old_accounts.push_back( *it ); - std::string account_id = account_id_to_string(old_accounts.back().id); + auto account_id = std::string(old_accounts.back().id); account_ids_to_send.push_back( account_id ); ++it; } diff --git a/libraries/wallet/wallet_api_impl.hpp b/libraries/wallet/wallet_api_impl.hpp index 8964c9576e..e9e5810361 100644 --- a/libraries/wallet/wallet_api_impl.hpp +++ b/libraries/wallet/wallet_api_impl.hpp @@ -126,10 +126,10 @@ class wallet_api_impl bool is_locked()const; template - graphene::db::object_downcast_t get_object(ID id)const + graphene::db::object_downcast_t get_object(const ID& id)const { - auto ob = _remote_db->get_objects({id}, {}).front(); - return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); + auto ob = _remote_db->get_objects({object_id_type(id)}, {}).front(); + return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); } /*** @@ -137,7 +137,7 @@ class wallet_api_impl * @param tx the transaction * @param s the fee schedule */ - void set_operation_fees( signed_transaction& tx, const fee_schedule& s ); + void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) const; /*** * @brief return basic info about the chain @@ -167,7 +167,7 @@ class wallet_api_impl extended_asset_object get_asset(string asset_symbol_or_id)const; - fc::optional get_htlc(string htlc_id) const; + fc::optional get_htlc(const htlc_id_type& htlc_id) const; asset_id_type get_asset_id(const string& asset_symbol_or_id) const; @@ -297,14 +297,16 @@ class wallet_api_impl signed_transaction update_worker_votes( string account, worker_vote_delta delta, bool broadcast ); - signed_transaction htlc_create( string source, string destination, string amount, string asset_symbol, - string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, - const uint32_t claim_period_seconds, const std::string& memo, bool broadcast = false ); + signed_transaction htlc_create( const string& source, const string& destination, + const string& amount, const string& asset_symbol, const string& hash_algorithm, + const string& preimage_hash, uint32_t preimage_size, + uint32_t claim_period_seconds, const string& memo, bool broadcast = false); - signed_transaction htlc_redeem( string htlc_id, string issuer, const std::vector& preimage, - bool broadcast ); + signed_transaction htlc_redeem( const htlc_id_type& htlc_id, const string& issuer, + const std::vector& preimage, bool broadcast ); - signed_transaction htlc_extend ( string htlc_id, string issuer, const uint32_t seconds_to_add, bool broadcast); + signed_transaction htlc_extend( const htlc_id_type& htlc_id, const string& issuer, + uint32_t seconds_to_add, bool broadcast); signed_transaction account_store_map(string account, string catalog, bool remove, flat_map> key_values, bool broadcast); @@ -360,7 +362,7 @@ class wallet_api_impl string amount_of_collateral, call_order_update_operation::extensions_type extensions, bool broadcast = false); - signed_transaction cancel_order(limit_order_id_type order_id, bool broadcast = false); + signed_transaction cancel_order(const limit_order_id_type& order_id, bool broadcast = false); signed_transaction transfer(string from, string to, string amount, string asset_symbol, string memo, bool broadcast = false); @@ -423,8 +425,6 @@ class wallet_api_impl static_variant_map _operation_which_map = create_static_variant_map< operation >(); private: - std::string account_id_to_string(account_id_type id) const; - static htlc_hash do_hash( const string& algorithm, const std::string& hash ); void enable_umask_protection(); diff --git a/libraries/wallet/wallet_asset.cpp b/libraries/wallet/wallet_asset.cpp index 80bd89e2c1..d1d9046ec9 100644 --- a/libraries/wallet/wallet_asset.cpp +++ b/libraries/wallet/wallet_asset.cpp @@ -82,7 +82,7 @@ namespace graphene { namespace wallet { namespace detail { return fc::variant(asset_symbol_or_id, 1).as( 1 ); opt_asset = _remote_db->lookup_asset_symbols( {asset_symbol_or_id} ); FC_ASSERT( (opt_asset.size() > 0) && (opt_asset[0].valid()) ); - return opt_asset[0]->id; + return opt_asset[0]->get_id(); } signed_transaction wallet_api_impl::create_asset(string issuer, string symbol, diff --git a/libraries/wallet/wallet_sign.cpp b/libraries/wallet/wallet_sign.cpp index 7ce982e622..3b24a691c8 100644 --- a/libraries/wallet/wallet_sign.cpp +++ b/libraries/wallet/wallet_sign.cpp @@ -442,7 +442,7 @@ namespace graphene { namespace wallet { namespace detail { _wallet.update_account(account); - _wallet.extra_keys[account.id].insert(wif_pub_key); + _wallet.extra_keys[account.get_id()].insert(wif_pub_key); return all_keys_for_account.find(wif_pub_key) != all_keys_for_account.end(); } @@ -496,13 +496,13 @@ namespace graphene { namespace wallet { namespace detail { get_object( update_op.proposal ); for( const std::string& name : delta.active_approvals_to_add ) - update_op.active_approvals_to_add.insert( get_account( name ).id ); + update_op.active_approvals_to_add.insert( get_account( name ).get_id() ); for( const std::string& name : delta.active_approvals_to_remove ) - update_op.active_approvals_to_remove.insert( get_account( name ).id ); + update_op.active_approvals_to_remove.insert( get_account( name ).get_id() ); for( const std::string& name : delta.owner_approvals_to_add ) - update_op.owner_approvals_to_add.insert( get_account( name ).id ); + update_op.owner_approvals_to_add.insert( get_account( name ).get_id() ); for( const std::string& name : delta.owner_approvals_to_remove ) - update_op.owner_approvals_to_remove.insert( get_account( name ).id ); + update_op.owner_approvals_to_remove.insert( get_account( name ).get_id() ); for( const std::string& k : delta.key_approvals_to_add ) update_op.key_approvals_to_add.insert( public_key_type( k ) ); for( const std::string& k : delta.key_approvals_to_remove ) diff --git a/libraries/wallet/wallet_transfer.cpp b/libraries/wallet/wallet_transfer.cpp index 524764500e..a18890624c 100644 --- a/libraries/wallet/wallet_transfer.cpp +++ b/libraries/wallet/wallet_transfer.cpp @@ -57,8 +57,8 @@ namespace graphene { namespace wallet { namespace detail { account_object from_account = get_account(from); account_object to_account = get_account(to); - account_id_type from_id = from_account.id; - account_id_type to_id = to_account.id; + account_id_type from_id = from_account.get_id(); + account_id_type to_id = to_account.get_id(); transfer_operation xfer_op; @@ -83,9 +83,10 @@ namespace graphene { namespace wallet { namespace detail { return sign_transaction(tx, broadcast); } FC_CAPTURE_AND_RETHROW( (from)(to)(amount)(asset_symbol)(memo)(broadcast) ) } - signed_transaction wallet_api_impl::htlc_create( string source, string destination, string amount, - string asset_symbol, string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, - const uint32_t claim_period_seconds, const std::string& memo, bool broadcast ) + signed_transaction wallet_api_impl::htlc_create( const string& source, const string& destination, + const string& amount, const string& asset_symbol, const string& hash_algorithm, + const string& preimage_hash, uint32_t preimage_size, + uint32_t claim_period_seconds, const string& memo, bool broadcast ) { try { @@ -122,7 +123,7 @@ namespace graphene { namespace wallet { namespace detail { (preimage_hash)(preimage_size)(claim_period_seconds)(broadcast) ) } - signed_transaction wallet_api_impl::htlc_redeem( string htlc_id, string issuer, + signed_transaction wallet_api_impl::htlc_redeem( const htlc_id_type& htlc_id, const string& issuer, const std::vector& preimage, bool broadcast ) { try @@ -147,8 +148,8 @@ namespace graphene { namespace wallet { namespace detail { } FC_CAPTURE_AND_RETHROW( (htlc_id)(issuer)(preimage)(broadcast) ) } - signed_transaction wallet_api_impl::htlc_extend ( string htlc_id, string issuer, const uint32_t seconds_to_add, - bool broadcast) + signed_transaction wallet_api_impl::htlc_extend( const htlc_id_type& htlc_id, const string& issuer, + uint32_t seconds_to_add, bool broadcast ) { try { @@ -172,11 +173,9 @@ namespace graphene { namespace wallet { namespace detail { } FC_CAPTURE_AND_RETHROW( (htlc_id)(issuer)(seconds_to_add)(broadcast) ) } - fc::optional wallet_api_impl::get_htlc(string htlc_id) const + fc::optional wallet_api_impl::get_htlc(const htlc_id_type& htlc_id) const { - htlc_id_type id; - fc::from_variant(htlc_id, id); - auto obj = _remote_db->get_objects( { id }, {}).front(); + auto obj = _remote_db->get_objects( { object_id_type(htlc_id) }, {}).front(); if ( !obj.is_null() ) { return fc::optional(obj.template as(GRAPHENE_MAX_NESTED_OBJECTS)); @@ -236,7 +235,7 @@ namespace graphene { namespace wallet { namespace detail { return sign_transaction(trx, broadcast); } - signed_transaction wallet_api_impl::cancel_order(limit_order_id_type order_id, bool broadcast ) + signed_transaction wallet_api_impl::cancel_order(const limit_order_id_type& order_id, bool broadcast ) { try { FC_ASSERT(!is_locked()); signed_transaction trx; diff --git a/libraries/wallet/wallet_voting.cpp b/libraries/wallet/wallet_voting.cpp index 1dc911e22b..3d30af356f 100644 --- a/libraries/wallet/wallet_voting.cpp +++ b/libraries/wallet/wallet_voting.cpp @@ -70,7 +70,7 @@ namespace graphene { namespace wallet { namespace detail { vector< object_id_type > query_ids; for( const worker_id_type& wid : merged ) - query_ids.push_back( wid ); + query_ids.push_back( object_id_type(wid) ); flat_set new_votes( acct.options.votes ); @@ -78,15 +78,16 @@ namespace graphene { namespace wallet { namespace detail { for( const variant& obj : objects ) { worker_object wo; + worker_id_type wo_id { wo.id }; from_variant( obj, wo, GRAPHENE_MAX_NESTED_OBJECTS ); new_votes.erase( wo.vote_for ); new_votes.erase( wo.vote_against ); - if( delta.vote_for.find( wo.id ) != delta.vote_for.end() ) + if( delta.vote_for.find( wo_id ) != delta.vote_for.end() ) new_votes.insert( wo.vote_for ); - else if( delta.vote_against.find( wo.id ) != delta.vote_against.end() ) + else if( delta.vote_against.find( wo_id ) != delta.vote_against.end() ) new_votes.insert( wo.vote_against ); else - assert( delta.vote_abstain.find( wo.id ) != delta.vote_abstain.end() ); + assert( delta.vote_abstain.find( wo_id ) != delta.vote_abstain.end() ); } account_update_operation update_op; @@ -139,7 +140,7 @@ namespace graphene { namespace wallet { namespace detail { // then maybe it's the owner account try { - std::string owner_account_id = account_id_to_string(get_account_id(owner_account)); + auto owner_account_id = std::string(get_account_id(owner_account)); fc::optional witness = _remote_db->get_witness_by_account(owner_account_id); if (witness) return *witness; @@ -207,7 +208,7 @@ namespace graphene { namespace wallet { namespace detail { witness_create_op.block_signing_key = witness_public_key; witness_create_op.url = url; - if (_remote_db->get_witness_by_account(account_id_to_string(witness_create_op.witness_account))) + if (_remote_db->get_witness_by_account(std::string(witness_create_op.witness_account))) FC_THROW("Account ${owner_account} is already a witness", ("owner_account", owner_account)); signed_transaction tx; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 44069f2560..c3ca602fe1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,7 +5,7 @@ add_library( database_fixture ${COMMON_SOURCES} ${COMMON_HEADERS} ) -target_link_libraries( database_fixture PUBLIC graphene_app graphene_es_objects graphene_egenesis_none ) +target_link_libraries( database_fixture PUBLIC graphene_es_objects graphene_app graphene_egenesis_none ) target_include_directories( database_fixture PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/common" ) @@ -17,8 +17,8 @@ endif() file(GLOB UNIT_TESTS "tests/*.cpp") add_executable( chain_test ${UNIT_TESTS} ) -target_link_libraries( chain_test graphene_app database_fixture - graphene_witness graphene_wallet ${PLATFORM_SPECIFIC_LIBS} ) +target_link_libraries( chain_test database_fixture + graphene_witness graphene_wallet graphene_app ${PLATFORM_SPECIFIC_LIBS} ) if(MSVC) set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) set_source_files_properties( tests/common/database_fixture.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) @@ -30,7 +30,7 @@ target_link_libraries( performance_test database_fixture ${PLATFORM_SPECIFIC_LIB file(GLOB APP_SOURCES "app/*.cpp") add_executable( app_test ${APP_SOURCES} ) -target_link_libraries( app_test graphene_app graphene_witness graphene_egenesis_none +target_link_libraries( app_test graphene_app graphene_egenesis_none ${PLATFORM_SPECIFIC_LIBS} ) file(GLOB CLI_SOURCES "cli/*.cpp") @@ -38,7 +38,7 @@ add_executable( cli_test ${CLI_SOURCES} ) if(WIN32) list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32) endif() -target_link_libraries( cli_test graphene_app graphene_wallet graphene_witness graphene_egenesis_none +target_link_libraries( cli_test graphene_wallet graphene_app graphene_egenesis_none ${PLATFORM_SPECIFIC_LIBS} ) if(MSVC) set_source_files_properties( cli/main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) diff --git a/tests/app/main.cpp b/tests/app/main.cpp index f5e937250f..ade829b11d 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -22,18 +22,12 @@ * THE SOFTWARE. */ #include -#include #include #include #include -#include -#include -#include -#include - #include #include #include @@ -240,10 +234,6 @@ BOOST_AUTO_TEST_CASE( three_node_network ) auto genesis_file = create_genesis_file(app_dir); graphene::app::application app1; - app1.register_plugin< graphene::account_history::account_history_plugin>(); - app1.register_plugin< graphene::market_history::market_history_plugin >(); - app1.register_plugin< graphene::witness_plugin::witness_plugin >(); - app1.register_plugin< graphene::grouped_orders::grouped_orders_plugin>(); auto sharable_cfg = std::make_shared(); auto& cfg = *sharable_cfg; fc::set_option( cfg, "p2p-endpoint", app1_p2p_endpoint_str ); @@ -265,10 +255,6 @@ BOOST_AUTO_TEST_CASE( three_node_network ) fc::temp_directory app2_dir( graphene::utilities::temp_directory_path() ); graphene::app::application app2; - app2.register_plugin(); - app2.register_plugin< graphene::market_history::market_history_plugin >(); - app2.register_plugin< graphene::witness_plugin::witness_plugin >(); - app2.register_plugin< graphene::grouped_orders::grouped_orders_plugin>(); auto sharable_cfg2 = std::make_shared(); auto& cfg2 = *sharable_cfg2; fc::set_option( cfg2, "genesis-json", genesis_file ); @@ -306,7 +292,8 @@ BOOST_AUTO_TEST_CASE( three_node_network ) BOOST_TEST_MESSAGE( "Creating transfer tx" ); graphene::chain::precomputable_transaction trx; { - account_id_type nathan_id = db2->get_index_type().indices().get().find( "nathan" )->id; + account_id_type nathan_id = db2->get_index_type().indices().get().find( "nathan" ) + ->get_id(); fc::ecc::private_key nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); balance_claim_operation claim_op; diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 7e22d184d0..41b3b632c8 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -665,7 +665,7 @@ BOOST_FIXTURE_TEST_CASE( mpa_tests, cli_fixture ) { // Play with asset fee pool - auto objs = con.wallet_api_ptr->get_object( bobcoin.dynamic_asset_data_id ) + auto objs = con.wallet_api_ptr->get_object( object_id_type( bobcoin.dynamic_asset_data_id ) ) .as>( FC_PACK_MAX_DEPTH ); idump( (objs) ); BOOST_REQUIRE_EQUAL( objs.size(), 1u ); @@ -675,7 +675,7 @@ BOOST_FIXTURE_TEST_CASE( mpa_tests, cli_fixture ) BOOST_TEST_MESSAGE("Fund fee pool"); con.wallet_api_ptr->fund_asset_fee_pool("nathan", "BOBCOIN", "2", true); - objs = con.wallet_api_ptr->get_object( bobcoin.dynamic_asset_data_id ) + objs = con.wallet_api_ptr->get_object( object_id_type( bobcoin.dynamic_asset_data_id ) ) .as>( FC_PACK_MAX_DEPTH ); BOOST_REQUIRE_EQUAL( objs.size(), 1u ); bobcoin_dyn = objs[0]; @@ -687,7 +687,7 @@ BOOST_FIXTURE_TEST_CASE( mpa_tests, cli_fixture ) BOOST_TEST_MESSAGE("Claim fee pool"); con.wallet_api_ptr->claim_asset_fee_pool("BOBCOIN", "1", true); - objs = con.wallet_api_ptr->get_object( bobcoin.dynamic_asset_data_id ) + objs = con.wallet_api_ptr->get_object( object_id_type( bobcoin.dynamic_asset_data_id ) ) .as>( FC_PACK_MAX_DEPTH ); BOOST_REQUIRE_EQUAL( objs.size(), 1u ); bobcoin_dyn = objs[0]; @@ -708,7 +708,7 @@ BOOST_FIXTURE_TEST_CASE( mpa_tests, cli_fixture ) asset_update_feed_producers_operation aufp_op; aufp_op.issuer = nathan_acct.id; aufp_op.asset_to_update = bobcoin.id; - aufp_op.new_feed_producers = { nathan_acct.id }; + aufp_op.new_feed_producers = { nathan_acct.get_id() }; con.wallet_api_ptr->add_operation_to_builder_transaction( handle, aufp_op ); con.wallet_api_ptr->set_fees_on_builder_transaction( handle, "1.3.0" ); con.wallet_api_ptr->sign_builder_transaction( handle, true ); @@ -725,8 +725,8 @@ BOOST_FIXTURE_TEST_CASE( mpa_tests, cli_fixture ) // Publish price feed BOOST_TEST_MESSAGE("Publish price feed"); price_feed feed; - feed.settlement_price = price( asset(1,bobcoin.id), asset(2) ); - feed.core_exchange_rate = price( asset(1,bobcoin.id), asset(1) ); + feed.settlement_price = price( asset(1,bobcoin.get_id()), asset(2) ); + feed.core_exchange_rate = price( asset(1,bobcoin.get_id()), asset(1) ); con.wallet_api_ptr->publish_asset_feed( "nathan", "BOBCOIN", feed, true ); asset_bitasset_data_object bob_bitasset = con.wallet_api_ptr->get_bitasset_data( "BOBCOIN" ); BOOST_CHECK( bob_bitasset.current_feed.settlement_price == feed.settlement_price ); @@ -815,7 +815,7 @@ BOOST_FIXTURE_TEST_CASE( mpa_tests, cli_fixture ) orders = con.wallet_api_ptr->get_limit_orders( "BOBCOIN", "1.3.0", 10 ); BOOST_REQUIRE_EQUAL( orders.size(), 1u ); BOOST_CHECK_EQUAL( orders.front().for_sale.value, 100 * GRAPHENE_BLOCKCHAIN_PRECISION ); - limit_order_id_type nathan_order_id = orders.front().id; + limit_order_id_type nathan_order_id = orders.front().get_id(); BOOST_CHECK(generate_block(app1)); check_nathan_bobcoin_balance( 3000 ); @@ -944,7 +944,7 @@ BOOST_FIXTURE_TEST_CASE( cli_get_signed_transaction_signers, cli_fixture ) const auto &test_acc = con.wallet_api_ptr->get_account("test"); flat_set expected_signers = {test_bki.pub_key}; - vector > expected_key_refs{{test_acc.id, test_acc.id}}; + vector > expected_key_refs{{test_acc.get_id(), test_acc.get_id()}}; auto signers = con.wallet_api_ptr->get_transaction_signers(signed_trx); BOOST_CHECK(signers == expected_signers); @@ -1116,7 +1116,7 @@ BOOST_FIXTURE_TEST_CASE( cli_get_available_transaction_signers, cli_fixture ) vector > expected_key_refs; expected_key_refs.push_back(flat_set()); expected_key_refs.push_back(flat_set()); - expected_key_refs.push_back({test_acc.id}); + expected_key_refs.push_back({test_acc.get_id()}); auto key_refs = con.wallet_api_ptr->get_key_references({expected_signers.begin(), expected_signers.end()}); std::sort(key_refs.begin(), key_refs.end()); @@ -1650,6 +1650,7 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc ) // normally, a wallet would watch block production, and find the transaction. Here, we can cheat: std::string alice_htlc_id_as_string; + htlc_id_type alice_htlc_id; { BOOST_TEST_MESSAGE("The system is generating a block"); graphene::chain::signed_block result_block; @@ -1657,14 +1658,15 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc ) // get the ID: auto tmp_hist = con.wallet_api_ptr->get_account_history("alice", 1); - htlc_id_type htlc_id = tmp_hist[0].op.result.get(); + htlc_id_type htlc_id { tmp_hist[0].op.result.get() }; + alice_htlc_id = htlc_id; alice_htlc_id_as_string = (std::string)(object_id_type)htlc_id; BOOST_TEST_MESSAGE("Alice shares the HTLC ID with Bob. The HTLC ID is: " + alice_htlc_id_as_string); } // Bob can now look over Alice's HTLC, to see if it is what was agreed to. BOOST_TEST_MESSAGE("Bob retrieves the HTLC Object by ID to examine it."); - auto alice_htlc = con.wallet_api_ptr->get_htlc(alice_htlc_id_as_string); + auto alice_htlc = con.wallet_api_ptr->get_htlc(alice_htlc_id); BOOST_TEST_MESSAGE("The HTLC Object is: " + fc::json::to_pretty_string(alice_htlc)); // Bob likes what he sees, so he creates an HTLC, using the info he retrieved from Alice's HTLC @@ -1673,6 +1675,7 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc ) // normally, a wallet would watch block production, and find the transaction. Here, we can cheat: std::string bob_htlc_id_as_string; + htlc_id_type bob_htlc_id; { BOOST_TEST_MESSAGE("The system is generating a block"); graphene::chain::signed_block result_block; @@ -1680,21 +1683,22 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc ) // get the ID: auto tmp_hist = con.wallet_api_ptr->get_account_history("bob", 1); - htlc_id_type htlc_id = tmp_hist[0].op.result.get(); + htlc_id_type htlc_id { tmp_hist[0].op.result.get() }; + bob_htlc_id = htlc_id; bob_htlc_id_as_string = (std::string)(object_id_type)htlc_id; BOOST_TEST_MESSAGE("Bob shares the HTLC ID with Alice. The HTLC ID is: " + bob_htlc_id_as_string); } // Alice can now look over Bob's HTLC, to see if it is what was agreed to: BOOST_TEST_MESSAGE("Alice retrieves the HTLC Object by ID to examine it."); - auto bob_htlc = con.wallet_api_ptr->get_htlc(bob_htlc_id_as_string); + auto bob_htlc = con.wallet_api_ptr->get_htlc(bob_htlc_id); BOOST_TEST_MESSAGE("The HTLC Object is: " + fc::json::to_pretty_string(bob_htlc)); // Alice likes what she sees, so uses her preimage to get her BOBCOIN { BOOST_TEST_MESSAGE("Alice uses her preimage to retrieve the BOBCOIN"); std::string secret = "My Secret"; - con.wallet_api_ptr->htlc_redeem(bob_htlc_id_as_string, "alice", secret, true); + con.wallet_api_ptr->htlc_redeem(bob_htlc_id, "alice", secret, true); BOOST_TEST_MESSAGE("The system is generating a block"); BOOST_CHECK(generate_block(app1)); } @@ -1704,7 +1708,7 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc ) { BOOST_TEST_MESSAGE("Bob uses Alice's preimage to retrieve the BOBCOIN"); std::string secret = "My Secret"; - con.wallet_api_ptr->htlc_redeem(alice_htlc_id_as_string, "bob", secret, true); + con.wallet_api_ptr->htlc_redeem(alice_htlc_id, "bob", secret, true); BOOST_TEST_MESSAGE("The system is generating a block"); BOOST_CHECK(generate_block(app1)); } @@ -2197,6 +2201,7 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc_bsip64 ) // normally, a wallet would watch block production, and find the transaction. Here, we can cheat: std::string alice_htlc_id_as_string; + htlc_id_type alice_htlc_id; { BOOST_TEST_MESSAGE("The system is generating a block"); graphene::chain::signed_block result_block; @@ -2204,14 +2209,15 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc_bsip64 ) // get the ID: auto tmp_hist = con.wallet_api_ptr->get_account_history("alice", 1); - htlc_id_type htlc_id = tmp_hist[0].op.result.get(); + htlc_id_type htlc_id { tmp_hist[0].op.result.get() }; + alice_htlc_id = htlc_id; alice_htlc_id_as_string = (std::string)(object_id_type)htlc_id; BOOST_TEST_MESSAGE("Alice shares the HTLC ID with Bob. The HTLC ID is: " + alice_htlc_id_as_string); } // Bob can now look over Alice's HTLC, to see if it is what was agreed to. BOOST_TEST_MESSAGE("Bob retrieves the HTLC Object by ID to examine it."); - auto alice_htlc = con.wallet_api_ptr->get_htlc(alice_htlc_id_as_string); + auto alice_htlc = con.wallet_api_ptr->get_htlc(alice_htlc_id); BOOST_TEST_MESSAGE("The HTLC Object is: " + fc::json::to_pretty_string(alice_htlc)); // Bob likes what he sees, so he creates an HTLC, using the info he retrieved from Alice's HTLC @@ -2221,6 +2227,7 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc_bsip64 ) // normally, a wallet would watch block production, and find the transaction. Here, we can cheat: std::string bob_htlc_id_as_string; + htlc_id_type bob_htlc_id; { BOOST_TEST_MESSAGE("The system is generating a block"); graphene::chain::signed_block result_block; @@ -2228,20 +2235,21 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc_bsip64 ) // get the ID: auto tmp_hist = con.wallet_api_ptr->get_account_history("bob", 1); - htlc_id_type htlc_id = tmp_hist[0].op.result.get(); + htlc_id_type htlc_id { tmp_hist[0].op.result.get() }; + bob_htlc_id = htlc_id; bob_htlc_id_as_string = (std::string)(object_id_type)htlc_id; BOOST_TEST_MESSAGE("Bob shares the HTLC ID with Alice. The HTLC ID is: " + bob_htlc_id_as_string); } // Alice can now look over Bob's HTLC, to see if it is what was agreed to: BOOST_TEST_MESSAGE("Alice retrieves the HTLC Object by ID to examine it."); - auto bob_htlc = con.wallet_api_ptr->get_htlc(bob_htlc_id_as_string); + auto bob_htlc = con.wallet_api_ptr->get_htlc(bob_htlc_id); BOOST_TEST_MESSAGE("The HTLC Object is: " + fc::json::to_pretty_string(bob_htlc)); // Alice likes what she sees, so uses her preimage to get her BOBCOIN { BOOST_TEST_MESSAGE("Alice uses her preimage to retrieve the BOBCOIN"); - con.wallet_api_ptr->htlc_redeem(bob_htlc_id_as_string, "alice", preimage_string, true); + con.wallet_api_ptr->htlc_redeem(bob_htlc_id, "alice", preimage_string, true); BOOST_TEST_MESSAGE("The system is generating a block"); BOOST_CHECK(generate_block(app1)); } @@ -2263,7 +2271,7 @@ BOOST_AUTO_TEST_CASE( cli_create_htlc_bsip64 ) // Bob can use the preimage to retrieve his BTS { BOOST_TEST_MESSAGE("Bob uses Alice's preimage to retrieve the BOBCOIN"); - con.wallet_api_ptr->htlc_redeem(alice_htlc_id_as_string, "bob", preimage_string, true); + con.wallet_api_ptr->htlc_redeem(alice_htlc_id, "bob", preimage_string, true); BOOST_TEST_MESSAGE("The system is generating a block"); BOOST_CHECK(generate_block(app1)); } diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index fb0e11bde6..a863964479 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -595,7 +595,7 @@ void database_fixture_base::verify_asset_supplies( const database& db ) for( const asset_object& asset_obj : db.get_index_type().indices() ) { const auto& dasset_obj = asset_obj.dynamic_asset_data_id(db); - total_balances[asset_obj.id] += dasset_obj.accumulated_fees; + total_balances[asset_obj.get_id()] += dasset_obj.accumulated_fees; total_balances[asset_id_type()] += dasset_obj.fee_pool; if( asset_obj.is_market_issued() ) { @@ -606,7 +606,7 @@ void database_fixture_base::verify_asset_supplies( const database& db ) if( !bad.has_settlement() ) // Note: if asset has been globally settled, do not check total debt total_debts[bad.asset_id] += bad.individual_settlement_debt; } - total_balances[asset_obj.id] += dasset_obj.confidential_supply.value; + total_balances[asset_obj.get_id()] += dasset_obj.confidential_supply.value; } for( const vesting_balance_object& vbo : db.get_index_type< vesting_balance_index >().indices() ) total_balances[ vbo.balance.asset_id ] += vbo.balance.amount; @@ -686,7 +686,8 @@ void database_fixture_base::verify_asset_supplies( const database& db ) for( const asset_object& asset_obj : db.get_index_type().indices() ) { - BOOST_CHECK_EQUAL(total_balances[asset_obj.id].value, asset_obj.dynamic_asset_data_id(db).current_supply.value); + BOOST_CHECK_EQUAL( total_balances[asset_obj.get_id()].value, + asset_obj.dynamic_asset_data_id(db).current_supply.value ); } BOOST_CHECK_EQUAL( core_in_orders.value , reported_core_in_orders.value ); @@ -1360,7 +1361,7 @@ const call_order_object* database_fixture_base::borrow( const account_object& wh verify_asset_supplies(db); auto& call_idx = db.get_index_type().indices().get(); - auto itr = call_idx.find( boost::make_tuple(who.id, what.asset_id) ); + auto itr = call_idx.find( boost::make_tuple(who.get_id(), what.asset_id) ); const call_order_object* call_obj = nullptr; if( itr != call_idx.end() ) @@ -2225,7 +2226,7 @@ void database_fixture_base::set_htlc_committee_parameters() trx.operations.push_back(cop); graphene::chain::processed_transaction proc_trx = db.push_transaction(trx); trx.clear(); - proposal_id_type good_proposal_id = proc_trx.operation_results[0].get(); + proposal_id_type good_proposal_id { proc_trx.operation_results[0].get() }; proposal_update_operation puo; puo.proposal = good_proposal_id; diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index bf88a7bc83..340031b38e 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -172,12 +172,12 @@ extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; #define ACTOR(name) \ PREP_ACTOR(name) \ const auto name = create_account(BOOST_PP_STRINGIZE(name), name ## _public_key); \ - graphene::chain::account_id_type name ## _id = name.id; (void)name ## _id; + graphene::chain::account_id_type name ## _id = name.get_id(); (void)name ## _id; #define GET_ACTOR(name) \ fc::ecc::private_key name ## _private_key = generate_private_key(BOOST_PP_STRINGIZE(name)); \ const account_object& name = get_account(BOOST_PP_STRINGIZE(name)); \ - graphene::chain::account_id_type name ## _id = name.id; \ + graphene::chain::account_id_type name ## _id = name.get_id(); \ (void)name ##_id #define ACTORS_IMPL(r, data, elem) ACTOR(elem) diff --git a/tests/elasticsearch/main.cpp b/tests/elasticsearch/main.cpp index 94e64233a2..6fb4fbb266 100644 --- a/tests/elasticsearch/main.cpp +++ b/tests/elasticsearch/main.cpp @@ -144,12 +144,12 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( sam, eur.amount(init_amount) ); issue_uia( ted, eur.amount(init_amount) ); @@ -158,8 +158,8 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { flat_map collateral_map; collateral_map[usd_id] = price( asset(1), asset(1, usd_id) ); - credit_offer_create_operation cop = make_credit_offer_create_op( sam_id, core.id, 10000, 100, 3600, 0, - false, db.head_block_time() + fc::days(1), collateral_map, {} ); + credit_offer_create_operation cop = make_credit_offer_create_op( sam_id, core.get_id(), 10000, 100, 3600, + 0, false, db.head_block_time() + fc::days(1), collateral_map, {} ); propose( cop ); } @@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { flat_map collateral_map1; collateral_map1[usd_id] = price( asset(1), asset(2, usd_id) ); - const credit_offer_object& coo1 = create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + const credit_offer_object& coo1 = create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, collateral_map1, {} ); BOOST_CHECK( coo1.owner_account == sam_id ); @@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) { if(delete_objects) { // all records deleted // asset and bitasset - asset_id_type usd_id = create_bitasset("USD", account_id_type()).id; + asset_id_type usd_id = create_bitasset("USD", account_id_type()).get_id(); generate_block(); string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }"; @@ -382,11 +382,11 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) { create_bitasset("USD", account_id_type()); // create op 0 const account_object& dan = create_account("dan"); // create op 1 - create_bitasset("CNY", dan.id); // create op 2 + create_bitasset("CNY", dan.get_id()); // create op 2 create_bitasset("BTC", account_id_type()); // create op 3 - create_bitasset("XMR", dan.id); // create op 4 + create_bitasset("XMR", dan.get_id()); // create op 4 create_bitasset("EUR", account_id_type()); // create op 5 - create_bitasset("OIL", dan.id); // create op 6 + create_bitasset("OIL", dan.get_id()); // create op 6 generate_block(); diff --git a/tests/tests/api_limit_tests.cpp b/tests/tests/api_limit_tests.cpp index 3dd518cf9c..40baf71808 100644 --- a/tests/tests/api_limit_tests.cpp +++ b/tests/tests/api_limit_tests.cpp @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE( api_limit_get_limit_orders ){ create_bitasset("USD", account_id_type()); create_account("dan"); create_account("bob"); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").get_id(); generate_block(); fc::usleep(fc::milliseconds(100)); GRAPHENE_CHECK_THROW(db_api.get_limit_orders(std::string(static_cast(asset_id_type())), @@ -176,10 +176,10 @@ BOOST_AUTO_TEST_CASE( api_limit_get_call_orders ){ graphene::app::database_api db_api( db, &( app.get_options() )); //account_id_type() do 3 ops auto nathan_private_key = generate_private_key("nathan"); - account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).get_id(); transfer(account_id_type(), nathan_id, asset(100)); asset_id_type bitusd_id = create_bitasset( - "USDBIT", nathan_id, 100, disable_force_settle).id; + "USDBIT", nathan_id, 100, disable_force_settle).get_id(); generate_block(); fc::usleep(fc::milliseconds(100)); BOOST_CHECK( bitusd_id(db).is_market_issued() ); @@ -198,10 +198,10 @@ BOOST_AUTO_TEST_CASE( api_limit_get_settle_orders ){ graphene::app::database_api db_api( db, &( app.get_options() )); //account_id_type() do 3 ops auto nathan_private_key = generate_private_key("nathan"); - account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).get_id(); transfer(account_id_type(), nathan_id, asset(100)); asset_id_type bitusd_id = create_bitasset( - "USDBIT", nathan_id, 100, disable_force_settle).id; + "USDBIT", nathan_id, 100, disable_force_settle).get_id(); generate_block(); fc::usleep(fc::milliseconds(100)); GRAPHENE_CHECK_THROW(db_api.get_settle_orders( @@ -219,12 +219,12 @@ BOOST_AUTO_TEST_CASE( api_limit_get_order_book ){ graphene::app::database_api db_api( db, &( app.get_options() )); auto nathan_private_key = generate_private_key("nathan"); auto dan_private_key = generate_private_key("dan"); - account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; - account_id_type dan_id = create_account("dan", dan_private_key.get_public_key()).id; + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).get_id(); + account_id_type dan_id = create_account("dan", dan_private_key.get_public_key()).get_id(); transfer(account_id_type(), nathan_id, asset(100)); transfer(account_id_type(), dan_id, asset(100)); - asset_id_type bitusd_id = create_user_issued_asset( "USDBIT", nathan_id(db), charge_market_fee).id; - asset_id_type bitdan_id = create_user_issued_asset( "DANBIT", dan_id(db), charge_market_fee).id; + asset_id_type bitusd_id = create_user_issued_asset( "USDBIT", nathan_id(db), charge_market_fee).get_id(); + asset_id_type bitdan_id = create_user_issued_asset( "DANBIT", dan_id(db), charge_market_fee).get_id(); issue_uia( nathan_id, asset(100, bitusd_id) ); issue_uia( dan_id, asset(100, bitdan_id) ); create_sell_order( nathan_id, asset(100, bitusd_id), asset(10000, bitdan_id) ); @@ -450,7 +450,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_collateral_bids) { for (int i=0; i<3; i++) { std::string acct_name = "mytempacct" + std::to_string(i); - account_id_type account_id=create_account(acct_name).id; + account_id_type account_id=create_account(acct_name).get_id(); transfer(committee_account, account_id, asset(init_balance)); bid_collateral(account_id(db), back(db).amount(10), swan(db).amount(1)); } @@ -476,7 +476,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_collateral_bids) { //limit= api_limit for (int i=3; i<255; i++) { std::string acct_name = "mytempacct" + std::to_string(i); - account_id_type account_id=create_account(acct_name).id; + account_id_type account_id=create_account(acct_name).get_id(); transfer(committee_account, account_id, asset(init_balance)); bid_collateral(account_id(db), back(db).amount(10), swan(db).amount(1)); } diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index f991559e03..8b4856fd9a 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account ) pup.proposal = proposal.id; pup.fee_paying_account = nathan.id; BOOST_TEST_MESSAGE( "Updating the proposal to have nathan's authority" ); - pup.active_approvals_to_add.insert(nathan.id); + pup.active_approvals_to_add.insert(nathan.get_id()); trx.operations = {pup}; sign( trx, committee_key ); @@ -373,7 +373,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account ) trx.clear_signatures(); pup.active_approvals_to_add.clear(); - pup.active_approvals_to_add.insert(nathan.id); + pup.active_approvals_to_add.insert(nathan.get_id()); trx.operations = {pup}; sign( trx, nathan_key3 ); @@ -565,7 +565,7 @@ BOOST_FIXTURE_TEST_CASE( fired_committee_members, database_fixture ) pop.proposed_ops.emplace_back(top); trx.operations.push_back(pop); const proposal_object& prop = db.get(PUSH_TX( db, trx ).operation_results.front().get()); - proposal_id_type pid = prop.id; + proposal_id_type pid = prop.get_id(); BOOST_CHECK(!pid(db).is_authorized_to_execute(db)); ilog( "commitee member approves proposal" ); @@ -665,7 +665,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture ) BOOST_CHECK(!prop.is_authorized_to_execute(db)); { - proposal_id_type pid = prop.id; + proposal_id_type pid = prop.get_id(); proposal_update_operation uop; uop.proposal = prop.id; uop.active_approvals_to_add.insert(nathan.get_id()); @@ -675,7 +675,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture ) PUSH_TX( db, trx ); trx.clear(); - BOOST_CHECK(db.find_object(pid) != nullptr); + BOOST_CHECK(db.find(pid) != nullptr); BOOST_CHECK(!prop.is_authorized_to_execute(db)); uop.active_approvals_to_add = {dan.get_id()}; @@ -685,7 +685,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture ) sign( trx, dan_key ); PUSH_TX( db, trx ); - BOOST_CHECK(db.find_object(pid) == nullptr); + BOOST_CHECK(db.find(pid) == nullptr); } } FC_LOG_AND_RETHROW() } @@ -748,14 +748,14 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture ) } { - proposal_id_type pid = prop.id; + proposal_id_type pid = prop.get_id(); proposal_delete_operation dop; dop.fee_paying_account = nathan.get_id(); dop.proposal = pid; trx.operations.push_back(dop); sign( trx, nathan_key ); PUSH_TX( db, trx ); - BOOST_CHECK(db.find_object(pid) == nullptr); + BOOST_CHECK(db.find(pid) == nullptr); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000); } } FC_LOG_AND_RETHROW() } @@ -824,7 +824,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture ) } { - proposal_id_type pid = prop.id; + proposal_id_type pid = prop.get_id(); proposal_delete_operation dop; dop.fee_paying_account = nathan.get_id(); dop.proposal = pid; @@ -832,7 +832,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture ) trx.operations.push_back(dop); sign( trx, nathan_key ); PUSH_TX( db, trx ); - BOOST_CHECK(db.find_object(pid) == nullptr); + BOOST_CHECK(db.find(pid) == nullptr); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000); } } FC_LOG_AND_RETHROW() } @@ -880,7 +880,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) BOOST_CHECK(!prop.is_authorized_to_execute(db)); { - proposal_id_type pid = prop.id; + proposal_id_type pid = prop.get_id(); proposal_update_operation uop; uop.fee_paying_account = nathan.get_id(); uop.proposal = prop.id; @@ -921,7 +921,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture ) sign( trx, nathan_key ); PUSH_TX( db, trx ); trx.clear(); - BOOST_CHECK(db.find_object(pid) == nullptr); + BOOST_CHECK(db.find(pid) == nullptr); } } FC_LOG_AND_RETHROW() } @@ -1088,8 +1088,8 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture ) ACTORS((nathan)(vikram)); upgrade_to_lifetime_member(nathan_id); upgrade_to_lifetime_member(vikram_id); - committee_member_id_type nathan_committee_member = create_committee_member(nathan_id(db)).id; - committee_member_id_type vikram_committee_member = create_committee_member(vikram_id(db)).id; + committee_member_id_type nathan_committee_member = create_committee_member(nathan_id(db)).get_id(); + committee_member_id_type vikram_committee_member = create_committee_member(vikram_id(db)).get_id(); //wdump((db.get_balance(account_id_type(), asset_id_type()))); generate_block(); @@ -1665,7 +1665,8 @@ BOOST_FIXTURE_TEST_CASE( parent_owner_test, database_fixture ) set_expiration( db, ptx ); sign( ptx, bob_active_key ); - return PUSH_TX( db, ptx, database::skip_transaction_dupe_check ).operation_results[0].get(); + return proposal_id_type { PUSH_TX( db, ptx, database::skip_transaction_dupe_check ).operation_results[0] + .get() }; }; auto approve_proposal = [&]( @@ -1908,7 +1909,7 @@ BOOST_AUTO_TEST_CASE( custom_operation_required_auths_before_fork ) { trx.operations = {pcop}; trx.signatures.clear(); sign(trx, alice_private_key); - proposal_id_type pid = db.push_transaction(trx).operation_results[0].get(); + proposal_id_type pid { db.push_transaction(trx).operation_results[0].get() }; // Check bob is not listed as a required approver BOOST_REQUIRE_EQUAL(pid(db).required_active_approvals.count(bob_id), 0); @@ -1965,7 +1966,7 @@ BOOST_AUTO_TEST_CASE( custom_operation_required_auths_after_fork ) { trx.operations = {pcop}; trx.signatures.clear(); sign(trx, alice_private_key); - proposal_id_type pid = db.push_transaction(trx).operation_results[0].get(); + proposal_id_type pid { db.push_transaction(trx).operation_results[0].get() }; // Check bob is listed as a required approver BOOST_REQUIRE_EQUAL(pid(db).required_active_approvals.count(bob_id), 1); @@ -2198,7 +2199,7 @@ BOOST_AUTO_TEST_CASE( nested_execution ) pup.active_approvals_to_add.insert( alice_id ); pco.proposed_ops.emplace_back( pup ); trx.operations.push_back( pco ); - nested.push_back( PUSH_TX( db, trx, ~0 ).operation_results.front().get() ); + nested.push_back( proposal_id_type { PUSH_TX( db, trx, ~0 ).operation_results.front().get() } ); trx.clear(); pco.proposed_ops.clear(); } @@ -2211,8 +2212,8 @@ BOOST_AUTO_TEST_CASE( nested_execution ) PUSH_TX( db, trx, ~0 ); for( size_t i = 1; i < nested.size(); i++ ) - BOOST_CHECK_THROW( db.get( nested[i] ), fc::assert_exception ); // executed successfully -> object removed - db.get( inner ); // wasn't executed -> object exists, doesn't throw + BOOST_CHECK_THROW( db.get( nested[i] ), fc::assert_exception ); // executed successfully -> object removed + db.get( inner ); // wasn't executed -> object exists, doesn't throw } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( issue_214 ) @@ -2234,7 +2235,7 @@ BOOST_AUTO_TEST_CASE( issue_214 ) pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back(pop); sign( trx, bob_private_key ); - const proposal_id_type pid1 = PUSH_TX( db, trx ).operation_results[0].get(); + const proposal_id_type pid1 { PUSH_TX( db, trx ).operation_results[0].get() }; trx.clear(); // Bob wants to propose that Alice confirm the first proposal @@ -2259,7 +2260,7 @@ BOOST_AUTO_TEST_CASE( issue_214 ) set_expiration( db, ntx ); ntx.operations.push_back(npop); sign( ntx, bob_private_key ); - const proposal_id_type pid1a = PUSH_TX( db, ntx ).operation_results[0].get(); + const proposal_id_type pid1a { PUSH_TX( db, ntx ).operation_results[0].get() }; ntx.clear(); // But execution after confirming it fails @@ -2272,14 +2273,14 @@ BOOST_AUTO_TEST_CASE( issue_214 ) PUSH_TX( db, ntx ); ntx.clear(); - db.get( pid1a ); // still exists + db.get( pid1a ); // still exists } generate_blocks( HARDFORK_CORE_214_TIME + fc::hours(1) ); set_expiration( db, trx ); sign( trx, bob_private_key ); // after the HF the previously failed tx works too - const proposal_id_type pid2 = PUSH_TX( db, trx ).operation_results[0].get(); + const proposal_id_type pid2 { PUSH_TX( db, trx ).operation_results[0].get() }; trx.clear(); // For completeness, Alice confirms Bob's second proposal @@ -2291,8 +2292,8 @@ BOOST_AUTO_TEST_CASE( issue_214 ) // Execution of the second proposal should have confirmed the first, // which should have been executed by now. - BOOST_CHECK_THROW( db.get(pid1), fc::assert_exception ); - BOOST_CHECK_THROW( db.get(pid2), fc::assert_exception ); + BOOST_CHECK_THROW( db.get(pid1), fc::assert_exception ); + BOOST_CHECK_THROW( db.get(pid2), fc::assert_exception ); BOOST_CHECK_EQUAL( top.amount.amount.value, get_balance( bob_id, top.amount.asset_id ) ); } FC_LOG_AND_RETHROW() } @@ -2352,16 +2353,16 @@ BOOST_AUTO_TEST_CASE( self_approving_proposal ) pop.fee_paying_account = alice_id; pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back(pop); - const proposal_id_type pid1 = PUSH_TX( db, trx, ~0 ).operation_results[0].get(); + const proposal_id_type pid1 { PUSH_TX( db, trx, ~0 ).operation_results[0].get() }; trx.clear(); BOOST_REQUIRE_EQUAL( 0u, pid1.instance.value ); - db.get(pid1); + db.get(pid1); trx.operations.push_back(pup); PUSH_TX( db, trx, ~0 ); // Proposal failed and still exists - db.get(pid1); + db.get(pid1); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( self_deleting_proposal ) @@ -2383,10 +2384,10 @@ BOOST_AUTO_TEST_CASE( self_deleting_proposal ) pop.fee_paying_account = alice_id; pop.expiration_time = db.head_block_time() + fc::days(1); trx.operations.push_back( pop ); - const proposal_id_type pid1 = PUSH_TX( db, trx, ~0 ).operation_results[0].get(); + const proposal_id_type pid1 { PUSH_TX( db, trx, ~0 ).operation_results[0].get() }; trx.clear(); BOOST_REQUIRE_EQUAL( 0u, pid1.instance.value ); - db.get(pid1); + db.get(pid1); proposal_update_operation pup; pup.fee_paying_account = alice_id; @@ -2396,7 +2397,7 @@ BOOST_AUTO_TEST_CASE( self_deleting_proposal ) PUSH_TX( db, trx, ~0 ); // Proposal failed and still exists - db.get(pid1); + db.get(pid1); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/bitasset_tests.cpp b/tests/tests/bitasset_tests.cpp index e0b7629d0b..32956b2983 100644 --- a/tests/tests/bitasset_tests.cpp +++ b/tests/tests/bitasset_tests.cpp @@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE( reset_backing_asset_on_witness_asset ) trx.set_expiration(HARDFORK_CORE_868_890_TIME - fc::seconds(1)); BOOST_TEST_MESSAGE("Create USDBIT"); - asset_id_type bit_usd_id = create_bitasset("USDBIT").id; + asset_id_type bit_usd_id = create_bitasset("USDBIT").get_id(); asset_id_type core_id = bit_usd_id(db).bitasset_data(db).options.short_backing_asset; { @@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE( reset_backing_asset_on_witness_asset ) } BOOST_TEST_MESSAGE("Create JMJBIT based on USDBIT."); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").get_id(); { BOOST_TEST_MESSAGE("Update the JMJBIT asset options"); change_asset_options(*this, nathan_id, nathan_private_key, bit_jmj_id, true ); @@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE( reset_backing_asset_on_non_witness_asset ) BOOST_TEST_MESSAGE("Create USDBIT"); - asset_id_type bit_usd_id = create_bitasset("USDBIT").id; + asset_id_type bit_usd_id = create_bitasset("USDBIT").get_id(); asset_id_type core_id = bit_usd_id(db).bitasset_data(db).options.short_backing_asset; { @@ -298,7 +298,7 @@ BOOST_AUTO_TEST_CASE( reset_backing_asset_on_non_witness_asset ) } BOOST_TEST_MESSAGE("Create JMJBIT based on USDBIT."); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").get_id(); { BOOST_TEST_MESSAGE("Update the JMJBIT asset options"); change_asset_options(*this, nathan_id, nathan_private_key, bit_jmj_id, false ); @@ -479,7 +479,7 @@ BOOST_AUTO_TEST_CASE( hf_890_test ) transfer(committee_account, borrower_id, asset(init_balance)); const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // change feed lifetime @@ -523,7 +523,7 @@ BOOST_AUTO_TEST_CASE( hf_890_test ) BOOST_CHECK( usd_id(db).bitasset_data(db).current_feed.settlement_price.is_null() ); // place a sell order, it won't be matched with the call order - limit_order_id_type sell_id = create_sell_order(seller_id, asset(10, usd_id), asset(1))->id; + limit_order_id_type sell_id = create_sell_order(seller_id, asset(10, usd_id), asset(1))->get_id(); { // change feed lifetime to longer @@ -545,7 +545,7 @@ BOOST_AUTO_TEST_CASE( hf_890_test ) if( i == 0 ) // before hard fork, median feed is still null, and limit order is still there { BOOST_CHECK( usd_id(db).bitasset_data(db).current_feed.settlement_price.is_null() ); - BOOST_CHECK( db.find( sell_id ) ); + BOOST_CHECK( db.find( sell_id ) ); // go beyond hard fork blocks += generate_blocks(hf_time - mi, true, skip); @@ -555,7 +555,7 @@ BOOST_AUTO_TEST_CASE( hf_890_test ) // after hard fork, median feed should become valid, and the limit order should be filled { BOOST_CHECK( usd_id(db).bitasset_data(db).current_feed.settlement_price == current_feed.settlement_price ); - BOOST_CHECK( !db.find( sell_id ) ); + BOOST_CHECK( !db.find( sell_id ) ); } // undo above tx's and reset @@ -963,7 +963,7 @@ BOOST_AUTO_TEST_CASE( hf_1270_test ) transfer( committee_account, borrower_id, asset(init_balance) ); const auto& bitusd = create_bitasset( "USDBIT", feedproducer_id ); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // set a short feed lifetime @@ -1054,8 +1054,8 @@ BOOST_AUTO_TEST_CASE( hf_1270_test ) // when median MSSR changed to 125%, the call order will be matched, // then this limit order should be filled limit_order_id_type sell_id = ( i % 2 == 0 ) ? - create_sell_order( seller_id, asset(20, usd_id), asset(1) )->id : // for MCR test - create_sell_order( seller_id, asset(8, usd_id), asset(1) )->id; // for MSSR test + create_sell_order( seller_id, asset(20, usd_id), asset(1) )->get_id() : // for MCR test + create_sell_order( seller_id, asset(8, usd_id), asset(1) )->get_id(); // for MSSR test { // change feed lifetime to longer, let all 3 feeds be valid @@ -1082,7 +1082,7 @@ BOOST_AUTO_TEST_CASE( hf_1270_test ) BOOST_CHECK_EQUAL( usd_id(db).bitasset_data(db).current_feed.maintenance_collateral_ratio, 1750 ); BOOST_CHECK_EQUAL( usd_id(db).bitasset_data(db).current_feed.maximum_short_squeeze_ratio, 1100 ); // limit order is still there - BOOST_CHECK( db.find( sell_id ) ); + BOOST_CHECK( db.find( sell_id ) ); // go beyond hard fork 890 blocks += generate_blocks( HARDFORK_CORE_868_890_TIME - mi, true, skip ); @@ -1107,10 +1107,10 @@ BOOST_AUTO_TEST_CASE( hf_1270_test ) if( affected_by_hf_343 ) // if updated bitasset before hf 890, and hf 343 executed after hf 890 // the limit order should have been filled - BOOST_CHECK( !db.find( sell_id ) ); + BOOST_CHECK( !db.find( sell_id ) ); else // if not affected by hf 343 // the limit order should be still there, because `check_call_order` was incorrectly skipped - BOOST_CHECK( db.find( sell_id ) ); + BOOST_CHECK( db.find( sell_id ) ); // go beyond hard fork 935 blocks += generate_blocks(HARDFORK_CORE_935_TIME - mi, true, skip); @@ -1126,13 +1126,13 @@ BOOST_AUTO_TEST_CASE( hf_1270_test ) if( i % 2 == 0) { // MCR test, median MCR should be 350% and order will not be filled except when i = 0 BOOST_CHECK_EQUAL(usd_id(db).bitasset_data(db).current_feed.maintenance_collateral_ratio, 3500); if( affected_by_hf_343 ) - BOOST_CHECK(!db.find(sell_id)); + BOOST_CHECK(!db.find(sell_id)); else - BOOST_CHECK(db.find(sell_id)); // MCR bug, order still there + BOOST_CHECK(db.find(sell_id)); // MCR bug, order still there } else { // MSSR test, MSSR should be 125% and order is filled BOOST_CHECK_EQUAL(usd_id(db).bitasset_data(db).current_feed.maximum_short_squeeze_ratio, 1250); - BOOST_CHECK(!db.find(sell_id)); // order filled + BOOST_CHECK(!db.find(sell_id)); // order filled } // go beyond hard fork 1270 @@ -1147,7 +1147,7 @@ BOOST_AUTO_TEST_CASE( hf_1270_test ) BOOST_CHECK( usd_id(db).bitasset_data(db).current_feed.settlement_price == current_feed.settlement_price ); if( i % 2 == 0 ) { // MCR test, order filled BOOST_CHECK_EQUAL(usd_id(db).bitasset_data(db).current_feed.maintenance_collateral_ratio, 3500); - BOOST_CHECK(!db.find(sell_id)); + BOOST_CHECK(!db.find(sell_id)); } } @@ -1254,7 +1254,7 @@ BOOST_AUTO_TEST_CASE( reset_backing_asset_switching_to_witness_fed ) BOOST_TEST_MESSAGE("Create USDBIT"); - asset_id_type bit_usd_id = create_bitasset("USDBIT").id; + asset_id_type bit_usd_id = create_bitasset("USDBIT").get_id(); asset_id_type core_id = bit_usd_id(db).bitasset_data(db).options.short_backing_asset; { @@ -1263,7 +1263,7 @@ BOOST_AUTO_TEST_CASE( reset_backing_asset_switching_to_witness_fed ) } BOOST_TEST_MESSAGE("Create JMJBIT based on USDBIT."); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").get_id(); { BOOST_TEST_MESSAGE("Update the JMJBIT asset options"); change_asset_options(*this, nathan_id, nathan_private_key, bit_jmj_id, false ); @@ -1456,14 +1456,14 @@ BOOST_AUTO_TEST_CASE(hf_890_test_hf2481) // Create the smart asset backed by JCOIN const uint16_t smartbit_market_fee_percent = 2 * GRAPHENE_1_PERCENT; create_bitasset("SMARTBIT", smartissuer_id, smartbit_market_fee_percent, - charge_market_fee, 2, jillcoin.id); + charge_market_fee, 2, jillcoin.get_id()); // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); trx.clear(); set_expiration(db, trx); const asset_object &smartbit = get_asset("SMARTBIT"); const asset_bitasset_data_object& smartbit_bitasset_data = (*smartbit.bitasset_data_id)(db); // Confirm that the asset is to be backed by JCOIN - BOOST_CHECK(smartbit_bitasset_data.options.short_backing_asset == jillcoin.id); + BOOST_CHECK(smartbit_bitasset_data.options.short_backing_asset == jillcoin.get_id()); // Fund balances of the actors issue_uia(alice, jillcoin.amount(5000 * jillcoin_unit)); diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index c83ef29e7b..1cdfc4749c 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -592,7 +592,7 @@ BOOST_AUTO_TEST_CASE( undo_pending ) signed_transaction trx; set_expiration( db, trx ); - account_id_type nathan_id = account_idx.get_next_id(); + account_id_type nathan_id { account_idx.get_next_id() }; account_create_operation cop; cop.registrar = GRAPHENE_TEMP_ACCOUNT; cop.name = "nathan"; @@ -646,7 +646,7 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create ) signed_transaction trx; set_expiration( db1, trx ); - account_id_type nathan_id = account_idx.get_next_id(); + account_id_type nathan_id { account_idx.get_next_id() }; account_create_operation cop; cop.registrar = GRAPHENE_TEMP_ACCOUNT; cop.name = "nathan"; @@ -707,7 +707,7 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions ) signed_transaction trx; set_expiration( db1, trx ); - account_id_type nathan_id = account_idx.get_next_id(); + account_id_type nathan_id { account_idx.get_next_id() }; account_create_operation cop; cop.name = "nathan"; cop.owner = authority(1, init_account_pub_key, 1); @@ -760,7 +760,7 @@ BOOST_AUTO_TEST_CASE( tapos ) trx.set_expiration( db1.head_block_time() ); //db1.get_slot_time(1) ); trx.set_reference_block( db1.head_block_id() ); - account_id_type nathan_id = account_idx.get_next_id(); + account_id_type nathan_id { account_idx.get_next_id() }; account_create_operation cop; cop.registrar = init1.id; cop.name = "nathan"; @@ -1526,7 +1526,7 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture ) account_object sam_account_object = create_account( "sam", sam_key ); // upgrade sam to LTM - upgrade_to_lifetime_member(sam_account_object.id); + upgrade_to_lifetime_member(sam_account_object.get_id()); //Get a sane head block time generate_block( skip_flags ); @@ -1632,9 +1632,9 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture ) database::skip_transaction_dupe_check | database::skip_transaction_signatures ); - account_id_type alice_account_id = + account_id_type alice_account_id { ptx_create.operation_results[0] - .get< object_id_type >(); + .get< object_id_type >() }; generate_block( skip_flags ); for( const vector< int >& key_sched_after : possible_key_sched ) diff --git a/tests/tests/bsip48_75_tests.cpp b/tests/tests/bsip48_75_tests.cpp index 84f37106ec..c450461224 100644 --- a/tests/tests/bsip48_75_tests.cpp +++ b/tests/tests/bsip48_75_tests.cpp @@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE( bsip48_75_hardfork_protection_test ) // Able to create asset without new data processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& samcoin = db.get(ptx.operation_results[0].get()); - asset_id_type samcoin_id = samcoin.id; + asset_id_type samcoin_id = samcoin.get_id(); BOOST_CHECK_EQUAL( samcoin.options.market_fee_percent, 100 ); BOOST_CHECK_EQUAL( samcoin.bitasset_data(db).options.minimum_feeds, 3 ); @@ -304,7 +304,7 @@ BOOST_AUTO_TEST_CASE( prediction_market_global_settle_permission ) // create a prediction market const asset_object& pm = create_prediction_market( "PDM", sam_id ); - asset_id_type pm_id = pm.id; + asset_id_type pm_id = pm.get_id(); BOOST_CHECK( pm_id(db).can_global_settle() ); @@ -376,7 +376,7 @@ BOOST_AUTO_TEST_CASE( update_max_supply ) // create a UIA const asset_object& uia = create_user_issued_asset( "UIATEST", sam, charge_market_fee ); - asset_id_type uia_id = uia.id; + asset_id_type uia_id = uia.get_id(); // issue some to Sam issue_uia( sam_id, uia.amount( GRAPHENE_MAX_SHARE_SUPPLY - 100 ) ); @@ -702,7 +702,7 @@ BOOST_AUTO_TEST_CASE( disable_new_supply_uia ) // create a UIA const asset_object& uia = create_user_issued_asset( "UIATEST", sam, charge_market_fee ); - asset_id_type uia_id = uia.id; + asset_id_type uia_id = uia.get_id(); BOOST_CHECK( uia_id(db).can_create_new_supply() ); BOOST_CHECK_EQUAL( uia_id(db).dynamic_data(db).current_supply.value, 0 ); @@ -811,7 +811,7 @@ BOOST_AUTO_TEST_CASE( disable_new_supply_pm ) // create a PM const asset_object& pm = create_prediction_market( "PDM", sam_id ); - asset_id_type pm_id = pm.id; + asset_id_type pm_id = pm.get_id(); BOOST_CHECK( pm_id(db).can_create_new_supply() ); BOOST_CHECK_EQUAL( pm_id(db).dynamic_data(db).current_supply.value, 0 ); @@ -918,7 +918,7 @@ BOOST_AUTO_TEST_CASE( skip_core_exchange_rate ) // create a UIA const asset_object& uia = create_user_issued_asset( "UIATEST", sam, charge_market_fee ); - asset_id_type uia_id = uia.id; + asset_id_type uia_id = uia.get_id(); BOOST_CHECK( uia_id(db).options.core_exchange_rate == price(asset(1, uia_id), asset(1)) ); @@ -1014,7 +1014,7 @@ BOOST_AUTO_TEST_CASE( invalid_flags_in_asset ) processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& samcoin = db.get(ptx.operation_results[0].get()); - asset_id_type samcoin_id = samcoin.id; + asset_id_type samcoin_id = samcoin.get_id(); // There are invalid bits in flags BOOST_CHECK( samcoin_id(db).options.flags & ~UIA_VALID_FLAGS_MASK ); @@ -1031,7 +1031,7 @@ BOOST_AUTO_TEST_CASE( invalid_flags_in_asset ) ptx = PUSH_TX(db, trx, ~0); const asset_object& sambit = db.get(ptx.operation_results[0].get()); - asset_id_type sambit_id = sambit.id; + asset_id_type sambit_id = sambit.get_id(); // There are invalid bits in flags BOOST_CHECK( sambit_id(db).options.flags & ~VALID_FLAGS_MASK ); @@ -1155,7 +1155,7 @@ BOOST_AUTO_TEST_CASE( invalid_flags_in_asset ) trx.operations.push_back( acop ); ptx = PUSH_TX(db, trx, ~0); const asset_object& newsamcoin = db.get(ptx.operation_results[0].get()); - asset_id_type newsamcoin_id = newsamcoin.id; + asset_id_type newsamcoin_id = newsamcoin.get_id(); BOOST_CHECK_EQUAL( newsamcoin_id(db).options.flags, UIA_VALID_FLAGS_MASK ); @@ -1186,7 +1186,7 @@ BOOST_AUTO_TEST_CASE( invalid_flags_in_asset ) trx.operations.push_back( acop2 ); ptx = PUSH_TX(db, trx, ~0); const asset_object& newsambit = db.get(ptx.operation_results[0].get()); - asset_id_type newsambit_id = newsambit.id; + asset_id_type newsambit_id = newsambit.get_id(); BOOST_CHECK_EQUAL( newsambit_id(db).options.flags, valid_bitflag ); @@ -1235,7 +1235,7 @@ BOOST_AUTO_TEST_CASE( update_asset_precision ) // create a prediction market const asset_object& pm = create_prediction_market( "PDM", sam_id ); - asset_id_type pm_id = pm.id; + asset_id_type pm_id = pm.get_id(); BOOST_CHECK_EQUAL( pm_id(db).precision, 5 ); @@ -1258,7 +1258,7 @@ BOOST_AUTO_TEST_CASE( update_asset_precision ) // create a UIA const asset_object& uia = create_user_issued_asset( "UIATEST", sam, charge_market_fee ); - asset_id_type uia_id = uia.id; + asset_id_type uia_id = uia.get_id(); BOOST_CHECK_EQUAL( uia_id(db).precision, 2 ); @@ -1321,7 +1321,7 @@ BOOST_AUTO_TEST_CASE( update_asset_precision ) // create a MPA which is backed by the UIA const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 10, charge_market_fee, 3, uia_id ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa_id(db).bitasset_data(db).options.short_backing_asset == uia_id ); @@ -1357,7 +1357,7 @@ BOOST_AUTO_TEST_CASE( asset_owner_permissions_update_icr_mcr_mssr ) // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa_id(db).can_owner_update_icr() ); BOOST_CHECK( mpa_id(db).can_owner_update_mcr() ); @@ -1747,7 +1747,7 @@ BOOST_AUTO_TEST_CASE( asset_owner_update_mcr_mssr ) // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); asset_id_type core_id = asset_id_type(); // add a price feed publisher and publish a feed @@ -1773,7 +1773,7 @@ BOOST_AUTO_TEST_CASE( asset_owner_update_mcr_mssr ) // borrower borrows some and sends to seller const call_order_object* call_ptr = borrow( borrower_id, asset(1000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id { call_ptr->id }; BOOST_CHECK_EQUAL( call_id(db).debt.value, 1000 ); BOOST_CHECK_EQUAL( call_id(db).collateral.value, 2000 ); @@ -1792,13 +1792,13 @@ BOOST_AUTO_TEST_CASE( asset_owner_update_mcr_mssr ) // seller places orders const limit_order_object* order1_ptr = create_sell_order( seller, asset(100, mpa_id), asset(105) ); BOOST_REQUIRE( order1_ptr ); - limit_order_id_type order1_id = order1_ptr->id; + limit_order_id_type order1_id = order1_ptr->get_id(); BOOST_CHECK_EQUAL( order1_id(db).for_sale.value, 100 ); BOOST_CHECK_EQUAL( order1_id(db).amount_to_receive().amount.value, 105 ); const limit_order_object* order2_ptr = create_sell_order( seller, asset(100, mpa_id), asset(115) ); BOOST_REQUIRE( order2_ptr ); - limit_order_id_type order2_id = order2_ptr->id; + limit_order_id_type order2_id = order2_ptr->get_id(); BOOST_CHECK_EQUAL( order2_id(db).for_sale.value, 100 ); BOOST_CHECK_EQUAL( order2_id(db).amount_to_receive().amount.value, 115 ); diff --git a/tests/tests/bsip85_tests.cpp b/tests/tests/bsip85_tests.cpp index 88eaab71e0..fc76ec70fd 100644 --- a/tests/tests/bsip85_tests.cpp +++ b/tests/tests/bsip85_tests.cpp @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE( hardfork_time_test ) // Should succeed processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); - proposal_id_type prop_id = ptx.operation_results[0].get(); + proposal_id_type prop_id { ptx.operation_results[0].get() }; // The maker fee discount percent is still 0 BOOST_CHECK_EQUAL( db.get_global_properties().parameters.get_maker_fee_discount_percent(), 0 ); @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE( bsip85_maker_fee_discount_test ) int64_t cer_usd_amount = 31; price tmp_cer( asset( cer_core_amount ), asset( cer_usd_amount, asset_id_type(1) ) ); const auto& usd_obj = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee, tmp_cer ); - asset_id_type usd_id = usd_obj.id; + asset_id_type usd_id = usd_obj.get_id(); issue_uia( alice_id, asset( alice_b0, usd_id ) ); issue_uia( bob_id, asset( bob_b0, usd_id ) ); @@ -185,11 +185,11 @@ BOOST_AUTO_TEST_CASE( bsip85_maker_fee_discount_test ) BOOST_TEST_MESSAGE( "Creating ao1, then be filled by bo1" ); // pays fee in core const limit_order_object* ao1 = create_sell_order( alice_id, asset(1000), asset(200, usd_id) ); - const limit_order_id_type ao1id = ao1->id; + const limit_order_id_type ao1id = ao1->get_id(); // pays fee in usd const limit_order_object* bo1 = create_sell_order( bob_id, asset(200, usd_id), asset(1000), max_exp, cer ); - BOOST_CHECK( db.find( ao1id ) == nullptr ); + BOOST_CHECK( db.find( ao1id ) == nullptr ); BOOST_CHECK( bo1 == nullptr ); // data after order created @@ -218,11 +218,11 @@ BOOST_AUTO_TEST_CASE( bsip85_maker_fee_discount_test ) BOOST_TEST_MESSAGE( "Creating ao2, then be partially filled by bo2" ); // pays fee in usd const limit_order_object* ao2 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), max_exp, cer ); - const limit_order_id_type ao2id = ao2->id; + const limit_order_id_type ao2id = ao2->get_id(); // pays fee in core const limit_order_object* bo2 = create_sell_order( bob_id, asset(100, usd_id), asset(500) ); - BOOST_CHECK( db.find( ao2id ) != nullptr ); + BOOST_CHECK( db.find( ao2id ) != nullptr ); BOOST_CHECK( bo2 == nullptr ); // data after order created diff --git a/tests/tests/bsip86_tests.cpp b/tests/tests/bsip86_tests.cpp index 739720e1ba..b740a09194 100644 --- a/tests/tests/bsip86_tests.cpp +++ b/tests/tests/bsip86_tests.cpp @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE( hardfork_time_test ) // Should succeed processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); - proposal_id_type prop_id = ptx.operation_results[0].get(); + proposal_id_type prop_id { ptx.operation_results[0].get() }; // The network fee percent is still 0 BOOST_CHECK_EQUAL( db.get_global_properties().parameters.get_market_fee_network_percent(), 0 ); @@ -131,8 +131,8 @@ BOOST_AUTO_TEST_CASE( fee_sharing_test ) cer, 4, market_fee_percent ); const asset_object& aliceusd = create_user_issued_asset( "ALICEUSD", alice_id(db), 0 ); - asset_id_type alicecoin_id = alicecoin.id; - asset_id_type aliceusd_id = aliceusd.id; + asset_id_type alicecoin_id = alicecoin.get_id(); + asset_id_type aliceusd_id = aliceusd.get_id(); // prepare users' balance issue_uia( alice, aliceusd.amount( 20000000 ) ); diff --git a/tests/tests/bsrm_basic_tests.cpp b/tests/tests/bsrm_basic_tests.cpp index d3ce89aa59..d6047adcc3 100644 --- a/tests/tests/bsrm_basic_tests.cpp +++ b/tests/tests/bsrm_basic_tests.cpp @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE( bsrm_hardfork_protection_test ) // Able to create asset without new data processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& samcoin = db.get(ptx.operation_results[0].get()); - asset_id_type samcoin_id = samcoin.id; + asset_id_type samcoin_id = samcoin.get_id(); BOOST_CHECK_EQUAL( samcoin.options.market_fee_percent, 100 ); BOOST_CHECK_EQUAL( samcoin.bitasset_data(db).options.minimum_feeds, 3 ); @@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE( uia_issuer_permissions_update_test ) vector ops; - asset_id_type samcoin_id = create_user_issued_asset( "SAMCOIN", sam_id(db), uiaflag ).id; + asset_id_type samcoin_id = create_user_issued_asset( "SAMCOIN", sam_id(db), uiaflag ).get_id(); // Testing asset_update_operation asset_update_operation auop; @@ -411,15 +411,15 @@ BOOST_AUTO_TEST_CASE( bsrm_asset_permissions_flags_extensions_test ) // create a PM with a zero market_fee_percent const asset_object& pm = create_prediction_market( "TESTPM", sam_id, 0, charge_market_fee ); - asset_id_type pm_id = pm.id; + asset_id_type pm_id = pm.get_id(); // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // create a UIA with a zero market_fee_percent const asset_object& uia = create_user_issued_asset( "TESTUIA", sam_id(db), charge_market_fee ); - asset_id_type uia_id = uia.id; + asset_id_type uia_id = uia.get_id(); // Prepare for asset update asset_update_operation auop; @@ -572,7 +572,7 @@ BOOST_AUTO_TEST_CASE( bsrm_asset_owner_permissions_update_bsrm ) // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa_id(db).can_owner_update_bsrm() ); @@ -719,7 +719,7 @@ BOOST_AUTO_TEST_CASE( close_debt_position_when_no_feed ) // Create asset // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // add a price feed publisher and publish a feed update_feed_producers( mpa_id, { feeder_id } ); @@ -738,7 +738,7 @@ BOOST_AUTO_TEST_CASE( close_debt_position_when_no_feed ) // borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // update price feed publisher list so that there is no valid feed update_feed_producers( mpa_id, { sam_id } ); @@ -796,7 +796,7 @@ BOOST_AUTO_TEST_CASE( update_bsrm_after_gs ) // Create asset // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); using bsrm_type = bitasset_options::black_swan_response_type; @@ -821,7 +821,7 @@ BOOST_AUTO_TEST_CASE( update_bsrm_after_gs ) // borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized ilog( "Publish a new feed to trigger GS" ); @@ -940,7 +940,7 @@ BOOST_AUTO_TEST_CASE( update_bsrm_after_individual_settlement_to_fund ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::individual_settlement_to_fund ); @@ -964,10 +964,10 @@ BOOST_AUTO_TEST_CASE( update_bsrm_after_individual_settlement_to_fund ) // borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(8000) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized ilog( "Publish a new feed to trigger settlement" ); @@ -1090,7 +1090,7 @@ BOOST_AUTO_TEST_CASE( update_bsrm_after_individual_settlement_to_order ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::individual_settlement_to_order ); @@ -1114,10 +1114,10 @@ BOOST_AUTO_TEST_CASE( update_bsrm_after_individual_settlement_to_order ) // borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(8000) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized ilog( "Publish a new feed to trigger settlement" ); @@ -1248,7 +1248,7 @@ BOOST_AUTO_TEST_CASE( undercollateralized_and_update_bsrm_from_no_settlement ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -1272,10 +1272,10 @@ BOOST_AUTO_TEST_CASE( undercollateralized_and_update_bsrm_from_no_settlement ) // borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(8000) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized ilog( "Publish a new feed so that the least collateralized short is undercollateralized" ); @@ -1394,7 +1394,7 @@ BOOST_AUTO_TEST_CASE( manual_gs_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == static_cast(i) ); BOOST_CHECK( !mpa_id(db).bitasset_data(db).has_individual_settlement() ); @@ -1417,10 +1417,10 @@ BOOST_AUTO_TEST_CASE( manual_gs_test ) // borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(8000) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized ilog( "Publish a new feed so that the least collateralized short is undercollateralized" ); diff --git a/tests/tests/bsrm_indvd_settlement_tests.cpp b/tests/tests/bsrm_indvd_settlement_tests.cpp index 598b740f34..26e567d3ad 100644 --- a/tests/tests/bsrm_indvd_settlement_tests.cpp +++ b/tests/tests/bsrm_indvd_settlement_tests.cpp @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); if( 0 == i ) BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() @@ -128,31 +128,31 @@ BOOST_AUTO_TEST_CASE( individual_settlement_test ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // 100000 / 2100 = 47.619047619 // undercollateralization price = 100000:2100 * 1250:1000 = 100000:1680 const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // 100000 / 2200 = 45.454545455 // undercollateralization price = 100000:2200 * 1250:1000 = 100000:1760 const call_order_object* call3_ptr = borrow( borrower3, asset(100000, mpa_id), asset(2200) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // 100000 / 2500 = 40 // undercollateralization price = 100000:2500 * 1250:1000 = 100000:2000 const call_order_object* call4_ptr = borrow( borrower4, asset(100000, mpa_id), asset(2500) ); BOOST_REQUIRE( call4_ptr ); - call_order_id_type call4_id = call4_ptr->id; + call_order_id_type call4_id = call4_ptr->get_id(); // 100000 / 2240 = 44.642857143 // undercollateralization price = 100000:2240 * 1250:1000 = 100000:1792 const call_order_object* call5_ptr = borrow( borrower5, asset(1000000, mpa_id), asset(22400) ); BOOST_REQUIRE( call5_ptr ); - call_order_id_type call5_id = call5_ptr->id; + call_order_id_type call5_id = call5_ptr->get_id(); // Transfer funds to sellers transfer( borrower, seller, asset(100000,mpa_id) ); @@ -191,36 +191,36 @@ BOOST_AUTO_TEST_CASE( individual_settlement_test ) // seller sells some const limit_order_object* sell_low = create_sell_order( seller, asset(10000,mpa_id), asset(190) ); BOOST_REQUIRE( sell_low ); - limit_order_id_type sell_low_id = sell_low->id; + limit_order_id_type sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 10000 ); // seller sells some const limit_order_object* sell_mid = create_sell_order( seller, asset(100000,mpa_id), asset(2000) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 100000 ); // seller4 sells some const limit_order_object* sell_mid2 = create_sell_order( seller4, asset(20000,mpa_id), asset(439) ); BOOST_REQUIRE( sell_mid2 ); - limit_order_id_type sell_mid2_id = sell_mid2->id; + limit_order_id_type sell_mid2_id = sell_mid2->get_id(); BOOST_CHECK_EQUAL( sell_mid2_id(db).for_sale.value, 20000 ); // seller sells some const limit_order_object* sell_high = create_sell_order( seller, asset(100000,mpa_id), asset(2400) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 100000 ); // seller2 settles auto result = force_settle( seller2, asset(50000,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find( settle_id ) ); BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 50000 ); // seller3 settles result = force_settle( seller3, asset(10000,mpa_id) ); - force_settlement_id_type settle2_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle2_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find( settle2_id ) ); BOOST_CHECK_EQUAL( settle2_id(db).balance.amount.value, 10000 ); @@ -529,7 +529,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_test ) BOOST_TEST_MESSAGE( "Seller4 sells some" ); const limit_order_object* sell_mid3 = create_sell_order( seller4, asset(20000,mpa_id), asset(439) ); BOOST_REQUIRE( sell_mid3 ); - limit_order_id_type sell_mid3_id = sell_mid3->id; + limit_order_id_type sell_mid3_id = sell_mid3->get_id(); auto check_result_2 = [&] { @@ -589,7 +589,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_disable_force_settle_tes // Create asset asset_id_type samcoin_id = create_user_issued_asset( "SAMCOIN", sam_id(db), charge_market_fee, price(asset(1, asset_id_type(1)), asset(1)), - 2, 100 ).id; // fee 1% + 2, 100 ).get_id(); // fee 1% issue_uia( borrower, asset(init_amount, samcoin_id) ); issue_uia( borrower2, asset(init_amount, samcoin_id) ); @@ -614,7 +614,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_disable_force_settle_tes trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::individual_settlement_to_fund ); @@ -643,12 +643,12 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_disable_force_settle_tes // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000, samcoin_id) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // undercollateralization price = 100000:2500 * 1250:1000 = 100000:2000 const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2500, samcoin_id) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // Transfer funds to sellers transfer( borrower, seller, asset(100000,mpa_id) ); @@ -875,7 +875,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_taking_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::individual_settlement_to_fund ); @@ -904,22 +904,22 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_taking_test ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // undercollateralization price = 100000:2100 * 1250:1000 = 100000:1680 const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // undercollateralization price = 100000:2200 * 1250:1000 = 100000:1760 const call_order_object* call3_ptr = borrow( borrower3, asset(100000, mpa_id), asset(2200) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // undercollateralization price = 100000:2500 * 1250:1000 = 100000:2000 const call_order_object* call4_ptr = borrow( borrower4, asset(100000, mpa_id), asset(2500) ); BOOST_REQUIRE( call4_ptr ); - call_order_id_type call4_id = call4_ptr->id; + call_order_id_type call4_id = call4_ptr->get_id(); // Transfer funds to sellers transfer( borrower, seller, asset(100000,mpa_id) ); @@ -978,7 +978,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_taking_test ) BOOST_CHECK_THROW( borrow( borrower5, asset(100000, mpa_id), asset(3135) ), fc::exception ); const call_order_object* call5_ptr = borrow( borrower5, asset(100000, mpa_id), asset(3136) ); BOOST_REQUIRE( call5_ptr ); - call_order_id_type call5_id = call5_ptr->id; + call_order_id_type call5_id = call5_ptr->get_id(); BOOST_CHECK_EQUAL( call5_id(db).debt.value, 100000 ); BOOST_CHECK_EQUAL( call5_id(db).collateral.value, 3136 ); @@ -1012,7 +1012,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_fund_and_taking_test ) limit_ptr = create_sell_order( seller, asset(100000,mpa_id), asset(2000) ); // the limit order is not filled BOOST_REQUIRE( limit_ptr ); - limit_order_id_type limit_id = limit_ptr->id; + limit_order_id_type limit_id = limit_ptr->get_id(); BOOST_CHECK_EQUAL( limit_ptr->for_sale.value, 100000 ); @@ -1177,7 +1177,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_order_and_taking_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::individual_settlement_to_order ); @@ -1205,22 +1205,22 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_order_and_taking_test ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // undercollateralization price = 100000:2100 * 1250:1000 = 100000:1680 const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // undercollateralization price = 100000:2200 * 1250:1000 = 100000:1760 const call_order_object* call3_ptr = borrow( borrower3, asset(100000, mpa_id), asset(2200) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // undercollateralization price = 100000:2500 * 1250:1000 = 100000:2000 const call_order_object* call4_ptr = borrow( borrower4, asset(100000, mpa_id), asset(2500) ); BOOST_REQUIRE( call4_ptr ); - call_order_id_type call4_id = call4_ptr->id; + call_order_id_type call4_id = call4_ptr->get_id(); // Transfer funds to sellers transfer( borrower, seller, asset(100000,mpa_id) ); @@ -1320,7 +1320,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_order_and_taking_test ) // borrower buys at higher price const limit_order_object* buy_high = create_sell_order( borrower, asset(10), asset(100,mpa_id) ); BOOST_CHECK( buy_high ); - limit_order_id_type buy_high_id = buy_high->id; + limit_order_id_type buy_high_id = buy_high->get_id(); // seller sells some, this will match buy_high, // and when it matches call4, it will be cancelled since it is too small @@ -1348,7 +1348,7 @@ BOOST_AUTO_TEST_CASE( individual_settlement_to_order_and_taking_test ) // borrower buys at higher price buy_high = create_sell_order( borrower, asset(10), asset(100,mpa_id) ); BOOST_CHECK( buy_high ); - buy_high_id = buy_high->id; + buy_high_id = buy_high->get_id(); // seller sells some, this will match buy_high, // and when it matches the settled debt, it will be cancelled since it is too small @@ -1473,7 +1473,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_debt_position ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::individual_settlement_to_order ); @@ -1484,7 +1484,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_debt_position ) trx.operations.push_back( acop ); ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa2 = db.get(ptx.operation_results[0].get()); - asset_id_type mpa2_id = mpa2.id; + asset_id_type mpa2_id = mpa2.get_id(); // add a price feed publisher and publish a feed update_feed_producers( mpa_id, { feeder_id } ); @@ -1518,12 +1518,12 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_debt_position ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // undercollateralization price = 100000:2100 * 1250:1000 = 100000:1680 const call_order_object* call2_ptr = borrow( borrower, asset(100000, mpa2_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // Transfer funds to sellers transfer( borrower, seller, asset(100000,mpa_id) ); @@ -1564,13 +1564,13 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_debt_position ) // seller settles some auto result = force_settle( seller, asset(11100,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find(settle_id) ); BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 11100 ); result = force_settle( seller, asset(11100,mpa2_id) ); - force_settlement_id_type settle2_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle2_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find(settle2_id) ); BOOST_CHECK_EQUAL( settle2_id(db).balance.amount.value, 11100 ); diff --git a/tests/tests/bsrm_no_settlement_tests.cpp b/tests/tests/bsrm_no_settlement_tests.cpp index 4487c9050b..db7d304da9 100644 --- a/tests/tests/bsrm_no_settlement_tests.cpp +++ b/tests/tests/bsrm_no_settlement_tests.cpp @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_margin_call_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -99,11 +99,11 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_margin_call_test ) // borrowers borrow some const call_order_object* call_ptr = borrow( borrower, asset(1000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(1000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized f.settlement_price = price( asset(10,mpa_id), asset(22) ); @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_margin_call_test ) // borrower3 create debt position right above ICR const call_order_object* call3_ptr = borrow( borrower3, asset(1000, mpa_id), asset(4181) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // borrower adjust debt position to right at MSSR // 1000 * (22/10) * 1.25 = 2750 @@ -169,19 +169,19 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_margin_call_test ) // seller2 sells some, due to MCFR, this order won't be filled in the beginning, but will be filled later const limit_order_object* sell_mid = create_sell_order( seller2, asset(100,mpa_id), asset(210) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 100 ); // seller2 sells more, this order won't be filled in the beginning either const limit_order_object* sell_high = create_sell_order( seller2, asset(100,mpa_id), asset(275) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 100 ); // seller2 sells more, this order won't be filled const limit_order_object* sell_highest = create_sell_order( seller2, asset(100,mpa_id), asset(285) ); BOOST_REQUIRE( sell_highest ); - limit_order_id_type sell_highest_id = sell_highest->id; + limit_order_id_type sell_highest_id = sell_highest->get_id(); BOOST_CHECK_EQUAL( sell_highest_id(db).for_sale.value, 100 ); BOOST_CHECK_EQUAL( get_balance( seller_id, mpa_id ), 2500 ); @@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_margin_call_test ) // seller sells more sell_low = create_sell_order( seller, asset(1000,mpa_id), asset(100) ); BOOST_REQUIRE( sell_low ); - limit_order_id_type sell_low_id = sell_low->id; + limit_order_id_type sell_low_id = sell_low->get_id(); auto final_check = [&] { @@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_limit_taker_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -368,11 +368,11 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_limit_taker_test ) // borrowers borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized f.settlement_price = price( asset(1000,mpa_id), asset(22) ); @@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_limit_taker_test ) // borrower3 create debt position right above ICR const call_order_object* call3_ptr = borrow( borrower3, asset(100000, mpa_id), asset(4181) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // borrower adjust debt position to right at MSSR // 100000 * (22/1000) * 1.25 = 2750 @@ -438,19 +438,19 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_limit_taker_test ) // seller2 sells some, due to MCFR, this order won't be filled in the beginning, but will be filled later const limit_order_object* sell_mid = create_sell_order( seller2, asset(10000,mpa_id), asset(210) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 10000 ); // seller2 sells more, this order won't be filled in the beginning either const limit_order_object* sell_high = create_sell_order( seller2, asset(10000,mpa_id), asset(275) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 10000 ); // seller2 sells more, this order won't be filled const limit_order_object* sell_highest = create_sell_order( seller2, asset(10000,mpa_id), asset(285) ); BOOST_REQUIRE( sell_highest ); - limit_order_id_type sell_highest_id = sell_highest->id; + limit_order_id_type sell_highest_id = sell_highest->get_id(); BOOST_CHECK_EQUAL( sell_highest_id(db).for_sale.value, 10000 ); BOOST_CHECK_EQUAL( get_balance( seller_id, mpa_id ), 250000 ); @@ -610,7 +610,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_force_settle_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -633,11 +633,11 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_force_settle_test ) // borrowers borrow some const call_order_object* call_ptr = borrow( borrower, asset(1000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(1000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized f.settlement_price = price( asset(10,mpa_id), asset(22) ); @@ -655,7 +655,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_force_settle_test ) // borrower3 create debt position right above ICR const call_order_object* call3_ptr = borrow( borrower3, asset(1000, mpa_id), asset(4181) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // borrower adjust debt position to right at MSSR // 1000 * (22/10) * 1.25 = 2750 @@ -703,19 +703,19 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_force_settle_test ) // seller2 sells some, due to MCFR, this order won't be filled in the beginning, but will be filled later const limit_order_object* sell_mid = create_sell_order( seller2, asset(100,mpa_id), asset(210) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 100 ); // seller2 sells more, this order won't be filled in the beginning either const limit_order_object* sell_high = create_sell_order( seller2, asset(100,mpa_id), asset(275) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 100 ); // seller2 sells more, this order won't be filled const limit_order_object* sell_highest = create_sell_order( seller2, asset(100,mpa_id), asset(285) ); BOOST_REQUIRE( sell_highest ); - limit_order_id_type sell_highest_id = sell_highest->id; + limit_order_id_type sell_highest_id = sell_highest->get_id(); BOOST_CHECK_EQUAL( sell_highest_id(db).for_sale.value, 100 ); BOOST_CHECK_EQUAL( get_balance( seller_id, mpa_id ), 2500 ); @@ -725,7 +725,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_force_settle_test ) // seller settles some auto result = force_settle( seller, asset(111,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( !db.find(settle_id) ); BOOST_CHECK_EQUAL( get_balance( seller_id, mpa_id ), 2389 ); // 2500 - 111 @@ -888,7 +888,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_settle_taker_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -911,11 +911,11 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_settle_taker_test ) // borrowers borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized f.settlement_price = price( asset(1000,mpa_id), asset(22) ); @@ -933,7 +933,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_settle_taker_test ) // borrower3 create debt position right above ICR const call_order_object* call3_ptr = borrow( borrower3, asset(100000, mpa_id), asset(4181) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // borrower adjust debt position to right at MSSR // 100000 * (22/1000) * 1.25 = 2750 @@ -981,19 +981,19 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_settle_taker_test ) // seller2 sells some, due to MCFR, this order won't be filled in the beginning, but will be filled later const limit_order_object* sell_mid = create_sell_order( seller2, asset(10000,mpa_id), asset(210) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 10000 ); // seller2 sells more, this order won't be filled in the beginning either const limit_order_object* sell_high = create_sell_order( seller2, asset(10000,mpa_id), asset(275) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 10000 ); // seller2 sells more, this order won't be filled const limit_order_object* sell_highest = create_sell_order( seller2, asset(10000,mpa_id), asset(285) ); BOOST_REQUIRE( sell_highest ); - limit_order_id_type sell_highest_id = sell_highest->id; + limit_order_id_type sell_highest_id = sell_highest->get_id(); BOOST_CHECK_EQUAL( sell_highest_id(db).for_sale.value, 10000 ); BOOST_CHECK_EQUAL( get_balance( seller_id, mpa_id ), 250000 ); @@ -1003,7 +1003,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_maker_small_settle_taker_test ) // seller settles some auto result = force_settle( seller, asset(11100,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; auto final_check = [&] { @@ -1099,7 +1099,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -1122,16 +1122,16 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) // borrowers borrow some const call_order_object* call_ptr = borrow( borrower, asset(1000, mpa_id), asset(2750) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(1000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // 1000 * (22/10) * 1.9 = 4180 const call_order_object* call3_ptr = borrow( borrower3, asset(1000, mpa_id), asset(4181) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // Transfer funds to sellers transfer( borrower, seller, asset(1000,mpa_id) ); @@ -1145,21 +1145,21 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) // seller2 sells some const limit_order_object* sell_highest = create_sell_order( seller2, asset(100,mpa_id), asset(285) ); BOOST_REQUIRE( sell_highest ); - limit_order_id_type sell_highest_id = sell_highest->id; + limit_order_id_type sell_highest_id = sell_highest->get_id(); BOOST_CHECK_EQUAL( sell_highest_id(db).for_sale.value, 100 ); expected_seller2_balance_mpa -= 100; // seller2 sells more const limit_order_object* sell_high = create_sell_order( seller2, asset(100,mpa_id), asset(275) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 100 ); expected_seller2_balance_mpa -= 100; // seller2 sells more, due to MCFR, this order won't be filled if no order is selling lower const limit_order_object* sell_mid = create_sell_order( seller2, asset(100,mpa_id), asset(210) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 100 ); expected_seller2_balance_mpa -= 100; @@ -1176,7 +1176,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(111,mpa_id), asset(230) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 111 ); expected_seller_balance_mpa -= 111; } @@ -1184,7 +1184,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(111,mpa_id), asset(210) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 111 ); expected_seller_balance_mpa -= 111; } @@ -1192,7 +1192,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(900,mpa_id), asset(1870) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 900 ); expected_seller_balance_mpa -= 900; } @@ -1200,7 +1200,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(920,mpa_id), asset(1870) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 920 ); expected_seller_balance_mpa -= 920; } @@ -1208,7 +1208,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(1000,mpa_id), asset(1870) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 1000 ); expected_seller_balance_mpa -= 1000; } @@ -1216,7 +1216,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(1050,mpa_id), asset(1870) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 1050 ); expected_seller_balance_mpa -= 1050; } @@ -1224,7 +1224,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(1800,mpa_id), asset(1870*2) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 1800 ); expected_seller_balance_mpa -= 1800; } @@ -1232,7 +1232,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_taker_test ) { sell_low = create_sell_order( seller, asset(2000,mpa_id), asset(1870) ); BOOST_REQUIRE( sell_low ); - sell_low_id = sell_low->id; + sell_low_id = sell_low->get_id(); BOOST_CHECK_EQUAL( sell_low_id(db).for_sale.value, 2000 ); expected_seller_balance_mpa -= 2000; } @@ -2218,7 +2218,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_update_debt_test ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa.bitasset_data(db).get_black_swan_response_method() == bsrm_type::no_settlement ); @@ -2241,11 +2241,11 @@ BOOST_AUTO_TEST_CASE( no_settlement_update_debt_test ) // borrowers borrow some const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); const call_order_object* call2_ptr = borrow( borrower2, asset(100000, mpa_id), asset(2100) ); BOOST_REQUIRE( call2_ptr ); - call_order_id_type call2_id = call2_ptr->id; + call_order_id_type call2_id = call2_ptr->get_id(); // publish a new feed so that borrower's debt position is undercollateralized f.settlement_price = price( asset(1000,mpa_id), asset(22) ); @@ -2263,7 +2263,7 @@ BOOST_AUTO_TEST_CASE( no_settlement_update_debt_test ) // borrower3 create debt position right above ICR const call_order_object* call3_ptr = borrow( borrower3, asset(100000, mpa_id), asset(4181) ); BOOST_REQUIRE( call3_ptr ); - call_order_id_type call3_id = call3_ptr->id; + call_order_id_type call3_id = call3_ptr->get_id(); // borrower adjust debt position to right at MSSR // 100000 * (22/1000) * 1.25 = 2750 @@ -2308,19 +2308,19 @@ BOOST_AUTO_TEST_CASE( no_settlement_update_debt_test ) // seller2 sells some, due to MCFR, this order won't be filled in the beginning, but will be filled later const limit_order_object* sell_mid = create_sell_order( seller2, asset(10000,mpa_id), asset(210) ); BOOST_REQUIRE( sell_mid ); - limit_order_id_type sell_mid_id = sell_mid->id; + limit_order_id_type sell_mid_id = sell_mid->get_id(); BOOST_CHECK_EQUAL( sell_mid_id(db).for_sale.value, 10000 ); // seller2 sells more, this order won't be filled in the beginning either const limit_order_object* sell_high = create_sell_order( seller2, asset(10000,mpa_id), asset(275) ); BOOST_REQUIRE( sell_high ); - limit_order_id_type sell_high_id = sell_high->id; + limit_order_id_type sell_high_id = sell_high->get_id(); BOOST_CHECK_EQUAL( sell_high_id(db).for_sale.value, 10000 ); // seller2 sells more, this order won't be filled const limit_order_object* sell_highest = create_sell_order( seller2, asset(10000,mpa_id), asset(285) ); BOOST_REQUIRE( sell_highest ); - limit_order_id_type sell_highest_id = sell_highest->id; + limit_order_id_type sell_highest_id = sell_highest->get_id(); BOOST_CHECK_EQUAL( sell_highest_id(db).for_sale.value, 10000 ); BOOST_CHECK_EQUAL( get_balance( seller2_id, mpa_id ), 20000 ); // 50000 - 10000 - 10000 - 10000 diff --git a/tests/tests/credit_offer_tests.cpp b/tests/tests/credit_offer_tests.cpp index 3df4e4fd10..1c3e0a11aa 100644 --- a/tests/tests/credit_offer_tests.cpp +++ b/tests/tests/credit_offer_tests.cpp @@ -54,14 +54,14 @@ BOOST_AUTO_TEST_CASE( credit_offer_hardfork_time_test ) const asset_object& core = asset_id_type()(db); const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( sam, usd.amount(init_amount) ); // Before the hard fork, unable to create a credit offer or transact against a credit offer or a credit deal, // or do any of them with proposals flat_map collateral_map; collateral_map[usd_id] = price( asset(1), asset(1, usd_id) ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, db.head_block_time() + fc::days(1), collateral_map, {} ), fc::exception ); @@ -75,8 +75,8 @@ BOOST_AUTO_TEST_CASE( credit_offer_hardfork_time_test ) BOOST_CHECK_THROW( repay_credit_deal( sam_id, tmp_cd_id, core.amount(100), core.amount(100) ), fc::exception ); - credit_offer_create_operation cop = make_credit_offer_create_op( sam_id, core.id, 10000, 100, 3600, 0, false, - db.head_block_time() + fc::days(1), collateral_map, {} ); + credit_offer_create_operation cop = make_credit_offer_create_op( sam_id, core.get_id(), 10000, 100, 3600, 0, + false, db.head_block_time() + fc::days(1), collateral_map, {} ); BOOST_CHECK_THROW( propose( cop ), fc::exception ); credit_offer_delete_operation dop = make_credit_offer_delete_op( sam_id, tmp_co_id ); @@ -130,12 +130,12 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( sam, eur.amount(init_amount) ); issue_uia( ted, eur.amount(init_amount) ); // Make a whitelist @@ -177,8 +177,8 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) flat_map collateral_map; collateral_map[usd_id] = price( asset(1), asset(1, usd_id) ); - credit_offer_create_operation cop = make_credit_offer_create_op( sam_id, core.id, 10000, 100, 3600, 0, false, - db.head_block_time() + fc::days(1), collateral_map, {} ); + credit_offer_create_operation cop = make_credit_offer_create_op( sam_id, core.get_id(), 10000, 100, 3600, 0, + false, db.head_block_time() + fc::days(1), collateral_map, {} ); propose( cop ); credit_offer_delete_operation dop = make_credit_offer_delete_op( sam_id, tmp_co_id ); @@ -241,9 +241,9 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) flat_map collateral_map1; collateral_map1[usd_id] = price( asset(1), asset(2, usd_id) ); - const credit_offer_object& coo1 = create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + const credit_offer_object& coo1 = create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, collateral_map1, {} ); - credit_offer_id_type co1_id = coo1.id; + credit_offer_id_type co1_id = coo1.get_id(); BOOST_CHECK( coo1.owner_account == sam_id ); BOOST_CHECK( coo1.asset_type == core.id ); BOOST_CHECK( coo1.total_balance == 10000 ); @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) const credit_offer_object& coo2 = create_credit_offer( ted_id, usd_id, 1, 10000000u, duration2, 10000, true, disable_time2, collateral_map2, borrower_map2 ); - credit_offer_id_type co2_id = coo2.id; + credit_offer_id_type co2_id = coo2.get_id(); BOOST_CHECK( coo2.owner_account == ted_id ); BOOST_CHECK( coo2.asset_type == usd_id ); BOOST_CHECK( coo2.total_balance == 1 ); @@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) const credit_offer_object& coo3 = create_credit_offer( sam_id, eur_id, 10, 1, 30, 1, false, disable_time3, collateral_map3, {} ); // Account is whitelisted - credit_offer_id_type co3_id = coo3.id; + credit_offer_id_type co3_id = coo3.get_id(); BOOST_CHECK( coo3.owner_account == sam_id ); BOOST_CHECK( coo3.asset_type == eur_id ); BOOST_CHECK( coo3.total_balance == 10 ); @@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) invalid_borrower_map2_3[no_account_id] = 1; // account does not exist // Non-positive balance - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 0, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 0, 100, 3600, 0, false, disable_time1, collateral_map1, {} ), fc::exception ); BOOST_CHECK_THROW( create_credit_offer( ted_id, usd_id, -1, 10000000u, duration2, 10000, true, @@ -373,15 +373,15 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) disable_time2, collateral_map2, borrower_map2 ), fc::exception ); // Negative minimum deal amount - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, -1, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, -1, false, disable_time1, collateral_map1, {} ), fc::exception ); // Too big minimum deal amount - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, GRAPHENE_MAX_SHARE_SUPPLY + 1, false, - disable_time1, collateral_map1, {} ), + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, GRAPHENE_MAX_SHARE_SUPPLY + 1, + false, disable_time1, collateral_map1, {} ), fc::exception ); // Auto-disable time in the past and the offer is enabled - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, true, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, true, disable_time1, collateral_map1, {} ), fc::exception ); // Auto-disable time too late @@ -389,29 +389,29 @@ BOOST_AUTO_TEST_CASE( credit_offer_crud_and_proposal_test ) too_late_disable_time, collateral_map2, borrower_map2 ), fc::exception ); // Empty allowed collateral map - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, empty_collateral_map, {} ), fc::exception ); // Invalid allowed collateral map - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_1, {} ), fc::exception ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_2, {} ), fc::exception ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_3, {} ), fc::exception ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_4, {} ), fc::exception ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_5, {} ), fc::exception ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_6, {} ), fc::exception ); - BOOST_CHECK_THROW( create_credit_offer( sam_id, core.id, 10000, 100, 3600, 0, false, + BOOST_CHECK_THROW( create_credit_offer( sam_id, core.get_id(), 10000, 100, 3600, 0, false, disable_time1, invalid_collateral_map1_7, {} ), fc::exception ); // Invalid acceptable borrowers map @@ -693,19 +693,19 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD", ted, white_list ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( ray, usd.amount(init_amount) ); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( ray, eur.amount(init_amount) ); issue_uia( sam, eur.amount(init_amount) ); issue_uia( ted, eur.amount(init_amount) ); const asset_object& cny = create_user_issued_asset( "MYCNY" ); - asset_id_type cny_id = cny.id; + asset_id_type cny_id = cny.get_id(); issue_uia( ray, cny.amount(init_amount) ); issue_uia( sam, cny.amount(init_amount) ); issue_uia( ted, cny.amount(init_amount) ); @@ -813,9 +813,9 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) collateral_map1[usd_id] = price( asset(1), asset(2, usd_id) ); collateral_map1[eur_id] = price( asset(1), asset(1, eur_id) ); - const credit_offer_object& coo1 = create_credit_offer( sam_id, core.id, 10000, 30000, 3600, 0, false, + const credit_offer_object& coo1 = create_credit_offer( sam_id, core.get_id(), 10000, 30000, 3600, 0, false, disable_time1, collateral_map1, {} ); - credit_offer_id_type co1_id = coo1.id; + credit_offer_id_type co1_id = coo1.get_id(); BOOST_CHECK( co1_id(db).owner_account == sam_id ); BOOST_CHECK( co1_id(db).asset_type == core.id ); BOOST_CHECK( co1_id(db).total_balance == 10000 ); @@ -842,7 +842,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Now able to borrow BOOST_TEST_MESSAGE( "Ray borrows" ); const credit_deal_object& cdo11 = borrow_from_credit_offer( ray_id, co1_id, asset(100), asset(200, usd_id) ); - credit_deal_id_type cd11_id = cdo11.id; + credit_deal_id_type cd11_id = cdo11.get_id(); time_point_sec expected_repay_time11 = db.head_block_time() + fc::seconds(3600); // 60 minutes after init BOOST_CHECK( cd11_id(db).borrower == ray_id ); @@ -916,7 +916,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) BOOST_TEST_MESSAGE( "Ray borrows more" ); const credit_deal_object& cdo12 = borrow_from_credit_offer( ray_id, co1_id, asset(100), asset(200, usd_id), ok_fee_rate, ok_duration ); - credit_deal_id_type cd12_id = cdo12.id; + credit_deal_id_type cd12_id = cdo12.get_id(); time_point_sec expected_repay_time12 = db.head_block_time() + fc::seconds(3600); // 60 minutes after init BOOST_CHECK( cd12_id(db).borrower == ray_id ); @@ -943,7 +943,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Able to borrow the same amount with more collateral BOOST_TEST_MESSAGE( "Ray borrows even more" ); const credit_deal_object& cdo13 = borrow_from_credit_offer( ray_id, co1_id, asset(100), asset(499, usd_id) ); - credit_deal_id_type cd13_id = cdo13.id; + credit_deal_id_type cd13_id = cdo13.get_id(); time_point_sec expected_repay_time13 = db.head_block_time() + fc::seconds(3600); // 65 minutes after init BOOST_CHECK( cd13_id(db).borrower == ray_id ); @@ -998,7 +998,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Ted is now able to borrow with CNY const credit_deal_object& cdo14 = borrow_from_credit_offer( ted_id, co1_id, asset(200), asset(200, cny_id) ); - credit_deal_id_type cd14_id = cdo14.id; + credit_deal_id_type cd14_id = cdo14.get_id(); time_point_sec expected_repay_time14 = db.head_block_time() + fc::seconds(600); // 15 minutes after init BOOST_CHECK( cd14_id(db).borrower == ted_id ); @@ -1027,7 +1027,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Ted is able to borrow less with CNY const credit_deal_object& cdo15 = borrow_from_credit_offer( ted_id, co1_id, asset(50), asset(100, cny_id) ); - credit_deal_id_type cd15_id = cdo15.id; + credit_deal_id_type cd15_id = cdo15.get_id(); time_point_sec expected_repay_time15 = db.head_block_time() + fc::seconds(600); // 15 minutes after init BOOST_CHECK( cd15_id(db).borrower == ted_id ); @@ -1076,7 +1076,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Now Ted is able to borrow 40 CORE with EUR const credit_deal_object& cdo16 = borrow_from_credit_offer( ted_id, co1_id, asset(40), asset(499, eur_id) ); - credit_deal_id_type cd16_id = cdo16.id; + credit_deal_id_type cd16_id = cdo16.get_id(); time_point_sec expected_repay_time16 = db.head_block_time() + fc::seconds(600); // 18 minutes after init BOOST_CHECK( cd16_id(db).borrower == ted_id ); @@ -1135,7 +1135,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) BOOST_REQUIRE( result.updated_objects.valid() ); BOOST_CHECK( result.updated_objects->size() == 2 ); - BOOST_CHECK( *result.updated_objects == flat_set({ co1_id, cd13_id }) ); + BOOST_CHECK( *result.updated_objects == flat_set({ co1_id(db).id, cd13_id(db).id }) ); BOOST_CHECK( !result.removed_objects.valid() ); @@ -1162,7 +1162,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Ted is able to borrow 2 CORE with EUR const credit_deal_object& cdo17 = borrow_from_credit_offer( ted_id, co1_id, asset(2), asset(49, eur_id) ); - credit_deal_id_type cd17_id = cdo17.id; + credit_deal_id_type cd17_id = cdo17.get_id(); time_point_sec expected_repay_time17 = db.head_block_time() + fc::seconds(600); // 22 minutes after init BOOST_CHECK( cd17_id(db).borrower == ted_id ); @@ -1192,7 +1192,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) BOOST_REQUIRE( result.updated_objects.valid() ); BOOST_CHECK( result.updated_objects->size() == 2 ); - BOOST_CHECK( *result.updated_objects == flat_set({ co1_id, cd13_id }) ); + BOOST_CHECK( *result.updated_objects == flat_set({ co1_id(db).id, cd13_id(db).id }) ); BOOST_CHECK( !result.removed_objects.valid() ); @@ -1269,7 +1269,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) collateral_map2[eur_id] = price( asset(10, usd_id), asset(10, eur_id) ); const credit_offer_object& coo2 = create_credit_offer( sam_id, usd_id, 10000, 70000, 1800, 0, true, disable_time2, collateral_map2, {} ); - credit_offer_id_type co2_id = coo2.id; + credit_offer_id_type co2_id = coo2.get_id(); BOOST_CHECK( co2_id(db).owner_account == sam_id ); BOOST_CHECK( co2_id(db).asset_type == usd_id ); BOOST_CHECK( co2_id(db).total_balance == 10000 ); @@ -1287,7 +1287,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Ray borrows from the new credit offer const auto& cdo21 = borrow_from_credit_offer( ray_id, co2_id, asset(1000, usd_id), asset(1200, cny_id) ); - credit_deal_id_type cd21_id = cdo21.id; + credit_deal_id_type cd21_id = cdo21.get_id(); time_point_sec expected_repay_time21 = db.head_block_time() + fc::seconds(1800); // 42 minutes after init BOOST_CHECK( cd21_id(db).borrower == ray_id ); @@ -1317,7 +1317,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) BOOST_REQUIRE( result.updated_objects.valid() ); BOOST_CHECK( result.updated_objects->size() == 2 ); - BOOST_CHECK( *result.updated_objects == flat_set({ co2_id, cd21_id }) ); + BOOST_CHECK( *result.updated_objects == flat_set({ co2_id(db).id, cd21_id(db).id }) ); BOOST_CHECK( !result.removed_objects.valid() ); @@ -1371,7 +1371,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) BOOST_REQUIRE( result.updated_objects.valid() ); BOOST_CHECK( result.updated_objects->size() == 2 ); - BOOST_CHECK( *result.updated_objects == flat_set({ co1_id, cd13_id }) ); + BOOST_CHECK( *result.updated_objects == flat_set({ co1_id(db).id, cd13_id(db).id }) ); BOOST_CHECK( !result.removed_objects.valid() ); @@ -1428,7 +1428,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Ted borrows from the new credit offer const auto& cdo22 = borrow_from_credit_offer( ted_id, co2_id, asset(1000, usd_id), asset(1100, eur_id) ); - credit_deal_id_type cd22_id = cdo22.id; + credit_deal_id_type cd22_id = cdo22.get_id(); time_point_sec expected_repay_time22 = db.head_block_time() + fc::seconds(1800); // 43 minutes after init BOOST_CHECK( cd22_id(db).borrower == ted_id ); @@ -1458,7 +1458,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) BOOST_REQUIRE( result.updated_objects.valid() ); BOOST_CHECK( result.updated_objects->size() == 2 ); - BOOST_CHECK( *result.updated_objects == flat_set({ co2_id, cd22_id }) ); + BOOST_CHECK( *result.updated_objects == flat_set({ co2_id(db).id, cd22_id(db).id }) ); BOOST_CHECK( !result.removed_objects.valid() ); @@ -1572,7 +1572,7 @@ BOOST_AUTO_TEST_CASE( credit_offer_borrow_repay_test ) // Ted borrows more const credit_deal_object& cdo18 = borrow_from_credit_offer( ted_id, co1_id, asset(10), asset(30, eur_id) ); - credit_deal_id_type cd18_id = cdo18.id; + credit_deal_id_type cd18_id = cdo18.get_id(); time_point_sec expected_repay_time18 = db.head_block_time() + fc::seconds(600); // 28 minutes after init BOOST_CHECK( cd18_id(db).borrower == ted_id ); @@ -1790,14 +1790,14 @@ BOOST_AUTO_TEST_CASE( credit_offer_apis_test ) asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( bob, usd.amount(init_amount) ); issue_uia( ray, usd.amount(init_amount) ); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( bob, eur.amount(init_amount) ); issue_uia( ray, eur.amount(init_amount) ); issue_uia( sam, eur.amount(init_amount) ); @@ -1816,27 +1816,27 @@ BOOST_AUTO_TEST_CASE( credit_offer_apis_test ) const credit_offer_object& coo1 = create_credit_offer( sam_id, core_id, 10000, 30000, 3600, 0, true, db.head_block_time() + fc::days(1), collateral_map_core, {} ); - credit_offer_id_type co1_id = coo1.id; + credit_offer_id_type co1_id = coo1.get_id(); const credit_offer_object& coo2 = create_credit_offer( ted_id, usd_id, 10000, 30000, 3600, 0, true, db.head_block_time() + fc::days(1), collateral_map_usd, {} ); - credit_offer_id_type co2_id = coo2.id; + credit_offer_id_type co2_id = coo2.get_id(); const credit_offer_object& coo3 = create_credit_offer( sam_id, eur_id, 10000, 30000, 3600, 0, true, db.head_block_time() + fc::days(1), collateral_map_eur, {} ); - credit_offer_id_type co3_id = coo3.id; + credit_offer_id_type co3_id = coo3.get_id(); const credit_offer_object& coo4 = create_credit_offer( sam_id, eur_id, 10000, 30000, 3600, 0, true, db.head_block_time() + fc::days(1), collateral_map_eur, {} ); - credit_offer_id_type co4_id = coo4.id; + credit_offer_id_type co4_id = coo4.get_id(); const credit_offer_object& coo5 = create_credit_offer( sam_id, usd_id, 10000, 30000, 3600, 0, true, db.head_block_time() + fc::days(1), collateral_map_usd, {} ); - credit_offer_id_type co5_id = coo5.id; + credit_offer_id_type co5_id = coo5.get_id(); const credit_offer_object& coo6 = create_credit_offer( ted_id, usd_id, 10000, 30000, 3600, 0, true, db.head_block_time() + fc::days(1), collateral_map_usd, {} ); - credit_offer_id_type co6_id = coo6.id; + credit_offer_id_type co6_id = coo6.get_id(); generate_block(); @@ -1927,29 +1927,29 @@ BOOST_AUTO_TEST_CASE( credit_offer_apis_test ) // Create credit deals // Offer owner : sam const credit_deal_object& cdo11 = borrow_from_credit_offer( ray_id, co1_id, asset(100), asset(200, usd_id) ); - credit_deal_id_type cd11_id = cdo11.id; + credit_deal_id_type cd11_id = cdo11.get_id(); // Offer owner : sam const credit_deal_object& cdo12 = borrow_from_credit_offer( ray_id, co1_id, asset(150), asset(400, eur_id) ); - credit_deal_id_type cd12_id = cdo12.id; + credit_deal_id_type cd12_id = cdo12.get_id(); // Offer owner : sam const credit_deal_object& cdo13 = borrow_from_credit_offer( bob_id, co1_id, asset(200), asset(600, eur_id) ); - credit_deal_id_type cd13_id = cdo13.id; + credit_deal_id_type cd13_id = cdo13.get_id(); // Offer owner : ted const credit_deal_object& cdo21 = borrow_from_credit_offer( bob_id, co2_id, asset(500, usd_id), asset(500, eur_id) ); - credit_deal_id_type cd21_id = cdo21.id; + credit_deal_id_type cd21_id = cdo21.get_id(); // Offer owner : sam const credit_deal_object& cdo31 = borrow_from_credit_offer( bob_id, co3_id, asset(500, eur_id), asset(5000) ); - credit_deal_id_type cd31_id = cdo31.id; + credit_deal_id_type cd31_id = cdo31.get_id(); // Offer owner : sam const credit_deal_object& cdo51 = borrow_from_credit_offer( ray_id, co5_id, asset(400, usd_id), asset(800, eur_id) ); - credit_deal_id_type cd51_id = cdo51.id; + credit_deal_id_type cd51_id = cdo51.get_id(); generate_block(); diff --git a/tests/tests/custom_authority_tests.cpp b/tests/tests/custom_authority_tests.cpp index fc0867434e..278fc1debd 100644 --- a/tests/tests/custom_authority_tests.cpp +++ b/tests/tests/custom_authority_tests.cpp @@ -729,7 +729,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { PUSH_TX(db, trx); custom_authority_id_type auth_id = - db.get_index_type().indices().get().find(alice_id)->id; + db.get_index_type().indices().get().find(alice_id)->get_id(); ////// // Bob attempts to transfer 99 CORE from Alice's account @@ -915,7 +915,8 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { PUSH_TX(db, trx); custom_authority_id_type ca_bob_transfers_from_alice_to_charlie = - db.get_index_type().indices().get().find(alice_id)->id; + db.get_index_type().indices().get().find(alice_id) + ->get_id(); ////// // Bob attempts to transfer 100 CORE from Alice's account to Charlie @@ -996,8 +997,8 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { auto iter = ca_alice_range.first; custom_authority_id_type *ca_charlie_transfers_from_alice_to_diana = nullptr; while (iter != ca_index.end()) { - custom_authority_id_type ca_id = iter->id; - const custom_authority_object *ca = db.find(ca_id); + custom_authority_id_type ca_id = iter->get_id(); + const custom_authority_object *ca = db.find(ca_id); flat_map ca_authorities = ca->auth.account_auths; BOOST_CHECK_EQUAL(1, ca_authorities.size()); if (ca_authorities.find(charlie.get_id()) != ca_authorities.end()) { @@ -1124,7 +1125,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { generate_blocks(1); const auto& bitusd = *db.get_index_type().indices().get().find("USDBIT"); const auto &core = asset_id_type()(db); - update_feed_producers(bitusd, {feedproducer.id}); + update_feed_producers(bitusd, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1180,7 +1181,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { auto caa = db.get_index_type().indices().get().find(alice.get_id()); - custom_authority_id_type auth_id = caa->id; + custom_authority_id_type auth_id = caa->get_id(); custom_authority_create_operation authorize_limit_order_cancellations; authorize_limit_order_cancellations.account = alice.get_id(); @@ -1364,11 +1365,11 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // assetissuer issues A1, B1, and C1 to alice asset_issue_operation issue_a1_to_alice_op - = issue_amount_to(assetissuer.get_id(), asset(1000, acoin1.id), alice.get_id()); + = issue_amount_to(assetissuer.get_id(), asset(1000, acoin1.get_id()), alice.get_id()); asset_issue_operation issue_b1_to_alice_op - = issue_amount_to(assetissuer.get_id(), asset(2000, bcoin1.id), alice.get_id()); + = issue_amount_to(assetissuer.get_id(), asset(2000, bcoin1.get_id()), alice.get_id()); asset_issue_operation issue_c1_to_alice_op - = issue_amount_to(assetissuer.get_id(), asset(2000, ccoin1.id), alice.get_id()); + = issue_amount_to(assetissuer.get_id(), asset(2000, ccoin1.get_id()), alice.get_id()); trx.clear(); trx.operations = {issue_a1_to_alice_op, issue_b1_to_alice_op, issue_c1_to_alice_op}; sign(trx, assetissuer_private_key); @@ -1414,9 +1415,9 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Define the two set of assets: ACOINs and BCOINs restriction is_acoin_rx = restriction(asset_id_index, FUNC(in), - flat_set{acoin1.id}); + flat_set{acoin1.get_id()}); restriction is_bcoin_rx = restriction(asset_id_index, FUNC(in), - flat_set{bcoin1.id, bcoin2.id, bcoin3.id}); + flat_set{bcoin1.get_id(), bcoin2.get_id(), bcoin3.get_id()}); // Custom Authority 1: Sell ACOINs to buy BCOINs restriction sell_acoin_rx = restriction(amount_to_sell_index, FUNC(attr), vector{is_acoin_rx}); @@ -1773,7 +1774,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { generate_blocks(1); const auto& bitusd = *db.get_index_type().indices().get().find("USDBIT"); const auto &core = asset_id_type()(db); - update_feed_producers(bitusd, {feedproducer.id}); + update_feed_producers(bitusd, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1827,7 +1828,8 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { PUSH_TX(db, trx); custom_authority_id_type auth_id = - db.get_index_type().indices().get().find(feedproducer.id)->id; + db.get_index_type().indices().get().find(feedproducer.get_id()) + ->get_id(); ////// // Bob attempts to publish feed of USDBIT on behalf of feedproducer @@ -1945,7 +1947,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ACTORS((feedproducer)); const auto &bitusd = create_bitasset("USDBIT", feedproducer_id); const auto &core = asset_id_type()(db); - update_feed_producers(bitusd, {feedproducer.id}); + update_feed_producers(bitusd, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -2201,7 +2203,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { generate_blocks(1); const asset_object &alicecoin = *db.get_index_type().indices().get().find("ALICECOIN"); const asset_object &specialcoin = *db.get_index_type().indices().get().find("SPECIALCOIN"); - const asset_id_type alicecoin_id = alicecoin.id; + const asset_id_type alicecoin_id = alicecoin.get_id(); ////// @@ -2304,7 +2306,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to issue the special coin to an allowed account // This should fail because Bob is not authorized to issue SPECIALCOIN to any account ////// - issue_op = issue_amount_to(alice.get_id(), asset(100, specialcoin.id), allowed3.get_id()); + issue_op = issue_amount_to(alice.get_id(), asset(100, specialcoin.get_id()), allowed3.get_id()); trx.clear(); trx.operations = {issue_op}; sign(trx, bob_private_key); @@ -2385,7 +2387,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { generate_blocks(1); const asset_object &alicecoin = *db.get_index_type().indices().get().find("ALICECOIN"); const asset_object &specialcoin = *db.get_index_type().indices().get().find("SPECIALCOIN"); - const asset_id_type alicecoin_id = alicecoin.id; + const asset_id_type alicecoin_id = alicecoin.get_id(); ////// @@ -2494,7 +2496,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to issue the special coin to an allowed account // This should fail because Bob is not authorized to issue SPECIALCOIN to any account ////// - issue_op = issue_amount_to(alice.get_id(), asset(100, specialcoin.id), allowed3.get_id()); + issue_op = issue_amount_to(alice.get_id(), asset(100, specialcoin.get_id()), allowed3.get_id()); trx.clear(); trx.operations = {issue_op}; sign(trx, bob_private_key); @@ -2511,7 +2513,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to issue the UIA to a banned account with the Bob's key // This should fail because Bob is not authorized to issue ALICECOIN to banned account (banned1) ////// - issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.id), banned1.get_id()); + issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.get_id()), banned1.get_id()); trx.clear(); trx.operations = {issue_op}; sign(trx, bob_private_key); @@ -2527,7 +2529,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to issue the UIA to a banned account with the Bob's key // This should fail because Bob is not authorized to issue ALICECOIN to banned account (banned2) ////// - issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.id), banned2.get_id()); + issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.get_id()), banned2.get_id()); trx.clear(); trx.operations = {issue_op}; sign(trx, bob_private_key); @@ -2543,7 +2545,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to issue the UIA to a banned account with the Bob's key // This should fail because Bob is not authorized to issue ALICECOIN to banned account (banned3) ////// - issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.id), banned3.get_id()); + issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.get_id()), banned3.get_id()); trx.clear(); trx.operations = {issue_op}; sign(trx, bob_private_key); @@ -2559,7 +2561,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to issue the UIA to an allowed account // This should succeed because Bob is authorized to issue ALICECOIN to any account ////// - issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.id), allowed3.get_id()); + issue_op = issue_amount_to(alice.get_id(), asset(100, alicecoin.get_id()), allowed3.get_id()); trx.clear(); trx.operations = {issue_op}; sign(trx, bob_private_key); @@ -2633,26 +2635,26 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Initialize: Alice issues her two coins to different accounts ////// asset_issue_operation issue_alice_to_allowed1_op - = issue_amount_to(alice.get_id(), asset(100, alicecoin.id), allowed1.get_id()); + = issue_amount_to(alice.get_id(), asset(100, alicecoin.get_id()), allowed1.get_id()); asset_issue_operation issue_alice_to_allowed2_op - = issue_amount_to(alice.get_id(), asset(200, alicecoin.id), allowed2.get_id()); + = issue_amount_to(alice.get_id(), asset(200, alicecoin.get_id()), allowed2.get_id()); asset_issue_operation issue_alice_to_allowed3_op - = issue_amount_to(alice.get_id(), asset(300, alicecoin.id), allowed3.get_id()); + = issue_amount_to(alice.get_id(), asset(300, alicecoin.get_id()), allowed3.get_id()); asset_issue_operation issue_alice_to_suspicious1_op - = issue_amount_to(alice.get_id(), asset(100, alicecoin.id), suspicious1.get_id()); + = issue_amount_to(alice.get_id(), asset(100, alicecoin.get_id()), suspicious1.get_id()); asset_issue_operation issue_alice_to_suspicious2_op - = issue_amount_to(alice.get_id(), asset(200, alicecoin.id), suspicious2.get_id()); + = issue_amount_to(alice.get_id(), asset(200, alicecoin.get_id()), suspicious2.get_id()); asset_issue_operation issue_special_to_allowed1_op - = issue_amount_to(alice.get_id(), asset(1000, specialcoin.id), allowed1.get_id()); + = issue_amount_to(alice.get_id(), asset(1000, specialcoin.get_id()), allowed1.get_id()); asset_issue_operation issue_special_to_allowed2_op - = issue_amount_to(alice.get_id(), asset(2000, specialcoin.id), allowed2.get_id()); + = issue_amount_to(alice.get_id(), asset(2000, specialcoin.get_id()), allowed2.get_id()); asset_issue_operation issue_special_to_allowed3_op - = issue_amount_to(alice.get_id(), asset(3000, specialcoin.id), allowed3.get_id()); + = issue_amount_to(alice.get_id(), asset(3000, specialcoin.get_id()), allowed3.get_id()); asset_issue_operation issue_special_to_suspicious1_op - = issue_amount_to(alice.get_id(), asset(1000, specialcoin.id), suspicious1.get_id()); + = issue_amount_to(alice.get_id(), asset(1000, specialcoin.get_id()), suspicious1.get_id()); asset_issue_operation issue_special_to_suspicious2_op - = issue_amount_to(alice.get_id(), asset(2000, specialcoin.id), suspicious2.get_id()); + = issue_amount_to(alice.get_id(), asset(2000, specialcoin.get_id()), suspicious2.get_id()); trx.clear(); trx.operations = {issue_alice_to_allowed1_op, issue_alice_to_allowed2_op, issue_alice_to_allowed3_op, issue_alice_to_suspicious1_op, issue_alice_to_suspicious2_op, @@ -2667,7 +2669,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should succeed because Alice is the issuer ////// override_transfer_operation override_op - = create_override(alice.get_id(), allowed1.get_id(), asset(20, alicecoin.id), arbitrator.get_id()); + = create_override(alice.get_id(), allowed1.get_id(), asset(20, alicecoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, alice_private_key); @@ -2676,7 +2678,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { BOOST_CHECK_EQUAL(allowed1_balance_alicecoin_after_override1, 80); override_op - = create_override(alice.get_id(), suspicious1.get_id(), asset(20, alicecoin.id), arbitrator.get_id()); + = create_override(alice.get_id(), suspicious1.get_id(), asset(20, alicecoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, alice_private_key); @@ -2686,21 +2688,21 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { BOOST_CHECK_EQUAL(suspicious1_balance_alicecoin_after_override1, 80); override_op - = create_override(alice.get_id(), allowed1.get_id(), asset(200, specialcoin.id), arbitrator.get_id()); + = create_override(alice.get_id(), allowed1.get_id(), asset(200, specialcoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, alice_private_key); PUSH_TX(db, trx); - int64_t allowed1_balance_specialcoin_after_override1 = get_balance(allowed1.get_id(), specialcoin.id); + int64_t allowed1_balance_specialcoin_after_override1 = get_balance(allowed1.get_id(), specialcoin.get_id()); BOOST_CHECK_EQUAL(allowed1_balance_specialcoin_after_override1, 800); override_op - = create_override(alice.get_id(), suspicious1.get_id(), asset(200, specialcoin.id), arbitrator.get_id()); + = create_override(alice.get_id(), suspicious1.get_id(), asset(200, specialcoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, alice_private_key); PUSH_TX(db, trx); - int64_t suspicious1_balance_specialcoin_after_override1 = get_balance(suspicious1.get_id(), specialcoin.id); + int64_t suspicious1_balance_specialcoin_after_override1 = get_balance(suspicious1.get_id(), specialcoin.get_id()); BOOST_CHECK_EQUAL(suspicious1_balance_specialcoin_after_override1, 800); @@ -2708,7 +2710,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to override some ALICECOIN and SPECIAL from some accounts // This should fail because Bob is not authorized to override any ALICECOIN nor SPECIALCOIN ////// - override_op = create_override(alice.get_id(), allowed1.get_id(), asset(25, alicecoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), allowed1.get_id(), asset(25, alicecoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, bob_private_key); @@ -2717,7 +2719,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // "rejected_custom_auths":[] EXPECT_EXCEPTION_STRING("\"rejected_custom_auths\":[]", [&] {PUSH_TX(db, trx);}); - override_op = create_override(alice.get_id(), allowed1.get_id(), asset(25, specialcoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), allowed1.get_id(), asset(25, specialcoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, bob_private_key); @@ -2798,7 +2800,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to override transfer some ALICECOIN from a suspicious account // This should succeed because Bob is now authorized to override ALICECOIN from some accounts ////// - override_op = create_override(alice.get_id(), suspicious1.get_id(), asset(25, alicecoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), suspicious1.get_id(), asset(25, alicecoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, bob_private_key); @@ -2812,7 +2814,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to override transfer some SPECIALCOIN from a suspicious account // This should fail because Bob is not authorized to override SPECIALCOIN from any accounts ////// - override_op = create_override(alice.get_id(), suspicious1.get_id(), asset(250, specialcoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), suspicious1.get_id(), asset(250, specialcoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, bob_private_key); @@ -2829,7 +2831,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to override transfer some SPECIALCOIN from an allowed account // This should fail because Bob is not authorized to override SPECIALCOIN from any accounts ////// - override_op = create_override(alice.get_id(), allowed3.get_id(), asset(250, specialcoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), allowed3.get_id(), asset(250, specialcoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, bob_private_key); @@ -2846,7 +2848,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Bob attempts to override transfer some ALICECOIN from an allowed account // This should fail because Bob is only authorized to override ALICECOIN from suspicious accounts ////// - override_op = create_override(alice.get_id(), allowed2.get_id(), asset(20, alicecoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), allowed2.get_id(), asset(20, alicecoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, bob_private_key); @@ -2868,7 +2870,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Alice attempts to override transfer of SPECIAL COIN from an allowed account // This should succeed because Alice has not revoked her own authorities as issuer ////// - override_op = create_override(alice.get_id(), allowed3.get_id(), asset(500, specialcoin.id), arbitrator.get_id()); + override_op = create_override(alice.get_id(), allowed3.get_id(), asset(500, specialcoin.get_id()), arbitrator.get_id()); trx.clear(); trx.operations = {override_op}; sign(trx, alice_private_key); @@ -2911,12 +2913,12 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// // Define core asset const auto &core = asset_id_type()(db); - asset_id_type core_id = core.id; + asset_id_type core_id = core.get_id(); // Create a smart asset const asset_object &bitusd = create_bitasset("USDBIT", feedproducer_id); - asset_id_type usd_id = bitusd.id; - update_feed_producers(bitusd, {feedproducer.id}); + asset_id_type usd_id = bitusd.get_id(); + update_feed_producers(bitusd, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; current_feed.maximum_short_squeeze_ratio = 1100; @@ -3650,7 +3652,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// flat_set new_producers = {trusted1.get_id(), trusted2.get_id()}; asset_update_feed_producers_operation producers_op - = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, alice_private_key); @@ -3668,7 +3670,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should fail because Bob is not authorized to update feed producers for ALICECOIN ////// new_producers = {trusted3.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3739,7 +3741,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // when an untrusted account is included ////// new_producers = {trusted4.get_id(), untrusted1.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3757,7 +3759,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // when an untrusted account is included ////// new_producers = {trusted4.get_id(), untrusted1.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3775,7 +3777,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // when an untrusted account is included ////// new_producers = {untrusted2.get_id(), untrusted3.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3847,7 +3849,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// flat_set new_producers = {trusted1.get_id(), trusted2.get_id(), trusted3.get_id()}; asset_update_feed_producers_operation producers_op - = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, alice_private_key); @@ -3866,7 +3868,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should fail because Bob is not authorized to update feed producers for ALICECOIN ////// new_producers = {trusted1.get_id(), trusted2.get_id(), trusted3.get_id(), unknown1.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3936,7 +3938,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should fail not all of the required feed producers are included ////// new_producers = {unknown2.get_id(), unknown3.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3954,7 +3956,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should fail not all of the required feed producers are included ////// new_producers = {trusted1.get_id(), unknown2.get_id(), unknown3.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3972,7 +3974,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should fail not all of the required feed producers are included ////// new_producers = {trusted1.get_id(), unknown2.get_id(), unknown3.get_id(), trusted2.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -3991,7 +3993,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // and because the all of the required feed producers are included ////// new_producers = {trusted1.get_id(), unknown2.get_id(), unknown3.get_id(), trusted2.get_id(), trusted3.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -4004,7 +4006,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // and because the all of the required feed producers are included ////// new_producers = {trusted3.get_id(), trusted2.get_id(), trusted1.get_id()}; - producers_op = create_producers_op(alice.get_id(), alicecoin.id, new_producers); + producers_op = create_producers_op(alice.get_id(), alicecoin.get_id(), new_producers); trx.clear(); trx.operations = {producers_op}; sign(trx, bob_private_key); @@ -4337,7 +4339,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// generate_blocks(1); graphene::chain::htlc_id_type alice_htlc_id = - db.get_index_type().indices().get().find(alice.get_id())->id; + db.get_index_type().indices().get().find(alice.get_id())->get_id(); ////// @@ -4399,7 +4401,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// generate_blocks(1); auto caa = db.get_index_type().indices().get().find(gateway.get_id()); - custom_authority_id_type caa_id = caa->id; + custom_authority_id_type caa_id = caa->get_id(); ////// @@ -4535,7 +4537,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// generate_blocks(1); graphene::chain::htlc_id_type alice_htlc_id = - db.get_index_type().indices().get().find(alice.get_id())->id; + db.get_index_type().indices().get().find(alice.get_id())->get_id(); ////// @@ -4922,8 +4924,8 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// generate_blocks(1); set_expiration(db, trx); - vesting_balance_id_type vesting_balance_id = - db.get_index_type().indices().get().find(alice.get_id())->id; + vesting_balance_id_type vesting_balance_id { + db.get_index_type().indices().get().find(alice.get_id())->id }; ////// @@ -5061,17 +5063,17 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// // Define core asset const auto &core = asset_id_type()(db); - asset_id_type core_id = core.id; + asset_id_type core_id = core.get_id(); // Create a smart asset create_bitasset("USDBIT", feedproducer_id); generate_blocks(1); const asset_object &bitusd = *db.get_index_type().indices().get().find("USDBIT"); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); // Configure the smart asset - update_feed_producers(bitusd, {feedproducer.id}); + update_feed_producers(bitusd, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; current_feed.maximum_short_squeeze_ratio = 1100; @@ -5308,9 +5310,9 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Initialize: assetissuer issues SPECIALCOIN to different accounts ////// asset_issue_operation issue_special_to_alice_op - = issue_amount_to(assetissuer.get_id(), asset(1000, specialcoin.id), alice.get_id()); + = issue_amount_to(assetissuer.get_id(), asset(1000, specialcoin.get_id()), alice.get_id()); asset_issue_operation issue_special_to_charlie_op - = issue_amount_to(assetissuer.get_id(), asset(2000, specialcoin.id), charlie.get_id()); + = issue_amount_to(assetissuer.get_id(), asset(2000, specialcoin.get_id()), charlie.get_id()); trx.clear(); trx.operations = {issue_special_to_alice_op, issue_special_to_charlie_op}; sign(trx, assetissuer_private_key); @@ -5320,24 +5322,24 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// // Alice reserves some SPECIALCOIN from her account ////// - asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.id)); + asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.get_id())); trx.clear(); trx.operations = {reserve_op}; sign(trx, alice_private_key); PUSH_TX(db, trx); - int64_t allowed1_balance_specialcoin_after_override1 = get_balance(alice.get_id(), specialcoin.id); + int64_t allowed1_balance_specialcoin_after_override1 = get_balance(alice.get_id(), specialcoin.get_id()); BOOST_CHECK_EQUAL(allowed1_balance_specialcoin_after_override1, 800); ////// // Charlie reserves some SPECIALCOIN from his account ////// - reserve_op = reserve_asset(charlie.get_id(), asset(200, specialcoin.id)); + reserve_op = reserve_asset(charlie.get_id(), asset(200, specialcoin.get_id())); trx.clear(); trx.operations = {reserve_op}; sign(trx, charlie_private_key); PUSH_TX(db, trx); - int64_t charlie_balance_specialcoin_after_override1 = get_balance(charlie.get_id(), specialcoin.id); + int64_t charlie_balance_specialcoin_after_override1 = get_balance(charlie.get_id(), specialcoin.get_id()); BOOST_CHECK_EQUAL(charlie_balance_specialcoin_after_override1, 1800); @@ -5425,7 +5427,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { ////// generate_blocks(1); const proposal_object& prop = *db.get_index_type().indices().begin(); - proposal_id_type proposal_id = prop.id; + proposal_id_type proposal_id = prop.get_id(); // Alice approves the proposal proposal_update_operation approve_proposal; @@ -5450,7 +5452,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This attempt should fail because Bob the Alice authorization is not yet active ////// { - asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.id)); + asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.get_id())); trx.clear(); trx.operations = {reserve_op}; sign(trx, bob_private_key); @@ -5473,7 +5475,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should succeed because the authorization is active ////// { - asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.id)); + asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.get_id())); trx.clear(); trx.operations = {reserve_op}; sign(trx, bob_private_key); @@ -5493,7 +5495,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should succeed because the authorization is active ////// { - asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.id)); + asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.get_id())); trx.clear(); trx.operations = {reserve_op}; sign(trx, bob_private_key); @@ -5513,7 +5515,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // This should fail because Bob the authorization has expired ////// { - asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.id)); + asset_reserve_operation reserve_op = reserve_asset(alice.get_id(), asset(200, specialcoin.get_id())); trx.clear(); trx.operations = {reserve_op}; sign(trx, bob_private_key); @@ -5789,7 +5791,7 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { auto itr_witnesses = witnesses.begin(); witness_id_type witness0_id = itr_witnesses[0]; const auto& idx = db.get_index_type().indices().get(); - witness_object witness0_obj = *idx.find(witness0_id); + witness_object witness0_obj = *idx.find(object_id_type(witness0_id)); ////// @@ -6132,13 +6134,13 @@ BOOST_AUTO_TEST_CASE(custom_auths) { try { // Create a new witness account (witness0) ACTORS((witness0)); // Upgrade witness account to LTM - upgrade_to_lifetime_member(witness0.id); + upgrade_to_lifetime_member(witness0.get_id()); generate_block(); // Create the witnesses // Get the witness0 identifier after a block has been generated // to be sure of using the most up-to-date identifier for the account - const account_id_type witness0_identifier = get_account("witness0").id; + const account_id_type witness0_identifier = get_account("witness0").get_id(); create_witness(witness0_identifier, witness0_private_key); generate_block(); diff --git a/tests/tests/custom_operations.cpp b/tests/tests/custom_operations.cpp index 37dfacc18d..e1a837cc59 100644 --- a/tests/tests/custom_operations.cpp +++ b/tests/tests/custom_operations.cpp @@ -316,7 +316,7 @@ try { BOOST_CHECK_EQUAL(storage_results[1].key, "language"); BOOST_CHECK_EQUAL(storage_results[1].value->as_string(), "en"); - account_storage_id_type storage_id = storage_results[1].id; + account_storage_id_type storage_id { storage_results[1].id }; storage_results = custom_operations_api.get_storage_info({}, "settings", {}, 2, storage_id); BOOST_REQUIRE_EQUAL(storage_results.size(), 2U ); diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index fe2138221d..95f7a88b62 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -148,9 +148,9 @@ BOOST_AUTO_TEST_CASE( get_signatures_non_immediate_owner ) const account_object& nathan = create_account("nathan", nathan_key1.get_public_key() ); const account_object& ashley = create_account("ashley", ashley_key1.get_public_key() ); const account_object& oliver = create_account("oliver", oliver_key1.get_public_key() ); - account_id_type nathan_id = nathan.id; - account_id_type ashley_id = ashley.id; - account_id_type oliver_id = oliver.id; + account_id_type nathan_id = nathan.get_id(); + account_id_type ashley_id = ashley.get_id(); + account_id_type oliver_id = oliver.get_id(); try { account_update_operation op; @@ -759,8 +759,8 @@ BOOST_AUTO_TEST_CASE( get_required_signatures_partially_signed_or_not ) } BOOST_AUTO_TEST_CASE( subscription_key_collision_test ) -{ - object_id_type uia_object_id = create_user_issued_asset( "UIATEST" ).get_id(); +{ try { + object_id_type uia_object_id = create_user_issued_asset( "UIATEST" ).id; uint32_t objects_changed = 0; auto callback = [&]( const variant& v ) @@ -773,7 +773,7 @@ BOOST_AUTO_TEST_CASE( subscription_key_collision_test ) // subscribe to an account which has same instance ID as UIATEST vector collision_ids; - collision_ids.push_back( string( object_id_type( account_id_type( uia_object_id ) ) ) ); + collision_ids.push_back( string( object_id_type( account_id_type( uia_object_id.instance() ) ) ) ); db_api.get_accounts( collision_ids ); generate_block(); @@ -789,7 +789,7 @@ BOOST_AUTO_TEST_CASE( subscription_key_collision_test ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread BOOST_CHECK_EQUAL( objects_changed, 0 ); // UIATEST did not change in this block, so no notification -} +} FC_CAPTURE_LOG_AND_RETHROW( (0) ) } BOOST_AUTO_TEST_CASE( subscription_notification_test ) { @@ -901,7 +901,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) #undef SUB_NOTIF_TEST_START_ID_DISABLE_AUTO_SUB vector account_ids; - account_ids.push_back( alice_id ); + account_ids.push_back( alice.id ); db_api1.get_objects( account_ids ); // db_api1 subscribe to Alice db_api11.get_objects( account_ids, true ); // db_api11 subscribe to Alice db_api21.get_objects( account_ids, false ); // db_api21 doesn't subscribe to Alice @@ -1105,7 +1105,7 @@ BOOST_AUTO_TEST_CASE( get_all_workers ) vector results; const auto& worker1 = create_worker( connie_id, 1000, fc::days(10) ); - worker_id_type worker1_id = worker1.id; + worker_id_type worker1_id { worker1.id }; BOOST_REQUIRE_EQUAL( db_api.get_all_workers().size(), 1 ); BOOST_REQUIRE_EQUAL( db_api.get_all_workers(true).size(), 0 ); @@ -1123,7 +1123,7 @@ BOOST_AUTO_TEST_CASE( get_all_workers ) BOOST_CHECK( db_api.get_all_workers(true).front().id == worker1_id ); const auto& worker2 = create_worker( whitney_id, 1000, fc::days(50) ); - worker_id_type worker2_id = worker2.id; + worker_id_type worker2_id { worker2.id }; BOOST_REQUIRE_EQUAL( db_api.get_all_workers().size(), 2 ); BOOST_REQUIRE_EQUAL( db_api.get_all_workers(true).size(), 1 ); @@ -1134,7 +1134,7 @@ BOOST_AUTO_TEST_CASE( get_all_workers ) BOOST_CHECK( db_api.get_all_workers(false).front().id == worker2_id ); const auto& worker3 = create_worker( wolverine_id, 1000, fc::days(100) ); - worker_id_type worker3_id = worker3.id; + worker_id_type worker3_id { worker3.id }; BOOST_REQUIRE_EQUAL( db_api.get_all_workers().size(), 3 ); BOOST_REQUIRE_EQUAL( db_api.get_all_workers(true).size(), 1 ); @@ -1185,13 +1185,13 @@ BOOST_AUTO_TEST_CASE( get_workers_by_account ) vector results; const auto& worker1 = create_worker( connie_id ); - worker_id_type worker1_id = worker1.id; + worker_id_type worker1_id { worker1.id }; const auto& worker2 = create_worker( whitney_id, 1000, fc::days(50) ); - worker_id_type worker2_id = worker2.id; + worker_id_type worker2_id { worker2.id }; const auto& worker3 = create_worker( whitney_id, 1000, fc::days(100) ); - worker_id_type worker3_id = worker3.id; + worker_id_type worker3_id { worker3.id }; BOOST_REQUIRE_EQUAL( db_api.get_workers_by_account("connie").size(), 1 ); BOOST_CHECK( db_api.get_workers_by_account("connie").front().id == worker1_id ); @@ -1290,7 +1290,7 @@ BOOST_AUTO_TEST_CASE(get_limit_orders_by_account) o = results.back(); // Get the No. 101-201 orders - results = db_api.get_limit_orders_by_account( seller.name, {}, o.id ); + results = db_api.get_limit_orders_by_account( seller.name, {}, o.get_id() ); BOOST_CHECK_EQUAL( results.size(), 101 ); for (size_t i = 0 ; i < results.size() - 1 ; ++i) { @@ -1301,7 +1301,7 @@ BOOST_AUTO_TEST_CASE(get_limit_orders_by_account) o = results.back(); // Get the No. 201- orders - results = db_api.get_limit_orders_by_account( seller.name, {}, o.id ); + results = db_api.get_limit_orders_by_account( seller.name, {}, o.get_id() ); BOOST_CHECK_EQUAL( results.size(), 50 ); for (size_t i = 0 ; i < results.size() - 1 ; ++i) { @@ -1311,7 +1311,7 @@ BOOST_AUTO_TEST_CASE(get_limit_orders_by_account) BOOST_CHECK(results.back().sell_price == price(core.amount(100), bitcny.amount(150))); // Get the No. 201-210 orders - results2 = db_api.get_limit_orders_by_account( seller.name, 10, o.id ); + results2 = db_api.get_limit_orders_by_account( seller.name, 10, o.get_id() ); BOOST_CHECK_EQUAL( results2.size(), 10 ); for (size_t i = 0 ; i < results2.size() - 1 ; ++i) { @@ -1322,12 +1322,12 @@ BOOST_AUTO_TEST_CASE(get_limit_orders_by_account) BOOST_CHECK(results2.back().sell_price == price(core.amount(100), bitcny.amount(170))); // Buyer has 70 orders, all IDs are greater than sellers - results = db_api.get_limit_orders_by_account( buyer.name, 90, o.id ); + results = db_api.get_limit_orders_by_account( buyer.name, 90, o.get_id() ); BOOST_CHECK_EQUAL( results.size(), 70 ); o = results.back(); // All seller's order IDs are smaller, so querying with a buyer's ID will get nothing - results = db_api.get_limit_orders_by_account( seller.name, 90, o.id ); + results = db_api.get_limit_orders_by_account( seller.name, 90, o.get_id() ); BOOST_CHECK_EQUAL( results.size(), 0 ); // Watcher has no order @@ -1692,7 +1692,7 @@ BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) try { account_update_operation op; op.account = nathan.id; - op.active = authority(3, nathan_public_key, 1, alice.id, 1, bob.id, 1); + op.active = authority(3, nathan_public_key, 1, alice.get_id(), 1, bob.get_id(), 1); op.owner = *op.active; trx.operations.push_back(op); sign(trx, nathan_private_key); @@ -1764,8 +1764,8 @@ BOOST_AUTO_TEST_CASE( get_call_orders_by_account ) { int64_t init_balance(1000000); transfer(committee_account, caller_id, asset(init_balance)); - update_feed_producers(usd, {feedproducer.id}); - update_feed_producers(cny, {feedproducer.id}); + update_feed_producers(usd, {feedproducer.get_id()}); + update_feed_producers(cny, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1803,13 +1803,13 @@ BOOST_AUTO_TEST_CASE( get_settle_orders_by_account ) { const auto &usd = create_bitasset("USD", creator_id); const auto &core = asset_id_type()(db); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); int64_t init_balance(1000000); transfer(committee_account, settler_id, asset(init_balance)); transfer(committee_account, caller_id, asset(init_balance)); - update_feed_producers(usd, {feedproducer.id}); + update_feed_producers(usd, {feedproducer.get_id()}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1820,7 +1820,7 @@ BOOST_AUTO_TEST_CASE( get_settle_orders_by_account ) { borrow(caller, usd.amount(1000), asset(15000)); generate_block(); - transfer(caller.id, settler.id, asset(200, usd_id)); + transfer(caller.get_id(), settler.get_id(), asset(200, usd_id)); auto result = force_settle( settler, usd_id(db).amount(4)); generate_block(); @@ -1854,11 +1854,11 @@ BOOST_AUTO_TEST_CASE( asset_in_collateral ) BOOST_CHECK_EQUAL( 0, oassets[0]->total_in_collateral->value ); BOOST_CHECK( !oassets[0]->total_backing_collateral.valid() ); - asset_id_type bitusd_id = create_bitasset( "USDBIT", nathan_id, 100, charge_market_fee ).id; + asset_id_type bitusd_id = create_bitasset( "USDBIT", nathan_id, 100, charge_market_fee ).get_id(); update_feed_producers( bitusd_id, { nathan_id } ); - asset_id_type bitdan_id = create_bitasset( "DANBIT", dan_id, 100, charge_market_fee ).id; + asset_id_type bitdan_id = create_bitasset( "DANBIT", dan_id, 100, charge_market_fee ).get_id(); update_feed_producers( bitdan_id, { nathan_id } ); - asset_id_type btc_id = create_bitasset( "BTC", nathan_id, 100, charge_market_fee, 8, bitusd_id ).id; + asset_id_type btc_id = create_bitasset( "BTC", nathan_id, 100, charge_market_fee, 8, bitusd_id ).get_id(); update_feed_producers( btc_id, { nathan_id } ); oassets = db_api.get_assets( { GRAPHENE_SYMBOL, "USDBIT", "DANBIT", "BTC" } ); @@ -1998,9 +1998,9 @@ BOOST_AUTO_TEST_CASE( get_trade_history ) ACTORS((bob)(alice)); const auto& eur = create_user_issued_asset("EUR"); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); const auto& usd = create_user_issued_asset("USD"); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( bob_id, usd.amount(1000000) ); issue_uia( alice_id, eur.amount(1000000) ); diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index dd072fc1d5..955abc095a 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(failed_modify_test) const auto& obj = db.create([](account_balance_object& obj) { obj.owner = account_id_type(123); }); - account_balance_id_type obj_id = obj.id; + account_balance_id_type obj_id { obj.id }; BOOST_CHECK_EQUAL(obj.owner.instance.value, 123u); // Modify dummy object, check that changes stick @@ -86,15 +86,15 @@ BOOST_AUTO_TEST_CASE(failed_modify_test) BOOST_CHECK_THROW(db.modify(obj, [](account_balance_object& obj) { throw 5; }), int); - BOOST_CHECK(db.find_object(obj_id)); + BOOST_CHECK(db.find(obj_id)); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( flat_index_test ) { try { ACTORS((sam)); - const auto& bitusd = create_bitasset("USDBIT", sam.id); - const asset_id_type bitusd_id = bitusd.id; - update_feed_producers(bitusd, {sam.id}); + const auto& bitusd = create_bitasset("USDBIT", sam.get_id()); + const asset_id_type bitusd_id = bitusd.get_id(); + update_feed_producers(bitusd, {sam.get_id()}); price_feed current_feed; current_feed.settlement_price = bitusd.amount(100) / asset(100); publish_feed(bitusd, sam, current_feed); @@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE( flat_index_test ) } // force maintenance - const auto& dynamic_global_props = db.get(dynamic_global_property_id_type()); + const auto& dynamic_global_props = db.get(dynamic_global_property_id_type()); generate_blocks(dynamic_global_props.next_maintenance_time, true); BOOST_CHECK( !(*bitusd_id(db).bitasset_data_id)(db).current_feed.settlement_price.is_null() ); @@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) BOOST_CHECK_THROW( direct.get( account_id_type( 1 ) ), fc::assert_exception ); account_object test_account; - test_account.id = account_id_type(1); + test_account.id = object_id_type( account_id_type(1) ); test_account.name = "account1"; my_accounts.load( fc::raw::pack( test_account ) ); @@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) BOOST_CHECK_EQUAL( test_account.name, direct.get( test_account.id ).name ); // The following assumes that MAX_HOLE = 100 - test_account.id = account_id_type(102); + test_account.id = object_id_type( account_id_type(102) ); test_account.name = "account102"; // highest insert was 1, direct.next is 2 => 102 is highest allowed instance my_accounts.load( fc::raw::pack( test_account ) ); @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) acct.name = "account0"; } ); - test_account.id = account_id_type(50); + test_account.id = object_id_type( account_id_type(50) ); test_account.name = "account50"; my_accounts.load( fc::raw::pack( test_account ) ); @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) }); // direct.next is still 103, so 204 is not allowed - test_account.id = account_id_type(204); + test_account.id = object_id_type( account_id_type(204) ); test_account.name = "account204"; GRAPHENE_REQUIRE_THROW( my_accounts.load( fc::raw::pack( test_account ) ), fc::assert_exception ); // This is actually undefined behaviour. The object has been inserted into @@ -204,7 +204,8 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) uint32_t count = 0; for( uint32_t i = 0; i < 250; i++ ) { - const account_object* aptr = dynamic_cast< const account_object* >( my_accounts.find( account_id_type( i ) ) ); + const account_object* aptr = dynamic_cast< const account_object* >( + my_accounts.find( object_id_type( account_id_type( i ) ) ) ); if( aptr ) { count++; @@ -217,7 +218,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) BOOST_CHECK_EQUAL( count, my_accounts.indices().size() - 1 ); GRAPHENE_REQUIRE_THROW( my_accounts.modify( direct.get( account_id_type( 1 ) ), [] ( object& acct ) { - acct.id = account_id_type(2); + acct.id = object_id_type( account_id_type(2) ); }), fc::assert_exception ); // This is actually undefined behaviour. The object has been modified, but // but the secondary has not updated its representation diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 2f26c2b151..f8d13323c7 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -99,8 +99,10 @@ BOOST_AUTO_TEST_CASE(asset_claim_fees_test) transfer( committee_account, izzy_id, _core(1000000) ); transfer( committee_account, jill_id, _core(1000000) ); - asset_id_type izzycoin_id = create_bitasset( "IZZYCOIN", izzy_id, GRAPHENE_1_PERCENT, charge_market_fee ).id; - asset_id_type jillcoin_id = create_bitasset( "JILLCOIN", jill_id, 2*GRAPHENE_1_PERCENT, charge_market_fee ).id; + asset_id_type izzycoin_id = create_bitasset( "IZZYCOIN", izzy_id, GRAPHENE_1_PERCENT, charge_market_fee ) + .get_id(); + asset_id_type jillcoin_id = create_bitasset( "JILLCOIN", jill_id, 2*GRAPHENE_1_PERCENT, charge_market_fee ) + .get_id(); const share_type izzy_prec = asset::scaled_precision( asset_id_type(izzycoin_id)(db).precision ); const share_type jill_prec = asset::scaled_precision( asset_id_type(jillcoin_id)(db).precision ); @@ -219,9 +221,9 @@ BOOST_AUTO_TEST_CASE(asset_claim_pool_test) const asset_object& alicecoin = create_user_issued_asset( "ALICECOIN", alice, 0 ); const asset_object& aliceusd = create_user_issued_asset( "ALICEUSD", alice, 0 ); - asset_id_type alicecoin_id = alicecoin.id; - asset_id_type aliceusd_id = aliceusd.id; - asset_id_type bobcoin_id = create_user_issued_asset( "BOBCOIN", bob, 0).id; + asset_id_type alicecoin_id = alicecoin.get_id(); + asset_id_type aliceusd_id = aliceusd.get_id(); + asset_id_type bobcoin_id = create_user_issued_asset( "BOBCOIN", bob, 0).get_id(); // prepare users' balance issue_uia( alice, aliceusd.amount( 20000000 ) ); @@ -726,7 +728,7 @@ BOOST_AUTO_TEST_CASE( fee_refund_test ) transfer( account_id_type(), bob_id, asset(bob_b0) ); asset_id_type core_id = asset_id_type(); - asset_id_type usd_id = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee ).id; + asset_id_type usd_id = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee ).get_id(); issue_uia( alice_id, asset( alice_b0, usd_id ) ); issue_uia( bob_id, asset( bob_b0, usd_id ) ); @@ -785,8 +787,8 @@ BOOST_AUTO_TEST_CASE( fee_refund_test ) // Check non-overlapping - limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id) )->id; - limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000) )->id; + limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id) )->get_id(); + limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000) )->get_id(); BOOST_CHECK_EQUAL( get_balance( alice_id, core_id ), alice_b0 - 1000 - order_create_fee ); BOOST_CHECK_EQUAL( get_balance( alice_id, usd_id ), alice_b0 ); @@ -861,7 +863,7 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) asset_id_type core_id = asset_id_type(); const auto& usd_obj = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee ); - asset_id_type usd_id = usd_obj.id; + asset_id_type usd_id = usd_obj.get_id(); issue_uia( alice_id, asset( alice_b0, usd_id ) ); issue_uia( bob_id, asset( bob_b0, usd_id ) ); @@ -951,8 +953,9 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) // Check non-overlapping // Alice creates order // Bob creates order which doesn't match - limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id) )->id; - limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000), exp, cer )->id; + limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id) )->get_id(); + limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000), exp, cer ) + ->get_id(); alice_bc -= order_create_fee; alice_bc -= 1000; @@ -1025,10 +1028,10 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) // Check partial fill const limit_order_object* ao2 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), exp, cer ); - const limit_order_id_type ao2id = ao2->id; + const limit_order_id_type ao2id = ao2->get_id(); const limit_order_object* bo2 = create_sell_order( bob_id, asset(100, usd_id), asset(500) ); - BOOST_CHECK( db.find( ao2id ) != nullptr ); + BOOST_CHECK( db.find( ao2id ) != nullptr ); BOOST_CHECK( bo2 == nullptr ); // data after order created @@ -1098,11 +1101,11 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) const limit_order_object* ao34 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), max_exp, cer ); const limit_order_object* ao35 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), max_exp, cer ); - const limit_order_id_type ao31id = ao31->id; - const limit_order_id_type ao32id = ao32->id; - const limit_order_id_type ao33id = ao33->id; - const limit_order_id_type ao34id = ao34->id; - const limit_order_id_type ao35id = ao35->id; + const limit_order_id_type ao31id = ao31->get_id(); + const limit_order_id_type ao32id = ao32->get_id(); + const limit_order_id_type ao33id = ao33->get_id(); + const limit_order_id_type ao34id = ao34->get_id(); + const limit_order_id_type ao35id = ao35->get_id(); alice_bc -= 1000 * 5; alice_bu -= order_create_fee * 5; @@ -1119,11 +1122,11 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) // Bob creating an order matching multiple Alice's orders const limit_order_object* bo31 = create_sell_order( bob_id, asset(500, usd_id), asset(2500), exp ); - BOOST_CHECK( db.find( ao31id ) == nullptr ); - BOOST_CHECK( db.find( ao32id ) != nullptr ); - BOOST_CHECK( db.find( ao33id ) == nullptr ); - BOOST_CHECK( db.find( ao34id ) != nullptr ); - BOOST_CHECK( db.find( ao35id ) != nullptr ); + BOOST_CHECK( db.find( ao31id ) == nullptr ); + BOOST_CHECK( db.find( ao32id ) != nullptr ); + BOOST_CHECK( db.find( ao33id ) == nullptr ); + BOOST_CHECK( db.find( ao34id ) != nullptr ); + BOOST_CHECK( db.find( ao35id ) != nullptr ); BOOST_CHECK( bo31 == nullptr ); // data after order created @@ -1144,11 +1147,11 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) // Bob creating an order matching multiple Alice's orders const limit_order_object* bo32 = create_sell_order( bob_id, asset(500, usd_id), asset(2500), exp ); - BOOST_CHECK( db.find( ao31id ) == nullptr ); - BOOST_CHECK( db.find( ao32id ) != nullptr ); - BOOST_CHECK( db.find( ao33id ) == nullptr ); - BOOST_CHECK( db.find( ao34id ) == nullptr ); - BOOST_CHECK( db.find( ao35id ) == nullptr ); + BOOST_CHECK( db.find( ao31id ) == nullptr ); + BOOST_CHECK( db.find( ao32id ) != nullptr ); + BOOST_CHECK( db.find( ao33id ) == nullptr ); + BOOST_CHECK( db.find( ao34id ) == nullptr ); + BOOST_CHECK( db.find( ao35id ) == nullptr ); BOOST_CHECK( bo32 != nullptr ); // data after order created @@ -1247,7 +1250,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) asset_id_type core_id = asset_id_type(); const auto& usd_obj = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee ); - asset_id_type usd_id = usd_obj.id; + asset_id_type usd_id = usd_obj.get_id(); issue_uia( alice_id, asset( alice_b0, usd_id ) ); issue_uia( bob_id, asset( bob_b0, usd_id ) ); @@ -1308,16 +1311,17 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // prepare orders BOOST_TEST_MESSAGE( "Creating orders those will never match: ao1, ao2, bo1, bo2 .." ); // ao1: won't expire, won't match, fee in core - limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(100000, usd_id) )->id; + limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(100000, usd_id) )->get_id(); BOOST_CHECK( db.find( ao1_id ) != nullptr ); // ao2: will expire, won't match, fee in core - limit_order_id_type ao2_id = create_sell_order( alice_id, asset(800), asset(100000, usd_id), exp )->id; + limit_order_id_type ao2_id = create_sell_order( alice_id, asset(800), asset(100000, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao2_id ) != nullptr ); // bo1: won't expire, won't match, fee in usd - limit_order_id_type bo1_id = create_sell_order( bob_id, asset(1000, usd_id), asset(100000), max_exp, cer )->id; + limit_order_id_type bo1_id = create_sell_order( bob_id, asset(1000, usd_id), asset(100000), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo1_id ) != nullptr ); // bo2: will expire, won't match, fee in usd - limit_order_id_type bo2_id = create_sell_order( bob_id, asset(800, usd_id), asset(100000), exp, cer )->id; + limit_order_id_type bo2_id = create_sell_order( bob_id, asset(800, usd_id), asset(100000), exp, cer )->get_id(); BOOST_CHECK( db.find( bo2_id ) != nullptr ); alice_bc -= order_create_fee * 2; @@ -1342,7 +1346,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // ao3: won't expire, partially match before hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao3 .." ); - limit_order_id_type ao3_id = create_sell_order( alice_id, asset(900), asset(2700, usd_id) )->id; + limit_order_id_type ao3_id = create_sell_order( alice_id, asset(900), asset(2700, usd_id) )->get_id(); BOOST_CHECK( db.find( ao3_id ) != nullptr ); create_sell_order( bob_id, asset(600, usd_id), asset(200) ); @@ -1363,7 +1367,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // ao4: will expire, will partially match before hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao4 .." ); - limit_order_id_type ao4_id = create_sell_order( alice_id, asset(700), asset(1400, usd_id), exp )->id; + limit_order_id_type ao4_id = create_sell_order( alice_id, asset(700), asset(1400, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao4_id ) != nullptr ); create_sell_order( bob_id, asset(200, usd_id), asset(100) ); @@ -1384,7 +1388,8 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // bo3: won't expire, will partially match before hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo3 .." ); - limit_order_id_type bo3_id = create_sell_order( bob_id, asset(500, usd_id), asset(1500), max_exp, cer )->id; + limit_order_id_type bo3_id = create_sell_order( bob_id, asset(500, usd_id), asset(1500), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo3_id ) != nullptr ); create_sell_order( alice_id, asset(450), asset(150, usd_id) ); @@ -1407,7 +1412,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // bo4: will expire, will partially match before hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo4 .." ); - limit_order_id_type bo4_id = create_sell_order( bob_id, asset(300, usd_id), asset(600), exp, cer )->id; + limit_order_id_type bo4_id = create_sell_order( bob_id, asset(300, usd_id), asset(600), exp, cer )->get_id(); BOOST_CHECK( db.find( bo4_id ) != nullptr ); create_sell_order( alice_id, asset(140), asset(70, usd_id) ); @@ -1430,7 +1435,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // ao5: won't expire, partially match after hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao5 .." ); - limit_order_id_type ao5_id = create_sell_order( alice_id, asset(606), asset(909, usd_id) )->id; + limit_order_id_type ao5_id = create_sell_order( alice_id, asset(606), asset(909, usd_id) )->get_id(); BOOST_CHECK( db.find( ao5_id ) != nullptr ); alice_bc -= order_create_fee; @@ -1446,7 +1451,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // ao6: will expire, partially match after hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao6 .." ); - limit_order_id_type ao6_id = create_sell_order( alice_id, asset(333), asset(444, usd_id), exp2 )->id; + limit_order_id_type ao6_id = create_sell_order( alice_id, asset(333), asset(444, usd_id), exp2 )->get_id(); BOOST_CHECK( db.find( ao6_id ) != nullptr ); alice_bc -= order_create_fee; @@ -1462,7 +1467,8 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // bo5: won't expire, partially match after hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo5 .." ); - limit_order_id_type bo5_id = create_sell_order( bob_id, asset(255, usd_id), asset(408), max_exp, cer )->id; + limit_order_id_type bo5_id = create_sell_order( bob_id, asset(255, usd_id), asset(408), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo5_id ) != nullptr ); bob_bu -= order_create_fee; @@ -1480,7 +1486,7 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) // bo6: will expire, partially match after hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo6 .." ); - limit_order_id_type bo6_id = create_sell_order( bob_id, asset(127, usd_id), asset(127), exp2, cer )->id; + limit_order_id_type bo6_id = create_sell_order( bob_id, asset(127, usd_id), asset(127), exp2, cer )->get_id(); BOOST_CHECK( db.find( bo6_id ) != nullptr ); bob_bu -= order_create_fee; @@ -1751,7 +1757,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) int64_t cer_usd_amount = 3; price tmp_cer( asset( cer_core_amount ), asset( cer_usd_amount, asset_id_type(1) ) ); const auto& usd_obj = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee, tmp_cer ); - asset_id_type usd_id = usd_obj.id; + asset_id_type usd_id = usd_obj.get_id(); issue_uia( alice_id, asset( alice_b0, usd_id ) ); issue_uia( bob_id, asset( bob_b0, usd_id ) ); @@ -1904,7 +1910,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) // Bob creates order which doesn't match BOOST_TEST_MESSAGE( "Creating non-overlapping orders" ); BOOST_TEST_MESSAGE( "Creating ao1" ); - limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id), exp )->id; + limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(1000, usd_id), exp )->get_id(); alice_bc -= order_create_fee; alice_bc -= 1000; @@ -1973,7 +1979,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) BOOST_CHECK_EQUAL( usd_stat->accumulated_fees.value, accum_b ); BOOST_TEST_MESSAGE( "Creating bo1" ); - limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000), exp, cer )->id; + limit_order_id_type bo1_id = create_sell_order( bob_id, asset(500, usd_id), asset(1000), exp, cer ) + ->get_id(); bob_bu -= usd_create_fee; bob_bu -= 500; @@ -2061,10 +2068,10 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) // Check partial fill BOOST_TEST_MESSAGE( "Creating ao2, then be partially filled by bo2" ); const limit_order_object* ao2 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), exp, cer ); - const limit_order_id_type ao2id = ao2->id; + const limit_order_id_type ao2id = ao2->get_id(); const limit_order_object* bo2 = create_sell_order( bob_id, asset(100, usd_id), asset(500) ); - BOOST_CHECK( db.find( ao2id ) != nullptr ); + BOOST_CHECK( db.find( ao2id ) != nullptr ); BOOST_CHECK( bo2 == nullptr ); // data after order created @@ -2140,11 +2147,11 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) const limit_order_object* ao34 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), max_exp, cer ); const limit_order_object* ao35 = create_sell_order( alice_id, asset(1000), asset(200, usd_id), max_exp, cer ); - const limit_order_id_type ao31id = ao31->id; - const limit_order_id_type ao32id = ao32->id; - const limit_order_id_type ao33id = ao33->id; - const limit_order_id_type ao34id = ao34->id; - const limit_order_id_type ao35id = ao35->id; + const limit_order_id_type ao31id = ao31->get_id(); + const limit_order_id_type ao32id = ao32->get_id(); + const limit_order_id_type ao33id = ao33->get_id(); + const limit_order_id_type ao34id = ao34->get_id(); + const limit_order_id_type ao35id = ao35->get_id(); alice_bc -= 1000 * 5; alice_bu -= usd_create_fee * 5; @@ -2162,11 +2169,11 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) BOOST_TEST_MESSAGE( "Creating bo31, completely fill ao31 and ao33, partially fill ao34" ); const limit_order_object* bo31 = create_sell_order( bob_id, asset(500, usd_id), asset(2500), exp ); - BOOST_CHECK( db.find( ao31id ) == nullptr ); - BOOST_CHECK( db.find( ao32id ) != nullptr ); - BOOST_CHECK( db.find( ao33id ) == nullptr ); - BOOST_CHECK( db.find( ao34id ) != nullptr ); - BOOST_CHECK( db.find( ao35id ) != nullptr ); + BOOST_CHECK( db.find( ao31id ) == nullptr ); + BOOST_CHECK( db.find( ao32id ) != nullptr ); + BOOST_CHECK( db.find( ao33id ) == nullptr ); + BOOST_CHECK( db.find( ao34id ) != nullptr ); + BOOST_CHECK( db.find( ao35id ) != nullptr ); BOOST_CHECK( bo31 == nullptr ); // data after order created @@ -2189,11 +2196,11 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) BOOST_TEST_MESSAGE( "Creating bo32, completely fill partially filled ao34 and new ao35, leave on market" ); const limit_order_object* bo32 = create_sell_order( bob_id, asset(500, usd_id), asset(2500), exp ); - BOOST_CHECK( db.find( ao31id ) == nullptr ); - BOOST_CHECK( db.find( ao32id ) != nullptr ); - BOOST_CHECK( db.find( ao33id ) == nullptr ); - BOOST_CHECK( db.find( ao34id ) == nullptr ); - BOOST_CHECK( db.find( ao35id ) == nullptr ); + BOOST_CHECK( db.find( ao31id ) == nullptr ); + BOOST_CHECK( db.find( ao32id ) != nullptr ); + BOOST_CHECK( db.find( ao33id ) == nullptr ); + BOOST_CHECK( db.find( ao34id ) == nullptr ); + BOOST_CHECK( db.find( ao35id ) == nullptr ); BOOST_CHECK( bo32 != nullptr ); // data after order created @@ -2303,7 +2310,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) int64_t cer_usd_amount = 3; price tmp_cer( asset( cer_core_amount ), asset( cer_usd_amount, asset_id_type(1) ) ); const auto& usd_obj = create_user_issued_asset( "IZZYUSD", izzy_id(db), charge_market_fee, tmp_cer ); - asset_id_type usd_id = usd_obj.id; + asset_id_type usd_id = usd_obj.get_id(); issue_uia( alice_id, asset( alice_b0, usd_id ) ); issue_uia( bob_id, asset( bob_b0, usd_id ) ); @@ -2372,16 +2379,18 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // prepare orders BOOST_TEST_MESSAGE( "Creating orders those will never match: ao1, ao2, bo1, bo2 .." ); // ao1: won't expire, won't match, fee in core - limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(100000, usd_id) )->id; + limit_order_id_type ao1_id = create_sell_order( alice_id, asset(1000), asset(100000, usd_id) )->get_id(); BOOST_CHECK( db.find( ao1_id ) != nullptr ); // ao2: will expire, won't match, fee in core - limit_order_id_type ao2_id = create_sell_order( alice_id, asset(800), asset(100000, usd_id), exp )->id; + limit_order_id_type ao2_id = create_sell_order( alice_id, asset(800), asset(100000, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao2_id ) != nullptr ); // bo1: won't expire, won't match, fee in usd - limit_order_id_type bo1_id = create_sell_order( bob_id, asset(1000, usd_id), asset(100000), max_exp, cer )->id; + limit_order_id_type bo1_id = create_sell_order( bob_id, asset(1000, usd_id), asset(100000), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo1_id ) != nullptr ); // bo2: will expire, won't match, fee in usd - limit_order_id_type bo2_id = create_sell_order( bob_id, asset(800, usd_id), asset(100000), exp, cer )->id; + limit_order_id_type bo2_id = create_sell_order( bob_id, asset(800, usd_id), asset(100000), exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo2_id ) != nullptr ); alice_bc -= order_create_fee * 2; @@ -2406,7 +2415,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao3: won't expire, partially match before hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao3 .." ); // 1:30 - limit_order_id_type ao3_id = create_sell_order( alice_id, asset(900), asset(27000, usd_id) )->id; + limit_order_id_type ao3_id = create_sell_order( alice_id, asset(900), asset(27000, usd_id) )->get_id(); BOOST_CHECK( db.find( ao3_id ) != nullptr ); create_sell_order( bob_id, asset(6000, usd_id), asset(200) ); @@ -2427,7 +2436,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao4: will expire, will partially match before hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao4 .." ); // 1:20 - limit_order_id_type ao4_id = create_sell_order( alice_id, asset(700), asset(14000, usd_id), exp )->id; + limit_order_id_type ao4_id = create_sell_order( alice_id, asset(700), asset(14000, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao4_id ) != nullptr ); create_sell_order( bob_id, asset(2000, usd_id), asset(100) ); @@ -2448,7 +2457,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo3: won't expire, will partially match before hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo3 .." ); // 1:30 - limit_order_id_type bo3_id = create_sell_order( bob_id, asset(500, usd_id), asset(15000), max_exp, cer )->id; + limit_order_id_type bo3_id = create_sell_order( bob_id, asset(500, usd_id), asset(15000), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo3_id ) != nullptr ); create_sell_order( alice_id, asset(4500), asset(150, usd_id) ); @@ -2471,7 +2481,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo4: will expire, will partially match before hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo4 .." ); // 1:20 - limit_order_id_type bo4_id = create_sell_order( bob_id, asset(300, usd_id), asset(6000), exp, cer )->id; + limit_order_id_type bo4_id = create_sell_order( bob_id, asset(300, usd_id), asset(6000), exp, cer )->get_id(); BOOST_CHECK( db.find( bo4_id ) != nullptr ); create_sell_order( alice_id, asset(1400), asset(70, usd_id) ); @@ -2495,7 +2505,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao11: won't expire, partially match after hard fork core-604, fee in core BOOST_TEST_MESSAGE( "Creating order ao11 .." ); // 1:18 - limit_order_id_type ao11_id = create_sell_order( alice_id, asset(510), asset(9180, usd_id) )->id; + limit_order_id_type ao11_id = create_sell_order( alice_id, asset(510), asset(9180, usd_id) )->get_id(); BOOST_CHECK( db.find( ao11_id ) != nullptr ); alice_bc -= order_create_fee; @@ -2511,7 +2521,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao12: will expire, partially match after hard fork core-604, fee in core BOOST_TEST_MESSAGE( "Creating order ao12 .." ); // 1:16 - limit_order_id_type ao12_id = create_sell_order( alice_id, asset(256), asset(4096, usd_id), exp2 )->id; + limit_order_id_type ao12_id = create_sell_order( alice_id, asset(256), asset(4096, usd_id), exp2 )->get_id(); BOOST_CHECK( db.find( ao12_id ) != nullptr ); alice_bc -= order_create_fee; @@ -2527,7 +2537,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo11: won't expire, partially match after hard fork core-604, fee in usd BOOST_TEST_MESSAGE( "Creating order bo11 .." ); // 1:18 - limit_order_id_type bo11_id = create_sell_order( bob_id, asset(388, usd_id), asset(6984), max_exp, cer )->id; + limit_order_id_type bo11_id = create_sell_order( bob_id, asset(388, usd_id), asset(6984), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo11_id ) != nullptr ); bob_bu -= usd_create_fee; @@ -2545,7 +2556,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo12: will expire, partially match after hard fork core-604, fee in usd BOOST_TEST_MESSAGE( "Creating order bo12 .." ); // 1:17 - limit_order_id_type bo12_id = create_sell_order( bob_id, asset(213, usd_id), asset(3621), exp2, cer )->id; + limit_order_id_type bo12_id = create_sell_order( bob_id, asset(213, usd_id), asset(3621), exp2, cer ) + ->get_id(); BOOST_CHECK( db.find( bo12_id ) != nullptr ); bob_bu -= usd_create_fee; @@ -2563,7 +2575,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao5: won't expire, partially match after hard fork 445, fee in core BOOST_TEST_MESSAGE( "Creating order ao5 .." ); // 1:15 - limit_order_id_type ao5_id = create_sell_order( alice_id, asset(606), asset(9090, usd_id) )->id; + limit_order_id_type ao5_id = create_sell_order( alice_id, asset(606), asset(9090, usd_id) )->get_id(); BOOST_CHECK( db.find( ao5_id ) != nullptr ); alice_bc -= order_create_fee; @@ -2580,7 +2592,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao6: will expire, partially match after hard fork 445, fee in core if( false ) { // only can have either ao5 or ao6, can't have both BOOST_TEST_MESSAGE( "Creating order ao6 .." ); // 3:40 = 1:13.33333 - limit_order_id_type ao6_id = create_sell_order( alice_id, asset(333), asset(4440, usd_id), exp )->id; + limit_order_id_type ao6_id = create_sell_order( alice_id, asset(333), asset(4440, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao6_id ) != nullptr ); alice_bc -= order_create_fee; @@ -2598,7 +2610,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo5: won't expire, partially match after hard fork 445, fee in usd if( false ) { // only can have either bo5 or bo6, can't have both BOOST_TEST_MESSAGE( "Creating order bo5 .." ); // 1:16 - limit_order_id_type bo5_id = create_sell_order( bob_id, asset(255, usd_id), asset(4080), max_exp, cer )->id; + limit_order_id_type bo5_id = create_sell_order( bob_id, asset(255, usd_id), asset(4080), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo5_id ) != nullptr ); bob_bu -= usd_create_fee; @@ -2617,7 +2630,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo6: will expire, partially match after hard fork 445, fee in usd BOOST_TEST_MESSAGE( "Creating order bo6 .." ); // 1:10 - limit_order_id_type bo6_id = create_sell_order( bob_id, asset(127, usd_id), asset(1270), exp, cer )->id; + limit_order_id_type bo6_id = create_sell_order( bob_id, asset(127, usd_id), asset(1270), exp, cer )->get_id(); BOOST_CHECK( db.find( bo6_id ) != nullptr ); BOOST_CHECK( db.find( bo6_id ) != nullptr ); @@ -2731,16 +2744,18 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // prepare more orders BOOST_TEST_MESSAGE( "Creating more orders those will never match: ao7, ao8, bo7, bo8 .." ); // ~ 1:100 // ao7: won't expire, won't match, fee in core - limit_order_id_type ao7_id = create_sell_order( alice_id, asset(1003), asset(100000, usd_id) )->id; + limit_order_id_type ao7_id = create_sell_order( alice_id, asset(1003), asset(100000, usd_id) )->get_id(); BOOST_CHECK( db.find( ao7_id ) != nullptr ); // ao8: will expire, won't match, fee in core - limit_order_id_type ao8_id = create_sell_order( alice_id, asset(803), asset(100000, usd_id), exp1 )->id; + limit_order_id_type ao8_id = create_sell_order( alice_id, asset(803), asset(100000, usd_id), exp1 )->get_id(); BOOST_CHECK( db.find( ao8_id ) != nullptr ); // bo7: won't expire, won't match, fee in usd - limit_order_id_type bo7_id = create_sell_order( bob_id, asset(1003, usd_id), asset(100000), max_exp, cer )->id; + limit_order_id_type bo7_id = create_sell_order( bob_id, asset(1003, usd_id), asset(100000), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo7_id ) != nullptr ); // bo8: will expire, won't match, fee in usd - limit_order_id_type bo8_id = create_sell_order( bob_id, asset(803, usd_id), asset(100000), exp1, cer )->id; + limit_order_id_type bo8_id = create_sell_order( bob_id, asset(803, usd_id), asset(100000), exp1, cer ) + ->get_id(); BOOST_CHECK( db.find( bo8_id ) != nullptr ); alice_bc -= order_create_fee * 2; @@ -2765,7 +2780,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao9: won't expire, partially match before hard fork core-604, fee in core BOOST_TEST_MESSAGE( "Creating order ao9 .." ); // 1:3 - limit_order_id_type ao9_id = create_sell_order( alice_id, asset(909), asset(2727, usd_id) )->id; + limit_order_id_type ao9_id = create_sell_order( alice_id, asset(909), asset(2727, usd_id) )->get_id(); BOOST_CHECK( db.find( ao9_id ) != nullptr ); create_sell_order( bob_id, asset(606, usd_id), asset(202) ); @@ -2786,7 +2801,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao10: will expire, will partially match before hard fork core-604, fee in core BOOST_TEST_MESSAGE( "Creating order ao10 .." ); // 1:2 - limit_order_id_type ao10_id = create_sell_order( alice_id, asset(707), asset(1414, usd_id), exp )->id; + limit_order_id_type ao10_id = create_sell_order( alice_id, asset(707), asset(1414, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao10_id ) != nullptr ); create_sell_order( bob_id, asset(202, usd_id), asset(101) ); @@ -2807,7 +2822,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo9: won't expire, will partially match before hard fork core-604, fee in usd BOOST_TEST_MESSAGE( "Creating order bo9 .." ); // 1:3 - limit_order_id_type bo9_id = create_sell_order( bob_id, asset(505, usd_id), asset(1515), max_exp, cer )->id; + limit_order_id_type bo9_id = create_sell_order( bob_id, asset(505, usd_id), asset(1515), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo9_id ) != nullptr ); create_sell_order( alice_id, asset(453), asset(151, usd_id) ); @@ -2830,7 +2846,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo10: will expire, will partially match before hard fork core-604, fee in usd BOOST_TEST_MESSAGE( "Creating order bo10 .." ); // 1:2 - limit_order_id_type bo10_id = create_sell_order( bob_id, asset(302, usd_id), asset(604), exp, cer )->id; + limit_order_id_type bo10_id = create_sell_order( bob_id, asset(302, usd_id), asset(604), exp, cer )->get_id(); BOOST_CHECK( db.find( bo10_id ) != nullptr ); create_sell_order( alice_id, asset(142), asset(71, usd_id) ); @@ -2853,7 +2869,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao13: won't expire, partially match after hard fork core-604, fee in core BOOST_TEST_MESSAGE( "Creating order ao13 .." ); // 1:1.5 - limit_order_id_type ao13_id = create_sell_order( alice_id, asset(424), asset(636, usd_id) )->id; + limit_order_id_type ao13_id = create_sell_order( alice_id, asset(424), asset(636, usd_id) )->get_id(); BOOST_CHECK( db.find( ao13_id ) != nullptr ); alice_bc -= order_create_fee; @@ -2869,7 +2885,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // ao14: will expire, partially match after hard fork core-604, fee in core BOOST_TEST_MESSAGE( "Creating order ao14 .." ); // 1:1.2 - limit_order_id_type ao14_id = create_sell_order( alice_id, asset(525), asset(630, usd_id), exp )->id; + limit_order_id_type ao14_id = create_sell_order( alice_id, asset(525), asset(630, usd_id), exp )->get_id(); BOOST_CHECK( db.find( ao14_id ) != nullptr ); alice_bc -= order_create_fee; @@ -2885,7 +2901,8 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo13: won't expire, partially match after hard fork core-604, fee in usd BOOST_TEST_MESSAGE( "Creating order bo13 .." ); // 1:1.5 - limit_order_id_type bo13_id = create_sell_order( bob_id, asset(364, usd_id), asset(546), max_exp, cer )->id; + limit_order_id_type bo13_id = create_sell_order( bob_id, asset(364, usd_id), asset(546), max_exp, cer ) + ->get_id(); BOOST_CHECK( db.find( bo13_id ) != nullptr ); bob_bu -= usd_create_fee; @@ -2903,7 +2920,7 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) // bo14: will expire, partially match after hard fork core-604, fee in usd BOOST_TEST_MESSAGE( "Creating order bo14 .." ); // 1:1.2 - limit_order_id_type bo14_id = create_sell_order( bob_id, asset(365, usd_id), asset(438), exp, cer )->id; + limit_order_id_type bo14_id = create_sell_order( bob_id, asset(365, usd_id), asset(438), exp, cer )->get_id(); BOOST_CHECK( db.find( bo14_id ) != nullptr ); bob_bu -= usd_create_fee; @@ -3435,7 +3452,7 @@ BOOST_AUTO_TEST_CASE( stealth_fba_test ) // Izzy creates STEALTH asset_id_type stealth_id = create_user_issued_asset( "STEALTH", izzy_id(db), - disable_confidential | transfer_restricted | override_authority | white_list | charge_market_fee ).id; + disable_confidential | transfer_restricted | override_authority | white_list | charge_market_fee ).get_id(); /* // this is disabled because it doesn't work, our modify() is probably being overwritten by undo diff --git a/tests/tests/force_settle_fee_tests.cpp b/tests/tests/force_settle_fee_tests.cpp index ea2f732ab5..9d3bc42199 100644 --- a/tests/tests/force_settle_fee_tests.cpp +++ b/tests/tests/force_settle_fee_tests.cpp @@ -175,15 +175,15 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Fund actors uint64_t initial_balance_core = 10000000; - transfer(committee_account, assetowner.id, asset(initial_balance_core)); - transfer(committee_account, feedproducer.id, asset(initial_balance_core)); + transfer(committee_account, assetowner.get_id(), asset(initial_balance_core)); + transfer(committee_account, feedproducer.get_id(), asset(initial_balance_core)); transfer(committee_account, michael_id, asset(initial_balance_core)); - transfer(committee_account, paul.id, asset(initial_balance_core)); + transfer(committee_account, paul.get_id(), asset(initial_balance_core)); // 1. Create assets const uint16_t usd_fso_percent = 5 * GRAPHENE_1_PERCENT; // 5% Force-settlement offset fee % const uint16_t usd_fsf_percent = 3 * GRAPHENE_1_PERCENT; // 3% Force-settlement fee % (BSIP87) - create_smart_asset("USDBIT", assetowner.id, usd_fso_percent, usd_fsf_percent); + create_smart_asset("USDBIT", assetowner.get_id(), usd_fso_percent, usd_fsf_percent); generate_block(); set_expiration(db, trx); @@ -191,8 +191,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const auto &bitusd = get_asset("USDBIT"); const auto &core = asset_id_type()(db); - asset_id_type bitusd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type bitusd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); const int64_t bitusd_unit = asset::scaled_precision(bitusd.precision).value; // 100 satoshi USDBIT in 1 USDBIT // 2. Publish a feed for the smart asset @@ -212,7 +212,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) int64_t michael_initial_core = 8; const call_order_object &call_michael = *borrow(michael, bitusd.amount(michael_initial_usd), core.amount(michael_initial_core)); - call_order_id_type call_michael_id = call_michael.id; + call_order_id_type call_michael_id = call_michael.get_id(); BOOST_CHECK_EQUAL(get_balance(michael, bitusd), michael_initial_usd); BOOST_CHECK_EQUAL(get_balance(michael, core), initial_balance_core - michael_initial_core); @@ -226,7 +226,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) int64_t paul_initial_core = paul_initial_usd * 2 / 20; // 10000 const call_order_object &call_paul = *borrow(paul, bitusd.amount(paul_initial_usd), core.amount(paul_initial_core)); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL(get_balance(paul, bitusd), paul_initial_usd); BOOST_CHECK_EQUAL(get_balance(paul, bitusd), paul_initial_usd); @@ -237,7 +237,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 5. Paul transfers 200 bitUSD to Rachel /////// int64_t rachel_initial_usd = 200 * bitusd_unit; - transfer(paul.id, rachel.id, asset(rachel_initial_usd, bitusd.id)); + transfer(paul.get_id(), rachel.get_id(), asset(rachel_initial_usd, bitusd.get_id())); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); BOOST_CHECK_EQUAL(get_balance(rachel, bitusd), rachel_initial_usd); @@ -252,8 +252,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const int64_t rachel_settle_amount = 20 * bitusd_unit; operation_result result = force_settle(rachel, bitusd.amount(rachel_settle_amount)); - force_settlement_id_type rachel_settle_id = *result.get() - .value.new_objects->begin(); + force_settlement_id_type rachel_settle_id { *result.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL(rachel_settle_id(db).balance.amount.value, rachel_settle_amount); // Check Rachel's balance @@ -420,10 +420,10 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Fund actors uint64_t initial_balance_core = 10000000; - transfer(committee_account, assetowner.id, asset(initial_balance_core)); - transfer(committee_account, feedproducer.id, asset(initial_balance_core)); + transfer(committee_account, assetowner.get_id(), asset(initial_balance_core)); + transfer(committee_account, feedproducer.get_id(), asset(initial_balance_core)); transfer(committee_account, michael_id, asset(initial_balance_core)); - transfer(committee_account, paul.id, asset(initial_balance_core)); + transfer(committee_account, paul.get_id(), asset(initial_balance_core)); /////// // 1. Create assets @@ -433,13 +433,13 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Attempt and fail to create the smart asset with a force-settlement fee % before HARDFORK_CORE_BSIP87_TIME trx.clear(); - REQUIRE_EXCEPTION_WITH_TEXT(create_smart_asset("USDBIT", assetowner.id, usd_fso_percent, usd_fsf_percent_0), + REQUIRE_EXCEPTION_WITH_TEXT(create_smart_asset("USDBIT", assetowner_id, usd_fso_percent, usd_fsf_percent_0), "cannot be set before Hardfork BSIP87"); // Create the smart asset without a force-settlement fee % trx.clear(); - create_smart_asset("USDBIT", assetowner.id, usd_fso_percent); + create_smart_asset("USDBIT", assetowner_id, usd_fso_percent); generate_block(); set_expiration(db, trx); @@ -454,7 +454,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) /////// // 2. Publish a feed for the smart asset /////// - update_feed_producers(bitusd.id, {feedproducer_id}); + update_feed_producers(bitusd.get_id(), {feedproducer_id}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; current_feed.maximum_short_squeeze_ratio = 1100; @@ -472,7 +472,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) int64_t paul_initial_core = paul_initial_usd * 2 * 20; // 400000 const call_order_object &call_paul = *borrow(paul, bitusd.amount(paul_initial_usd), core.amount(paul_initial_core)); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL(get_balance(paul, bitusd), paul_initial_usd); BOOST_CHECK_EQUAL(get_balance(paul, bitusd), paul_initial_usd); @@ -483,7 +483,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 4. Paul gives Rachel 20 bitUSD and retains 80 bitUSD /////// int64_t rachel_initial_usd = 20 * bitusd_unit; - transfer(paul.id, rachel.id, asset(rachel_initial_usd, bitusd.id)); + transfer(paul.get_id(), rachel.get_id(), asset(rachel_initial_usd, bitusd.get_id())); BOOST_CHECK_EQUAL(get_balance(rachel, bitusd), rachel_initial_usd); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); @@ -498,8 +498,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const int64_t rachel_settle_amount = 2 * bitusd_unit; operation_result result = force_settle(rachel, bitusd.amount(rachel_settle_amount)); - force_settlement_id_type rachel_settle_id = *result.get() - .value.new_objects->begin(); + force_settlement_id_type rachel_settle_id { *result.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL(rachel_settle_id(db).balance.amount.value, rachel_settle_amount); // Advance time to complete the force settlement and to update the price feed @@ -581,7 +581,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 8. Paul gives Michael 30 bitUSD and retains 50 bitUSD /////// int64_t michael_initial_usd = 30 * bitusd_unit; - transfer(paul.id, michael.id, asset(michael_initial_usd, bitusd.id)); + transfer(paul.get_id(), michael.get_id(), asset(michael_initial_usd, bitusd.get_id())); // Check Michael's balance BOOST_CHECK_EQUAL(get_balance(michael, bitusd), michael_initial_usd); @@ -598,8 +598,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const int64_t michael_settle_amount = 5 * bitusd_unit; result = force_settle(michael, bitusd.amount(michael_settle_amount)); - force_settlement_id_type michael_settle_id = *result.get() - .value.new_objects->begin(); + force_settlement_id_type michael_settle_id { *result.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL(michael_settle_id(db).balance.amount.value, michael_settle_amount); // Advance time to complete the force settlement and to update the price feed @@ -668,7 +668,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 11. Paul gives Yanna 40 bitUSD and retains 10 bitUSD /////// int64_t yanna_initial_usd = 40 * bitusd_unit; - transfer(paul.id, yanna.id, asset(yanna_initial_usd, bitusd.id)); + transfer(paul.get_id(), yanna.get_id(), asset(yanna_initial_usd, bitusd.get_id())); // Check Yanna's balance BOOST_CHECK_EQUAL(get_balance(yanna, bitusd), yanna_initial_usd); @@ -686,8 +686,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const int64_t yanna_settle_amount = 10 * bitusd_unit; result = force_settle(yanna, bitusd.amount(yanna_settle_amount)); - force_settlement_id_type yanna_settle_id = *result.get() - .value.new_objects->begin(); + force_settlement_id_type yanna_settle_id { *result.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL(yanna_settle_id(db).balance.amount.value, yanna_settle_amount); // Advance time to complete the force settlement and to update the price feed @@ -757,7 +757,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 14. Paul gives Vikram 10 bitUSD and retains 0 bitUSD /////// int64_t vikram_initial_usd = 10 * bitusd_unit; - transfer(paul.id, vikram.id, asset(vikram_initial_usd, bitusd.id)); + transfer(paul.get_id(), vikram.get_id(), asset(vikram_initial_usd, bitusd.get_id())); // Check Yanna's balance BOOST_CHECK_EQUAL(get_balance(vikram, bitusd), vikram_initial_usd); @@ -776,8 +776,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const int64_t vikram_settle_amount = 10 * bitusd_unit; result = force_settle(vikram, bitusd.amount(vikram_settle_amount)); - force_settlement_id_type vikram_settle_id = *result.get() - .value.new_objects->begin(); + force_settlement_id_type vikram_settle_id { *result.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL(vikram_settle_id(db).balance.amount.value, vikram_settle_amount); // Advance time to complete the force settlement and to update the price feed @@ -860,9 +860,9 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) /////// // Rachel, Michael, and Yanna return their remaining bitUSD to Paul trx.clear(); - transfer(rachel.id, paul.id, bitusd.amount(get_balance(rachel, bitusd))); - transfer(michael.id, paul.id, bitusd.amount(get_balance(michael, bitusd))); - transfer(yanna.id, paul.id, bitusd.amount(get_balance(yanna, bitusd))); + transfer(rachel.get_id(), paul.get_id(), bitusd.amount(get_balance(rachel, bitusd))); + transfer(michael.get_id(), paul.get_id(), bitusd.amount(get_balance(michael, bitusd))); + transfer(yanna.get_id(), paul.get_id(), bitusd.amount(get_balance(yanna, bitusd))); // Vikram has no bitUSD to transfer BOOST_CHECK_EQUAL(get_balance(vikram, bitusd), 0); @@ -1059,14 +1059,14 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Fund actors uint64_t initial_balance_core = 10000000; - transfer(committee_account, assetowner.id, asset(initial_balance_core)); - transfer(committee_account, feedproducer.id, asset(initial_balance_core)); - transfer(committee_account, paul.id, asset(initial_balance_core)); + transfer(committee_account, assetowner.get_id(), asset(initial_balance_core)); + transfer(committee_account, feedproducer.get_id(), asset(initial_balance_core)); + transfer(committee_account, paul.get_id(), asset(initial_balance_core)); // 1. Create assets const uint16_t usd_fso_percent = 5 * GRAPHENE_1_PERCENT; // 5% Force-settlement offset fee % const uint16_t usd_fsf_percent = 100 * GRAPHENE_1_PERCENT; // 100% Force-settlement fee % (BSIP87) - create_smart_asset("USDBIT", assetowner.id, usd_fso_percent, usd_fsf_percent); + create_smart_asset("USDBIT", assetowner.get_id(), usd_fso_percent, usd_fsf_percent); generate_block(); set_expiration(db, trx); @@ -1080,7 +1080,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) /////// // 2. Publish a feed for the smart asset /////// - update_feed_producers(bitusd.id, {feedproducer_id}); + update_feed_producers(bitusd.get_id(), {feedproducer_id}); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; current_feed.maximum_short_squeeze_ratio = 1100; @@ -1098,7 +1098,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) int64_t paul_initial_core = paul_initial_usd * 2 * 20; // 400000 const call_order_object &call_paul = *borrow(paul, bitusd.amount(paul_initial_usd), core.amount(paul_initial_core)); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL(get_balance(paul, bitusd), paul_initial_usd); BOOST_CHECK_EQUAL(get_balance(paul, bitusd), paul_initial_usd); @@ -1109,7 +1109,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 4. Paul gives Rachel 20 bitUSD and retains 80 bitUSD /////// int64_t rachel_initial_usd = 20 * bitusd_unit; - transfer(paul.id, rachel.id, asset(rachel_initial_usd, bitusd.id)); + transfer(paul.get_id(), rachel.get_id(), asset(rachel_initial_usd, bitusd.get_id())); BOOST_CHECK_EQUAL(get_balance(rachel, bitusd), rachel_initial_usd); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); @@ -1124,8 +1124,8 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const int64_t rachel_settle_amount = 2 * bitusd_unit; // 200 satoshi bitusd operation_result result = force_settle(rachel, bitusd.amount(rachel_settle_amount)); - force_settlement_id_type rachel_settle_id = *result.get() - .value.new_objects->begin(); + force_settlement_id_type rachel_settle_id { *result.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL(rachel_settle_id(db).balance.amount.value, rachel_settle_amount); // Advance time to complete the force settlement and to update the price feed @@ -1213,7 +1213,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Fund actors uint64_t initial_balance_core = 10000000; - transfer(committee_account, assetowner.id, asset(initial_balance_core)); + transfer(committee_account, assetowner.get_id(), asset(initial_balance_core)); // Confirm before hardfork activation BOOST_CHECK(db.head_block_time() < HARDFORK_CORE_BSIP87_TIME); @@ -1228,7 +1228,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Attempt to create the smart asset with a force-settlement fee % // The attempt should fail because it is before HARDFORK_CORE_BSIP87_TIME trx.clear(); - REQUIRE_EXCEPTION_WITH_TEXT(create_smart_asset("USDBIT", assetowner.id, usd_fso_percent, usd_fsf_percent_0), + REQUIRE_EXCEPTION_WITH_TEXT(create_smart_asset("USDBIT", assetowner_id, usd_fso_percent, usd_fsf_percent_0), "cannot be set before Hardfork BSIP87"); @@ -1236,7 +1236,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 2. Asset owner fails to create the smart coin called bitUSD with a force-settlement fee % in a proposal /////// { - asset_create_operation create_op = create_smart_asset_op("USDBIT", assetowner.id, usd_fso_percent, + asset_create_operation create_op = create_smart_asset_op("USDBIT", assetowner_id, usd_fso_percent, usd_fsf_percent_0); proposal_create_operation cop; cop.review_period_seconds = 86400; @@ -1256,7 +1256,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // 3. Asset owner succeeds to create the smart coin called bitUSD without a force-settlement fee % /////// trx.clear(); - create_smart_asset("USDBIT", assetowner.id, usd_fso_percent); + create_smart_asset("USDBIT", assetowner_id, usd_fso_percent); generate_block(); set_expiration(db, trx); @@ -1356,7 +1356,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) const uint16_t fsf_percent_1 = 1 * GRAPHENE_1_PERCENT; // 1% Force-settlement fee % (BSIP87) const uint16_t fsf_percent_5 = 1 * GRAPHENE_1_PERCENT; // 5% Force-settlement fee % (BSIP87) trx.clear(); - create_smart_asset("CNYBIT", assetowner.id, usd_fso_percent, fsf_percent_1); + create_smart_asset("CNYBIT", assetowner_id, usd_fso_percent, fsf_percent_1); generate_block(); set_expiration(db, trx); @@ -1374,7 +1374,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) /////// { // Create the proposal - asset_create_operation create_op = create_smart_asset_op("RUBBIT", assetowner.id, usd_fso_percent, + asset_create_operation create_op = create_smart_asset_op("RUBBIT", assetowner_id, usd_fso_percent, fsf_percent_1); proposal_create_operation cop; cop.review_period_seconds = 86400; @@ -1390,7 +1390,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Approve the proposal - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = assetowner_id; @@ -1460,7 +1460,7 @@ BOOST_FIXTURE_TEST_SUITE(force_settle_tests, force_settle_database_fixture) // Approve the proposal - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = assetowner_id; diff --git a/tests/tests/force_settle_match_tests.cpp b/tests/tests/force_settle_match_tests.cpp index a0b030a2e9..6b2023e75d 100644 --- a/tests/tests/force_settle_match_tests.cpp +++ b/tests/tests/force_settle_match_tests.cpp @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_settle_call) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // set margin call fee ratio @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_settle_call) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -85,10 +85,10 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_settle_call) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7, tcr 200% > 175% const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500), 2000); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/1.75 CORE/USD = 100/7, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(25000)); transfer(borrower, seller, bitusd.amount(1000)); @@ -117,18 +117,18 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_settle_call) price mc( asset(10*175), asset(1*100, usd_id) ); // This sell order above MSSP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); BOOST_CHECK_EQUAL( 2993, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->get_id(); // This buy order at MSSP will be matched only if no margin call (margin call takes precedence) - limit_order_id_type buy_med = create_sell_order(buyer2, asset(33000), bitusd.amount(3000))->id; + limit_order_id_type buy_med = create_sell_order(buyer2, asset(33000), bitusd.amount(3000))->get_id(); // This buy order above MSSP will be matched with a sell order (limit order with better price takes precedence) - limit_order_id_type buy_high = create_sell_order(buyer3, asset(111), bitusd.amount(10))->id; + limit_order_id_type buy_high = create_sell_order(buyer3, asset(111), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(buyer2, bitusd) ); @@ -155,16 +155,16 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_settle_call) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle_id ) != nullptr ); // buy orders won't change - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); - BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 33000 ); - BOOST_CHECK_EQUAL( db.find( buy_high )->for_sale.value, 111 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 33000 ); + BOOST_CHECK_EQUAL( db.find( buy_high )->for_sale.value, 111 ); // the settle order will match with call, at mssp: 1/11 = 1000/11000 - const call_order_object* tmp_call = db.find( call_id ); + const call_order_object* tmp_call = db.find( call_id ); BOOST_CHECK( tmp_call != nullptr ); // call will receive call_to_cover, pay 11*call_to_cover @@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_settle_call) BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); // the settle order then will match with call2, at mssp: 1/11 = 1000/11000 - const call_order_object* tmp_call2 = db.find( call2_id ); + const call_order_object* tmp_call2 = db.find( call2_id ); BOOST_CHECK( tmp_call2 != nullptr ); // call2 will receive call2_to_cover, pay 11*call2_to_cover @@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // set margin call fee ratio @@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -262,13 +262,13 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/175 CORE/USD = 6/70, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(100000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 285% collateral const call_order_object& call2 = *borrow( borrower2, bitusd.amount(7), asset(1), 1700); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 285% collateral const call_order_object& call3 = *borrow( borrower3, bitusd.amount(14), asset(2), 1700); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(100000)); // adjust price feed to get call orders into margin call territory @@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle_id ) == nullptr ); // the settle order will match with call2, at mssp: 100/11, @@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle2_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle2_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle2_id ) == nullptr ); // the settle order will match with call, at mssp: 100/11 @@ -391,7 +391,7 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle3_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle3_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle3_id ) == nullptr ); // the settle order will match with call, at mssp @@ -422,7 +422,7 @@ BOOST_AUTO_TEST_CASE(hf2481_small_settle_call) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle4_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle4_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle4_id ) == nullptr ); // the settle order will match with call, at mssp @@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // set margin call fee ratio @@ -487,7 +487,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -496,15 +496,15 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7, tcr 200% > 175% const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500), 2000); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/1.75 CORE/USD = 100/7, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(25000)); // create a small position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7, no tcr const call_order_object& call4 = *borrow( borrower4, bitusd.amount(10), asset(160) ); - call_order_id_type call4_id = call4.id; + call_order_id_type call4_id = call4.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); @@ -528,28 +528,28 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) BOOST_CHECK_EQUAL( 10, get_balance(borrower4, bitusd) ); // This sell order above MSSP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); BOOST_CHECK_EQUAL( 2993, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 80, get_balance(buyer, core) ); // Create a sell order which will be matched with several call orders later, price 1/9 - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(500), core.amount(4500) )->id; - BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 500 ); + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(500), core.amount(4500) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 500 ); // Create a force settlement, will be matched with several call orders later auto result = force_settle( seller, bitusd.amount(2400) ); BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle_id ) != nullptr ); // prepare price feed to get call and call2 (but not call3) into margin call territory @@ -590,7 +590,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); // the limit order then will match with call2, at limit order's price: 1/9 - const call_order_object* tmp_call2 = db.find( call2_id ); + const call_order_object* tmp_call2 = db.find( call2_id ); BOOST_CHECK( tmp_call2 != nullptr ); // if the limit is big enough, call2 will receive call2_to_cover, pay 9*call2_to_cover @@ -604,7 +604,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) // call4 will match with the settle order, since it has no tcr, it will be fully closed // match price is 1/11 - const call_order_object* tmp_call4 = db.find( call4_id ); + const call_order_object* tmp_call4 = db.find( call4_id ); BOOST_CHECK( tmp_call4 == nullptr ); // borrower4 balance changes @@ -627,7 +627,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) BOOST_CHECK_EQUAL( 25000, call3.collateral.value ); // sell_id is completely filled - BOOST_CHECK( !db.find( sell_id ) ); + BOOST_CHECK( !db.find( sell_id ) ); // settle order is not fully filled BOOST_CHECK( db.find( settle_id ) != nullptr ); @@ -638,7 +638,7 @@ BOOST_AUTO_TEST_CASE(tcr_test_hf2481_call_settle) get_balance(seller, core) ); // 500*9 + 10*10.7 + call2_cover2 * 10.7 // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // Can not reduce CR of a call order to trigger a margin call but not get fully filled and final CR <= ICR BOOST_CHECK_THROW( borrow( borrower_id(db), asset(10000, usd_id), asset(160000), 1700), fc::exception ); @@ -687,7 +687,7 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // set margin call fee ratio @@ -711,7 +711,7 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -720,16 +720,16 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7, tcr 200% > 175% const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500), 2000); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/1.75 CORE/USD = 100/7, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(25000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); // create a small position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7, no tcr const call_order_object& call4 = *borrow( borrower4, bitusd.amount(10), asset(160) ); - call_order_id_type call4_id = call4.id; + call_order_id_type call4_id = call4.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); @@ -753,28 +753,28 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) BOOST_CHECK_EQUAL( 10, get_balance(borrower4, bitusd) ); // This sell order above MSSP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); BOOST_CHECK_EQUAL( 2993, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 80, get_balance(buyer, core) ); // Create a sell order which will be matched with several call orders later, price 1/9 - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(500), core.amount(4500) )->id; - BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 500 ); + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(500), core.amount(4500) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 500 ); // Create a force settlement, will be matched with several call orders later auto result = force_settle( seller, bitusd.amount(2400) ); BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle_id ) != nullptr ); BOOST_CHECK_EQUAL( 2400, settle_id(db).balance.amount.value ); @@ -805,7 +805,7 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) generate_block(); // firstly the limit order will match with call, at limit order's price: 1/9 - const call_order_object* tmp_call = db.find( call_id ); + const call_order_object* tmp_call = db.find( call_id ); BOOST_CHECK( tmp_call != nullptr ); // call will receive call_to_cover, pay 9*call_to_cover @@ -820,7 +820,7 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) BOOST_CHECK_EQUAL( 0, get_balance(borrower_id, usd_id) ); // the limit order then will match with call2, at limit order's price: 1/9 - const call_order_object* tmp_call2 = db.find( call2_id ); + const call_order_object* tmp_call2 = db.find( call2_id ); BOOST_CHECK( tmp_call2 != nullptr ); // if the limit is big enough, call2 will receive call2_to_cover, pay 9*call2_to_cover @@ -833,7 +833,7 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) BOOST_CHECK_EQUAL( 0, get_balance(borrower2_id, usd_id) ); // sell_id is completely filled - BOOST_CHECK( !db.find( sell_id ) ); + BOOST_CHECK( !db.find( sell_id ) ); // all call orders are still there BOOST_CHECK( db.find( call_id ) != nullptr ); @@ -863,14 +863,14 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) BOOST_CHECK_EQUAL( 25000, call3_id(db).collateral.value ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // pass the hard fork time generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); // call4 will match with the settle order, since it has no tcr, it will be fully closed // match price is 1/11 - const call_order_object* tmp_call4 = db.find( call4_id ); + const call_order_object* tmp_call4 = db.find( call4_id ); BOOST_CHECK( tmp_call4 == nullptr ); // borrower4 balance changes @@ -902,7 +902,7 @@ BOOST_AUTO_TEST_CASE(hf2481_cross_test) get_balance(seller_id, asset_id_type()) ); // 500*9 + 10*10.7 + call2_cover2 * 10.7 // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // generate a block generate_block(); @@ -930,7 +930,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); { // set margin call fee ratio @@ -953,7 +953,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); transfer(committee_account, borrower5_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -962,19 +962,19 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/175 CORE/USD = 60/700, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(100000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/175 CORE/USD = 62/700, tcr 200% > 175% const call_order_object& call2 = *borrow( borrower2, bitusd.amount(100000), asset(15500), 2000); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/175 CORE/USD = 100/700, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(25000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); // create a small position with 320% collateral, call price is 16/175 CORE/USD = 64/700, no tcr const call_order_object& call4 = *borrow( borrower4, bitusd.amount(1000), asset(160) ); - call_order_id_type call4_id = call4.id; + call_order_id_type call4_id = call4.get_id(); // create yet another position with 900% collateral, call price is 45/175 CORE/USD = 180/700, no tcr const call_order_object& call5 = *borrow( borrower5, bitusd.amount(100000), asset(45000)); - call_order_id_type call5_id = call5.id; + call_order_id_type call5_id = call5.get_id(); transfer(borrower, seller, bitusd.amount(100000)); transfer(borrower2, seller, bitusd.amount(100000)); @@ -1002,36 +1002,36 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) share_type expected_seller_usd_balance = 300000; // This sell order above MCOP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(700), core.amount(150))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 700 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(700), core.amount(150))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 700 ); expected_seller_usd_balance -= 700; BOOST_CHECK_EQUAL( expected_seller_usd_balance.value, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(1000))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(1000))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 80, get_balance(buyer, core) ); // Create a sell order which will be matched with several call orders later, price 100/9 - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(100000), core.amount(9000) )->id; - BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 100000 ); + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(100000), core.amount(9000) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 100000 ); expected_seller_usd_balance -= 100000; // Create another sell order which will trigger a blackswan event if matched, price 100/21 limit_order_id_type sell_swan; if( i == 1 ) { - sell_swan = create_sell_order(seller, bitusd.amount(100), core.amount(21) )->id; - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 100 ); + sell_swan = create_sell_order(seller, bitusd.amount(100), core.amount(21) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 100 ); expected_seller_usd_balance -= 100; } else if( i == 2 ) { - sell_swan = create_sell_order(seller, bitusd.amount(10000), core.amount(2100) )->id; - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); + sell_swan = create_sell_order(seller, bitusd.amount(10000), core.amount(2100) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); expected_seller_usd_balance -= 10000; } @@ -1040,7 +1040,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle_id ) != nullptr ); expected_seller_usd_balance -= 40000; @@ -1049,7 +1049,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle2_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle2_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle2_id ) != nullptr ); expected_seller_usd_balance -= 10000; @@ -1058,7 +1058,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle3_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle3_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle3_id ) != nullptr ); expected_seller_usd_balance -= 3; @@ -1072,7 +1072,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle4_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle4_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle4_id ) != nullptr ); expected_seller_usd_balance -= 5; @@ -1139,7 +1139,7 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) expected_margin_call_fees += margin_call_fee_limit_2; // sell_id is completely filled - BOOST_CHECK( !db.find( sell_id ) ); + BOOST_CHECK( !db.find( sell_id ) ); // now call4 has the lowest CR // call4 will match with the settle order, since it is small and has too few collateral, it will be fully closed @@ -1270,16 +1270,16 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) BOOST_CHECK_EQUAL( expected_seller_core_balance.value, get_balance(seller, core) ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // sell_high is not matched - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 700 ); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 700 ); // sell_swan is not matched if( i == 1 ) - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 100 ); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 100 ); else if( i == 2 ) - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); // check gs fund BOOST_CHECK_EQUAL( usd_id(db).bitasset_data(db).settlement_fund.value, expected_gs_fund.value ); @@ -1296,16 +1296,16 @@ BOOST_AUTO_TEST_CASE(call_settle_blackswan) BOOST_TEST_MESSAGE( "Check again" ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // sell_high is not matched - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 700 ); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 700 ); // sell_swan is not matched if( i == 1 ) - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 100 ); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 100 ); else if( i == 2 ) - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); // check gs fund BOOST_CHECK_EQUAL( usd_id(db).bitasset_data(db).settlement_fund.value, expected_gs_fund.value ); @@ -1340,7 +1340,7 @@ BOOST_AUTO_TEST_CASE(call_settle_limit_settle) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); asset_id_type core_id; { @@ -1362,7 +1362,7 @@ BOOST_AUTO_TEST_CASE(call_settle_limit_settle) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1371,13 +1371,13 @@ BOOST_AUTO_TEST_CASE(call_settle_limit_settle) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/175 CORE/USD = 60/700, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(100000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 360% collateral, call price is 18/175 CORE/USD = 72/700, no tcr const call_order_object& call2 = *borrow( borrower2, bitusd.amount(100000), asset(18000) ); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 800% collateral, call price is 40/175 CORE/USD = 160/700, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(40000) ); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(100000)); transfer(borrower2, seller, bitusd.amount(100000)); @@ -1401,15 +1401,15 @@ BOOST_AUTO_TEST_CASE(call_settle_limit_settle) BOOST_CHECK_EQUAL( 0, get_balance(borrower3, bitusd) ); // Create a sell order which will trigger a blackswan event if matched, price 100/16 - limit_order_id_type sell_swan = create_sell_order(seller2, bitusd.amount(10000), core.amount(1600) )->id; - BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); + limit_order_id_type sell_swan = create_sell_order(seller2, bitusd.amount(10000), core.amount(1600) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_swan )->for_sale.value, 10000 ); // Create a force settlement, will be matched with several call orders later auto result = force_settle( seller, bitusd.amount(200000) ); BOOST_REQUIRE( result.is_type() ); BOOST_REQUIRE( result.get().value.new_objects.valid() ); BOOST_REQUIRE( !result.get().value.new_objects->empty() ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK( db.find( settle_id ) != nullptr ); BOOST_CHECK_EQUAL( 200000, settle_id(db).balance.amount.value ); diff --git a/tests/tests/grouped_orders_api_tests.cpp b/tests/tests/grouped_orders_api_tests.cpp index 3d8b308055..42a1fbdec3 100644 --- a/tests/tests/grouped_orders_api_tests.cpp +++ b/tests/tests/grouped_orders_api_tests.cpp @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(api_limit_get_grouped_limit_orders) { create_bitasset("USD", account_id_type()); create_account("dan"); create_account("bob"); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").get_id(); generate_block(); fc::usleep(fc::milliseconds(100)); auto core = std::string( asset_id_type() ); diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 143d2e3369..c1a5f31a75 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_virtual_operation_test) { try { graphene::app::history_api hist_api(app); - asset_id_type usd_id = create_user_issued_asset("USD").id; + asset_id_type usd_id = create_user_issued_asset("USD").get_id(); ACTORS( (dan)(bob) ); fund( dan, asset(100) ); @@ -251,11 +251,11 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { const account_object& dan = create_account("dan"); // create op 1 - create_bitasset("CNY", dan.id); // create op 2 + create_bitasset("CNY", dan.get_id()); // create op 2 create_bitasset("BTC", account_id_type()); // create op 3 - create_bitasset("XMR", dan.id); // create op 4 + create_bitasset("XMR", dan.get_id()); // create op 4 create_bitasset("EUR", account_id_type()); // create op 5 - create_bitasset("OIL", dan.id); // create op 6 + create_bitasset("OIL", dan.get_id()); // create op 6 generate_block(); fc::usleep(fc::milliseconds(100)); @@ -605,11 +605,11 @@ BOOST_AUTO_TEST_CASE(get_account_history_by_time) { const account_object& dan = create_account("dan"); // create op 1 - create_bitasset("CNY", dan.id); // create op 2 + create_bitasset("CNY", dan.get_id()); // create op 2 create_bitasset("BTC", account_id_type()); // create op 3 - create_bitasset("XMR", dan.id); // create op 4 + create_bitasset("XMR", dan.get_id()); // create op 4 create_bitasset("EUR", account_id_type()); // create op 5 - create_bitasset("OIL", dan.id); // create op 6 + create_bitasset("OIL", dan.get_id()); // create op 6 generate_block(); fc::usleep(fc::milliseconds(100)); @@ -712,7 +712,7 @@ BOOST_AUTO_TEST_CASE(track_account) { // account_id_type() creates dan(account tracked) const account_object& dan = create_account("dan"); - auto dan_id = dan.id; + auto dan_id = dan.get_id(); // dan makes 1 op create_bitasset("EUR", dan_id); @@ -786,7 +786,7 @@ BOOST_AUTO_TEST_CASE(track_account2) { // account_id_type() creates alice(tracked account) const account_object& alice = create_account("alice"); - auto alice_id = alice.id; + auto alice_id = alice.get_id(); //account_id_type() creates some ops create_bitasset("CNY", account_id_type()); @@ -870,7 +870,7 @@ BOOST_AUTO_TEST_CASE(min_blocks_to_keep_test) { histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 10, operation_history_id_type(0)); BOOST_REQUIRE_EQUAL(histories.size(), 3u); - operation_history_id_type oldest_op_hist_id = histories.back().id; + operation_history_id_type oldest_op_hist_id { histories.back().id }; BOOST_CHECK( db.find(oldest_op_hist_id) ); generate_block(); diff --git a/tests/tests/htlc_tests.cpp b/tests/tests/htlc_tests.cpp index 15ad4caa8c..833b7feebf 100644 --- a/tests/tests/htlc_tests.cpp +++ b/tests/tests/htlc_tests.cpp @@ -115,7 +115,7 @@ try { // make sure Bob (or anyone) can see the details of the transaction graphene::app::database_api db_api(db); - auto obj = db_api.get_objects( {alice_htlc_id }).front(); + auto obj = db_api.get_objects( { object_id_type(alice_htlc_id) }).front(); graphene::chain::htlc_object htlc = obj.template as(GRAPHENE_MAX_NESTED_OBJECTS); // someone else attempts to extend it (bob says he's alice, but he's not) @@ -304,7 +304,7 @@ try { asset(3 * GRAPHENE_BLOCKCHAIN_PRECISION), hash_it(pre_image), 0, 60); trx.operations.push_back(create_operation); sign(trx, alice_private_key); - htlc_id_type htlc_id = PUSH_TX(db, trx, ~0).operation_results[0].get(); + htlc_id_type htlc_id { PUSH_TX(db, trx, ~0).operation_results[0].get() }; trx.clear(); BOOST_TEST_MESSAGE("Bob attempts to redeem, but can't because preimage size is 0 (should fail)"); graphene::chain::htlc_redeem_operation redeem; @@ -319,7 +319,7 @@ try { // Alice creates an asset BOOST_TEST_MESSAGE("Create ALICECOIN so transfer_restricted can be controlled"); - const asset_id_type uia_id = create_user_issued_asset( "ALICECOIN", alice, transfer_restricted).id; + const asset_id_type uia_id = create_user_issued_asset( "ALICECOIN", alice, transfer_restricted).get_id(); BOOST_TEST_MESSAGE("Issuing ALICECOIN to Bob"); issue_uia(bob, asset(10000, uia_id) ); // verify transfer restrictions are in place @@ -462,7 +462,7 @@ try { sign(trx, alice_private_key); graphene::protocol::processed_transaction results = PUSH_TX(db, trx, ~0); trx.operations.clear(); - htlc_id_type htlc_id = results.operation_results[0].get(); + htlc_id_type htlc_id { results.operation_results[0].get() }; BOOST_TEST_MESSAGE("Attempt to redeem HTLC that has no preimage, but include one anyway (should fail)"); htlc_redeem_operation redeem; redeem.htlc_id = htlc_id; @@ -489,7 +489,7 @@ try { sign(trx, alice_private_key); graphene::protocol::processed_transaction results = PUSH_TX(db, trx, ~0); trx.operations.clear(); - htlc_id_type htlc_id = results.operation_results[0].get(); + htlc_id_type htlc_id { results.operation_results[0].get() }; BOOST_TEST_MESSAGE("Attempt to redeem with no preimage (should fail)"); htlc_redeem_operation redeem; redeem.htlc_id = htlc_id; @@ -962,7 +962,7 @@ try { upgrade_to_lifetime_member( nathan ); // create a UIA - const asset_id_type uia_id = create_user_issued_asset( "NATHANCOIN", nathan, white_list ).id; + const asset_id_type uia_id = create_user_issued_asset( "NATHANCOIN", nathan, white_list ).get_id(); // Make a whitelist authority { BOOST_TEST_MESSAGE( "Changing the whitelist authority" ); diff --git a/tests/tests/liquidity_pool_tests.cpp b/tests/tests/liquidity_pool_tests.cpp index 770851cee8..d0c9d1c085 100644 --- a/tests/tests/liquidity_pool_tests.cpp +++ b/tests/tests/liquidity_pool_tests.cpp @@ -57,7 +57,8 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_hardfork_time_test ) // Before the hard fork, unable to create a liquidity pool or transact against a liquidity pool, // or do any of them with proposals - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, lpa.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa.get_id(), 0, 0 ), + fc::exception ); liquidity_pool_id_type tmp_lp_id; BOOST_CHECK_THROW( delete_liquidity_pool( sam_id, tmp_lp_id ), fc::exception ); @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_hardfork_time_test ) fc::exception ); liquidity_pool_create_operation cop = - make_liquidity_pool_create_op( sam_id, core.id, usd.id, lpa.id, 0, 0 ); + make_liquidity_pool_create_op( sam_id, core.get_id(), usd.get_id(), lpa.get_id(), 0, 0 ); BOOST_CHECK_THROW( propose( cop ), fc::exception ); liquidity_pool_delete_operation delop = make_liquidity_pool_delete_op( sam_id, tmp_lp_id ); @@ -131,7 +132,7 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_create_delete_proposal_test ) // Able to propose { liquidity_pool_create_operation cop = - make_liquidity_pool_create_op( sam_id, core.id, usd.id, lpa.id, 0, 0 ); + make_liquidity_pool_create_op( sam_id, core.get_id(), usd.get_id(), lpa.get_id(), 0, 0 ); propose( cop ); liquidity_pool_id_type tmp_lp_id; @@ -153,7 +154,8 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_create_delete_proposal_test ) } // Able to create liquidity pools with valid data - const liquidity_pool_object& lpo1 = create_liquidity_pool( sam_id, core.id, usd.id, lpa1.id, 0, 0 ); + const liquidity_pool_object& lpo1 = create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa1.get_id(), + 0, 0 ); BOOST_CHECK( lpo1.asset_a == core.id ); BOOST_CHECK( lpo1.asset_b == usd.id ); BOOST_CHECK( lpo1.balance_a == 0 ); @@ -163,11 +165,12 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_create_delete_proposal_test ) BOOST_CHECK( lpo1.withdrawal_fee_percent == 0 ); BOOST_CHECK( lpo1.virtual_value == 0 ); - liquidity_pool_id_type lp_id1 = lpo1.id; + liquidity_pool_id_type lp_id1 = lpo1.get_id(); BOOST_CHECK( lpa1.is_liquidity_pool_share_asset() ); BOOST_CHECK( *lpa1.for_liquidity_pool == lp_id1 ); - const liquidity_pool_object& lpo2 = create_liquidity_pool( sam_id, core.id, usd.id, lpa2.id, 200, 300 ); + const liquidity_pool_object& lpo2 = create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa2.get_id(), + 200, 300 ); BOOST_CHECK( lpo2.asset_a == core.id ); BOOST_CHECK( lpo2.asset_b == usd.id ); BOOST_CHECK( lpo2.balance_a == 0 ); @@ -177,11 +180,12 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_create_delete_proposal_test ) BOOST_CHECK( lpo2.withdrawal_fee_percent == 300 ); BOOST_CHECK( lpo2.virtual_value == 0 ); - liquidity_pool_id_type lp_id2 = lpo2.id; + liquidity_pool_id_type lp_id2 = lpo2.get_id(); BOOST_CHECK( lpa2.is_liquidity_pool_share_asset() ); BOOST_CHECK( *lpa2.for_liquidity_pool == lp_id2 ); - const liquidity_pool_object& lpo3 = create_liquidity_pool( sam_id, usd.id, mpa.id, lpa3.id, 50, 50 ); + const liquidity_pool_object& lpo3 = create_liquidity_pool( sam_id, usd.get_id(), mpa.get_id(), lpa3.get_id(), + 50, 50 ); BOOST_CHECK( lpo3.asset_a == usd.id ); BOOST_CHECK( lpo3.asset_b == mpa.id ); @@ -192,42 +196,58 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_create_delete_proposal_test ) BOOST_CHECK( lpo3.withdrawal_fee_percent == 50 ); BOOST_CHECK( lpo3.virtual_value == 0 ); - liquidity_pool_id_type lp_id3 = lpo3.id; + liquidity_pool_id_type lp_id3 = lpo3.get_id(); BOOST_CHECK( lpa3.is_liquidity_pool_share_asset() ); BOOST_CHECK( *lpa3.for_liquidity_pool == lp_id3 ); // Unable to create a liquidity pool with invalid data // the same assets in pool - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, core.id, lpa.id, 0, 0 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, usd.id, usd.id, lpa.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), core.get_id(), lpa.get_id(), 0, 0 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, usd.get_id(), usd.get_id(), lpa.get_id(), 0, 0 ), + fc::exception ); // ID of the first asset is greater - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, usd.id, core.id, lpa.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, usd.get_id(), core.get_id(), lpa.get_id(), 0, 0 ), + fc::exception ); // the share asset is one of the assets in pool - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, usd.id, lpa.id, lpa.id, 0, 0 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, lpa.id, pm.id, lpa.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, usd.get_id(), lpa.get_id(), lpa.get_id(), 0, 0 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, lpa.get_id(), pm.get_id(), lpa.get_id(), 0, 0 ), + fc::exception ); // percentage too big - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, lpa.id, 10001, 0 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, lpa.id, 0, 10001 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, lpa.id, 10001, 10001 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa.get_id(), 10001, 0 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa.get_id(), 0, 10001 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa.get_id(), 10001, 10001 ), + fc::exception ); // asset does not exist - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, no_asset_id1, 0, 0 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, no_asset_id1, lpa.id, 0, 0 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, no_asset_id1, no_asset_id2, lpa.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), no_asset_id1, 0, 0 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), no_asset_id1, lpa.get_id(), 0, 0 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, no_asset_id1, no_asset_id2, lpa.get_id(), 0, 0 ), + fc::exception ); // the account does not own the share asset - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, ted_lpa.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), ted_lpa.get_id(), 0, 0 ), + fc::exception ); // the share asset is a MPA or a PM - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, mpa.id, 0, 0 ), fc::exception ); - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, pm.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), mpa.get_id(), 0, 0 ), + fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), pm.get_id(), 0, 0 ), + fc::exception ); // the share asset is already bound to a liquidity pool - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, usd.id, lpa1.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), usd.get_id(), lpa1.get_id(), 0, 0 ), + fc::exception ); // current supply of the share asset is not zero - BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.id, lpa.id, usd.id, 0, 0 ), fc::exception ); + BOOST_CHECK_THROW( create_liquidity_pool( sam_id, core.get_id(), lpa.get_id(), usd.get_id(), 0, 0 ), + fc::exception ); // Unable to issue a liquidity pool share asset BOOST_CHECK_THROW( issue_uia( sam, lpa1.amount(1) ), fc::exception ); // Sam is able to delete an empty pool owned by him - generic_operation_result result = delete_liquidity_pool( sam_id, lpo1.id ); + generic_operation_result result = delete_liquidity_pool( sam_id, lpo1.get_id() ); BOOST_CHECK( !db.find( lp_id1 ) ); BOOST_CHECK( !lpa1.is_liquidity_pool_share_asset() ); BOOST_CHECK_EQUAL( result.new_objects.size(), 0u ); @@ -278,9 +298,9 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_deposit_withdrawal_test ) const asset_object& lpa = create_user_issued_asset( "LPATEST", sam, charge_market_fee ); asset_id_type core_id = asset_id_type(); - asset_id_type eur_id = eur.id; - asset_id_type usd_id = usd.id; - asset_id_type lpa_id = lpa.id; + asset_id_type eur_id = eur.get_id(); + asset_id_type usd_id = usd.get_id(); + asset_id_type lpa_id = lpa.get_id(); int64_t init_amount = 10000000 * GRAPHENE_BLOCKCHAIN_PRECISION; fund( sam, asset(init_amount) ); @@ -313,8 +333,9 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_deposit_withdrawal_test ) int64_t expected_lp_supply = 0; // create a liquidity pool - const liquidity_pool_object& lpo = create_liquidity_pool( sam_id, eur.id, usd.id, lpa.id, 200, 300 ); - liquidity_pool_id_type lp_id = lpo.id; + const liquidity_pool_object& lpo = create_liquidity_pool( sam_id, eur.get_id(), usd.get_id(), lpa.get_id(), + 200, 300 ); + liquidity_pool_id_type lp_id = lpo.get_id(); BOOST_CHECK( lpo.asset_a == eur_id ); BOOST_CHECK( lpo.asset_b == usd_id ); @@ -672,7 +693,7 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_deposit_withdrawal_test ) generate_block(); graphene::market_history::liquidity_pool_ticker_id_type ticker_id( lp_id.instance ); - const auto& ticker = db.get< graphene::market_history::liquidity_pool_ticker_object >( ticker_id ); + const auto& ticker = db.get( ticker_id ); BOOST_CHECK_EQUAL( ticker._24h_deposit_count, 7u ); BOOST_CHECK_EQUAL( ticker.total_deposit_count, 7u ); BOOST_CHECK_EQUAL( ticker._24h_withdrawal_count, 2u ); @@ -713,9 +734,9 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_exchange_test ) const asset_object& lpa = create_user_issued_asset( "LPATEST", sam, charge_market_fee ); asset_id_type core_id = asset_id_type(); - asset_id_type eur_id = eur.id; - asset_id_type usd_id = usd.id; - asset_id_type lpa_id = lpa.id; + asset_id_type eur_id = eur.get_id(); + asset_id_type usd_id = usd.get_id(); + asset_id_type lpa_id = lpa.get_id(); int64_t init_amount = 10000000 * GRAPHENE_BLOCKCHAIN_PRECISION; fund( sam, asset(init_amount) ); @@ -751,8 +772,9 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_exchange_test ) int64_t expected_lp_supply = 0; // create a liquidity pool - const liquidity_pool_object& lpo = create_liquidity_pool( sam_id, eur.id, usd.id, lpa.id, 200, 300 ); - liquidity_pool_id_type lp_id = lpo.id; + const liquidity_pool_object& lpo = create_liquidity_pool( sam_id, eur.get_id(), usd.get_id(), lpa.get_id(), + 200, 300 ); + liquidity_pool_id_type lp_id = lpo.get_id(); BOOST_CHECK( lpo.asset_a == eur_id ); BOOST_CHECK( lpo.asset_b == usd_id ); @@ -974,7 +996,7 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_exchange_test ) BOOST_CHECK_EQUAL( eur_id(db).dynamic_data(db).accumulated_fees.value, expected_accumulated_fees_eur ); graphene::market_history::liquidity_pool_ticker_id_type ticker_id( lp_id.instance ); - const auto& ticker = db.get< graphene::market_history::liquidity_pool_ticker_object >( ticker_id ); + const auto& ticker = db.get( ticker_id ); BOOST_CHECK_EQUAL( ticker._24h_exchange_a2b_count, 1u ); BOOST_CHECK_EQUAL( ticker.total_exchange_a2b_count, 1u ); BOOST_CHECK_EQUAL( ticker._24h_exchange_b2a_count, 1u ); @@ -1368,17 +1390,16 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_apis_test ) const asset_object ted_lp3 = create_user_issued_asset( "TEDLP3", ted, charge_market_fee ); // create liquidity pools - const liquidity_pool_object sam_lpo1 = create_liquidity_pool( sam_id, sam_eur.id, sam_usd.id, - sam_lp1.id, 100, 310 ); - const liquidity_pool_object sam_lpo2 = create_liquidity_pool( sam_id, sam_usd.id, ted_usd.id, - sam_lp2.id, 200, 320 ); - const liquidity_pool_object ted_lpo1 = create_liquidity_pool( ted_id, sam_usd.id, ted_usd.id, - ted_lp1.id, 300, 330 ); - const liquidity_pool_object ted_lpo2 = create_liquidity_pool( ted_id, sam_usd.id, ted_eur.id, - ted_lp2.id, 400, 340 ); - const liquidity_pool_object ted_lpo3 = create_liquidity_pool( ted_id, ted_eur.id, ted_usd.id, - ted_lp3.id, 500, 350 ); - + const liquidity_pool_object sam_lpo1 = create_liquidity_pool( sam_id, sam_eur.get_id(), sam_usd.get_id(), + sam_lp1.get_id(), 100, 310 ); + const liquidity_pool_object sam_lpo2 = create_liquidity_pool( sam_id, sam_usd.get_id(), ted_usd.get_id(), + sam_lp2.get_id(), 200, 320 ); + const liquidity_pool_object ted_lpo1 = create_liquidity_pool( ted_id, sam_usd.get_id(), ted_usd.get_id(), + ted_lp1.get_id(), 300, 330 ); + const liquidity_pool_object ted_lpo2 = create_liquidity_pool( ted_id, sam_usd.get_id(), ted_eur.get_id(), + ted_lp2.get_id(), 400, 340 ); + const liquidity_pool_object ted_lpo3 = create_liquidity_pool( ted_id, ted_eur.get_id(), ted_usd.get_id(), + ted_lp3.get_id(), 500, 350 ); generate_block(); // Check database API @@ -1388,73 +1409,73 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_apis_test ) auto pools = db_api.list_liquidity_pools(); BOOST_REQUIRE_EQUAL( pools.size(), 5u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo1.id ); - BOOST_CHECK( pools.back().id == ted_lpo3.id ); + BOOST_CHECK( pools.front().id == sam_lpo1.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo3.get_id() ); // pagination - pools = db_api.list_liquidity_pools( 5, sam_lpo2.id ); + pools = db_api.list_liquidity_pools( 5, sam_lpo2.get_id() ); BOOST_REQUIRE_EQUAL( pools.size(), 4u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo2.id ); - BOOST_CHECK( pools.back().id == ted_lpo3.id ); + BOOST_CHECK( pools.front().id == sam_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo3.get_id() ); // with statistics - pools = db_api.list_liquidity_pools( 2, sam_lpo2.id, true ); + pools = db_api.list_liquidity_pools( 2, sam_lpo2.get_id(), true ); BOOST_REQUIRE_EQUAL( pools.size(), 2u ); BOOST_CHECK( pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo2.id ); - BOOST_CHECK( pools.back().id == ted_lpo1.id ); + BOOST_CHECK( pools.front().id == sam_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo1.get_id() ); // get_liquidity_pools_by_asset_a pools = db_api.get_liquidity_pools_by_asset_a( "SAMUSD" ); BOOST_REQUIRE_EQUAL( pools.size(), 3u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo2.id ); - BOOST_CHECK( pools.back().id == ted_lpo2.id ); + BOOST_CHECK( pools.front().id == sam_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo2.get_id() ); // pagination and with statistics - pools = db_api.get_liquidity_pools_by_asset_a( "SAMUSD", 2, ted_lpo2.id, true ); + pools = db_api.get_liquidity_pools_by_asset_a( "SAMUSD", 2, ted_lpo2.get_id(), true ); BOOST_REQUIRE_EQUAL( pools.size(), 1u ); BOOST_CHECK( pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == ted_lpo2.id ); + BOOST_CHECK( pools.front().id == ted_lpo2.get_id() ); // get_liquidity_pools_by_asset_b pools = db_api.get_liquidity_pools_by_asset_b( "TEDUSD" ); BOOST_REQUIRE_EQUAL( pools.size(), 3u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo2.id ); - BOOST_CHECK( pools.back().id == ted_lpo3.id ); + BOOST_CHECK( pools.front().id == sam_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo3.get_id() ); // pagination and with statistics - pools = db_api.get_liquidity_pools_by_asset_b( "TEDUSD", 2, sam_lpo1.id, true ); + pools = db_api.get_liquidity_pools_by_asset_b( "TEDUSD", 2, sam_lpo1.get_id(), true ); BOOST_REQUIRE_EQUAL( pools.size(), 2u ); BOOST_CHECK( pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo2.id ); - BOOST_CHECK( pools.back().id == ted_lpo1.id ); + BOOST_CHECK( pools.front().id == sam_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo1.get_id() ); // get_liquidity_pools_by_one_asset pools = db_api.get_liquidity_pools_by_one_asset( "SAMUSD" ); BOOST_REQUIRE_EQUAL( pools.size(), 4u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo1.id ); - BOOST_CHECK( pools.back().id == ted_lpo2.id ); + BOOST_CHECK( pools.front().id == sam_lpo1.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo2.get_id() ); // pagination and with statistics pools = db_api.get_liquidity_pools_by_one_asset( "SAMUSD", 3, liquidity_pool_id_type(), true ); BOOST_REQUIRE_EQUAL( pools.size(), 3u ); BOOST_CHECK( pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo1.id ); - BOOST_CHECK( pools.back().id == ted_lpo1.id ); + BOOST_CHECK( pools.front().id == sam_lpo1.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo1.get_id() ); // get_liquidity_pools_by_both_asset pools = db_api.get_liquidity_pools_by_both_assets( "SAMUSD", "TEDUSD" ); BOOST_REQUIRE_EQUAL( pools.size(), 2u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo2.id ); - BOOST_CHECK( pools.back().id == ted_lpo1.id ); + BOOST_CHECK( pools.front().id == sam_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo1.get_id() ); // pagination and with statistics - pools = db_api.get_liquidity_pools_by_both_assets( "SAMUSD", "TEDUSD", 3, ted_lpo2.id, true ); + pools = db_api.get_liquidity_pools_by_both_assets( "SAMUSD", "TEDUSD", 3, ted_lpo2.get_id(), true ); BOOST_REQUIRE_EQUAL( pools.size(), 0u ); // get_liquidity_pools_by_share_asset @@ -1462,27 +1483,23 @@ BOOST_AUTO_TEST_CASE( liquidity_pool_apis_test ) BOOST_REQUIRE_EQUAL( opools.size(), 2u ); BOOST_CHECK( opools.front().valid() ); BOOST_CHECK( opools.front()->statistics.valid() ); - BOOST_CHECK( opools.front()->id == sam_lpo1.id ); + BOOST_CHECK( opools.front()->id == sam_lpo1.get_id() ); BOOST_CHECK( !opools.back().valid() ); // get_liquidity_pools_by_owner pools = db_api.get_liquidity_pools_by_owner( "sam" ); BOOST_REQUIRE_EQUAL( pools.size(), 2u ); BOOST_CHECK( !pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == sam_lpo1.id ); - BOOST_CHECK( pools.back().id == sam_lpo2.id ); + BOOST_CHECK( pools.front().id == sam_lpo1.get_id() ); + BOOST_CHECK( pools.back().id == sam_lpo2.get_id() ); // pagination and with statistics - pools = db_api.get_liquidity_pools_by_owner( "ted", 5, sam_lpo1.id, true ); - BOOST_REQUIRE_EQUAL( pools.size(), 3u ); + pools = db_api.get_liquidity_pools_by_owner( "ted", 5, ted_lp2.get_id(), true ); + BOOST_REQUIRE_EQUAL( pools.size(), 2u ); BOOST_CHECK( pools.front().statistics.valid() ); - BOOST_CHECK( pools.front().id == ted_lpo1.id ); - BOOST_CHECK( pools.back().id == ted_lpo3.id ); + BOOST_CHECK( pools.front().id == ted_lpo2.get_id() ); + BOOST_CHECK( pools.back().id == ted_lpo3.get_id() ); - } catch (fc::exception& e) { - edump((e.to_detail_string())); - throw; - } -} +} FC_CAPTURE_LOG_AND_RETHROW( (0) ) } BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/margin_call_fee_tests.cpp b/tests/tests/margin_call_fee_tests.cpp index f86f3ce09f..acb8592ea6 100644 --- a/tests/tests/margin_call_fee_tests.cpp +++ b/tests/tests/margin_call_fee_tests.cpp @@ -320,7 +320,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Initialize tokens // CORE asset exists by default const asset_object &core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const int64_t CORE_UNIT = asset::scaled_precision(core.precision).value; // 100000 satoshi CORE in 1 CORE // Create the SMARTBIT asset @@ -333,7 +333,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object smartbit = get_asset("SMARTBIT"); - const asset_id_type smartbit_id = smartbit.id; + const asset_id_type smartbit_id = smartbit.get_id(); update_feed_producers(smartbit, {feedproducer_id}); // Initialize token balance of actors @@ -371,7 +371,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Bob retains the asset in his own balances, or transfers it, or sells it is not critical // because his debt position is what will be tracked. ////// - call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core)).id; + call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core)).get_id(); BOOST_REQUIRE_EQUAL(get_balance(bob, smartbit), 200 * SMARTBIT_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement const price bob_initial_cr = bob_call_id(db).collateralization(); // Units of collateral / debt @@ -441,7 +441,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; // Margin call should exchange all of the available debt (X) for X*(MSSR-MCFR)/settlement_price // The match price should be the settlement_price/(MSSR-MCFR) = settlement_price/(MSSR-MCFR) @@ -589,7 +589,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Initialize tokens // CORE asset exists by default const asset_object &core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const int64_t CORE_UNIT = asset::scaled_precision(core.precision).value; // 100000 satoshi CORE in 1 CORE // Create the SMARTBIT asset @@ -602,7 +602,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object smartbit = get_asset("SMARTBIT"); - const asset_id_type smartbit_id = smartbit.id; + const asset_id_type smartbit_id = smartbit.get_id(); update_feed_producers(smartbit, {feedproducer_id}); // Initialize token balance of actors @@ -650,7 +650,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Bob retains the asset in his own balances, or transfers it, or sells it is not critical // because his debt position is what will be tracked. ////// - call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core)).id; + call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core)).get_id(); BOOST_REQUIRE_EQUAL(get_balance(bob, smartbit), 200 * SMARTBIT_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement const price bob_initial_cr = bob_call_id(db).collateralization(); // Units of collateral / debt @@ -697,7 +697,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // **Bob's margin call SHOULD NOT be affected.** ////// // Charlie obtains his SMARTBIT by borrowing it from the blockchain - call_order_id_type charlie_call_id = (*borrow(charlie, charlie_initial_smart, charlie_initial_core)).id; + call_order_id_type charlie_call_id = (*borrow(charlie, charlie_initial_smart, charlie_initial_core)).get_id(); BOOST_REQUIRE_EQUAL(get_balance(charlie, smartbit), 200 * SMARTBIT_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement const price charlie_initial_cr = charlie_call_id(db).collateralization(); // Units of collateral / debt @@ -743,7 +743,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset charlie_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, charlie_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type charlie_order_id = ptx.operation_results[0].get(); + limit_order_id_type charlie_order_id { ptx.operation_results[0].get() }; // Check Charlies's limit order is still open BOOST_CHECK(db.find(charlie_order_id)); @@ -792,7 +792,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; // Margin call should exchange all of the available debt (X) for X*(MSSR-MCFR)/settlement_price // Payment to limit order = X*(MSSR-MCFR)/settlement_price @@ -920,7 +920,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Initialize tokens // CORE asset exists by default const asset_object &core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const int64_t CORE_UNIT = asset::scaled_precision(core.precision).value; // 100000 satoshi CORE in 1 CORE // Create the SMARTBIT asset @@ -933,7 +933,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object smartbit = get_asset("SMARTBIT"); - const asset_id_type smartbit_id = smartbit.id; + const asset_id_type smartbit_id = smartbit.get_id(); update_feed_producers(smartbit, {feedproducer_id}); // Initialize token balance of actors @@ -972,7 +972,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // because his debt position is what will be tracked. ////// const uint16_t tcr = 2200; // Bob's target collateral ratio (TCR) 220% expressed in terms of GRAPHENE_COLLATERAL_RATIO_DENOM - call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core, tcr)).id; + call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core, tcr)).get_id(); BOOST_REQUIRE_EQUAL(get_balance(bob, smartbit), 200 * SMARTBIT_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement const price bob_initial_cr = bob_call_id(db).collateralization(); // Units of collateral / debt @@ -1044,7 +1044,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; // The match price **as maker** should be the settlement_price/(MSSR-MCFR) = settlement_price/(MSSR-MCFR) const uint16_t ratio_numerator = current_feed.maximum_short_squeeze_ratio - smartbit_margin_call_fee_ratio; @@ -1267,7 +1267,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Initialize tokens // CORE asset exists by default const asset_object &core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const int64_t CORE_UNIT = asset::scaled_precision(core.precision).value; // 100000 satoshi CORE in 1 CORE // Create the SMARTBIT asset @@ -1280,7 +1280,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object smartbit = get_asset("SMARTBIT"); - const asset_id_type smartbit_id = smartbit.id; + const asset_id_type smartbit_id = smartbit.get_id(); update_feed_producers(smartbit, {feedproducer_id}); // Initialize token balance of actors @@ -1340,7 +1340,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // 3. (Order 1: Limit order) Alice places a **"large"** limit order to sell SMARTBIT. ////// // Alice borrows SMARTBIT - call_order_id_type alice_call_id = (*borrow(alice, alice_initial_smart, alice_initial_core)).id; + call_order_id_type alice_call_id = (*borrow(alice, alice_initial_smart, alice_initial_core)).get_id(); BOOST_CHECK_EQUAL(get_balance(alice_id(db), smartbit_id(db)), 500 * SMARTBIT_UNIT); BOOST_CHECK_EQUAL(get_balance(alice_id, core_id), 0 * CORE_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement @@ -1363,7 +1363,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; // Alice should have no balance BOOST_CHECK_EQUAL(get_balance(alice_id(db), smartbit_id(db)), 0 * SMARTBIT_UNIT); @@ -1377,7 +1377,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) ////// const asset bob_initial_debt_smart = bob_initial_smart; const asset bob_initial_debt_collateral = bob_initial_core; - call_order_id_type bob_call_id = (*borrow(bob, bob_initial_debt_smart, bob_initial_debt_collateral)).id; + call_order_id_type bob_call_id = (*borrow(bob, bob_initial_debt_smart, bob_initial_debt_collateral)).get_id(); // Bobs's balances should reflect that CORE was used to create SMARTBIT BOOST_CHECK_EQUAL(get_balance(bob_id, smartbit_id), 200 * SMARTBIT_UNIT); @@ -1565,7 +1565,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Initialize tokens // CORE asset exists by default const asset_object &core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const int64_t CORE_UNIT = asset::scaled_precision(core.precision).value; // 100000 satoshi CORE in 1 CORE // Create the SMARTBIT asset @@ -1578,7 +1578,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object smartbit = get_asset("SMARTBIT"); - const asset_id_type smartbit_id = smartbit.id; + const asset_id_type smartbit_id = smartbit.get_id(); update_feed_producers(smartbit, {feedproducer_id}); // Initialize token balance of actors @@ -1664,7 +1664,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; // Alice should have no balance BOOST_CHECK_EQUAL(get_balance(alice_id(db), smartbit_id(db)), 0 * SMARTBIT_UNIT); @@ -1677,7 +1677,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // because his debt position is what will be tracked. ////// const uint16_t tcr = 2200; // Bob's target collateral ratio (TCR) 220% expressed in terms of GRAPHENE_COLLATERAL_RATIO_DENOM - call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core, tcr)).id; + call_order_id_type bob_call_id = (*borrow(bob, bob_initial_smart, bob_initial_core, tcr)).get_id(); BOOST_REQUIRE_EQUAL(get_balance(bob, smartbit), 200 * SMARTBIT_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement const price bob_initial_cr = bob_call_id(db).collateralization(); // Units of collateral / debt @@ -1934,7 +1934,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Initialize tokens // CORE asset exists by default const asset_object &core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const int64_t CORE_UNIT = asset::scaled_precision(core.precision).value; // 100000 satoshi CORE in 1 CORE // Create the SMARTBIT asset @@ -1948,7 +1948,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object smartbit = get_asset("SMARTBIT"); - const asset_id_type smartbit_id = smartbit.id; + const asset_id_type smartbit_id = smartbit.get_id(); update_feed_producers(smartbit, {feedproducer_id}); // Initialize token balance of actors @@ -2037,7 +2037,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // 3. (Order 1: Limit order) Alice places a **"large"** limit order to sell SMARTBIT. ////// // Alice borrows SMARTBIT - call_order_id_type alice_call_id = (*borrow(alice, alice_initial_smart, alice_initial_core)).id; + call_order_id_type alice_call_id = (*borrow(alice, alice_initial_smart, alice_initial_core)).get_id(); BOOST_CHECK_EQUAL(get_balance(alice_id(db), smartbit_id(db)), 500 * SMARTBIT_UNIT); BOOST_CHECK_EQUAL(get_balance(alice_id, core_id), 0 * CORE_UNIT); BOOST_CHECK(!smartbit.bitasset_data(db).has_settlement()); // No global settlement @@ -2065,7 +2065,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; // Alice should have no balance BOOST_CHECK_EQUAL(get_balance(alice_id(db), smartbit_id(db)), 0 * SMARTBIT_UNIT); @@ -2080,7 +2080,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) ////// const asset bob_initial_debt_smart = bob_initial_smart; const asset bob_initial_debt_collateral = bob_initial_core; - call_order_id_type bob_call_id = (*borrow(bob, bob_initial_debt_smart, bob_initial_debt_collateral)).id; + call_order_id_type bob_call_id = (*borrow(bob, bob_initial_debt_smart, bob_initial_debt_collateral)).get_id(); // Bobs's balances should reflect that CORE was used to create SMARTBIT BOOST_CHECK_EQUAL(get_balance(bob_id, smartbit_id), 200 * SMARTBIT_UNIT); @@ -2313,7 +2313,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // CORE asset exists by default asset_object core = asset_id_type()(db); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); // Fund actors uint64_t initial_balance_core = 10000000; @@ -2493,7 +2493,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Approve the proposal - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = assetowner_id; @@ -2563,7 +2563,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Approve the proposal - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = assetowner_id; @@ -2635,7 +2635,7 @@ BOOST_FIXTURE_TEST_SUITE(margin_call_fee_tests, bitasset_database_fixture) // Approve the proposal - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = assetowner_id; diff --git a/tests/tests/market_fee_sharing_tests.cpp b/tests/tests/market_fee_sharing_tests.cpp index 4e6b12b35f..6e980c4689 100644 --- a/tests/tests/market_fee_sharing_tests.cpp +++ b/tests/tests/market_fee_sharing_tests.cpp @@ -35,7 +35,7 @@ struct reward_database_fixture : database_fixture const fc::ecc::private_key& private_key, const asset_id_type& asset_id, uint16_t reward_percent, - const whitelist_market_fee_sharing_t &whitelist_market_fee_sharing = whitelist_market_fee_sharing_t{}, + const whitelist_market_fee_sharing_t &whitelist_market_fee_sharing = {}, const flat_set &blacklist = flat_set()) { asset_update_operation op; @@ -286,8 +286,8 @@ BOOST_AUTO_TEST_CASE(asset_rewards_test) auto alice = register_account("alice", alicereferrer); auto bob = register_account("bob", bobreferrer); - transfer( committee_account, alice.id, core_asset(1000000) ); - transfer( committee_account, bob.id, core_asset(1000000) ); + transfer( committee_account, alice.get_id(), core_asset(1000000) ); + transfer( committee_account, bob.get_id(), core_asset(1000000) ); transfer( committee_account, izzy_id, core_asset(1000000) ); transfer( committee_account, jill_id, core_asset(1000000) ); @@ -297,8 +297,8 @@ BOOST_AUTO_TEST_CASE(asset_rewards_test) constexpr auto izzycoin_market_percent = 10*GRAPHENE_1_PERCENT; constexpr auto jillcoin_market_percent = 20*GRAPHENE_1_PERCENT; - asset_id_type izzycoin_id = create_bitasset( "IZZYCOIN", izzy_id, izzycoin_market_percent ).id; - asset_id_type jillcoin_id = create_bitasset( "JILLCOIN", jill_id, jillcoin_market_percent ).id; + asset_id_type izzycoin_id = create_bitasset( "IZZYCOIN", izzy_id, izzycoin_market_percent ).get_id(); + asset_id_type jillcoin_id = create_bitasset( "JILLCOIN", jill_id, jillcoin_market_percent ).get_id(); update_asset(izzy_id, izzy_private_key, izzycoin_id, izzycoin_reward_percent); update_asset(jill_id, jill_private_key, jillcoin_id, jillcoin_reward_percent); @@ -330,12 +330,14 @@ BOOST_AUTO_TEST_CASE(asset_rewards_test) enable_fees(); // Alice and Bob create some coins - borrow( alice.id, _izzy( 1500), core_asset( 600000) ); - borrow( bob.id, _jill(2000), core_asset(180000) ); + borrow( alice.get_id(), _izzy( 1500), core_asset( 600000) ); + borrow( bob.get_id(), _jill(2000), core_asset(180000) ); // Alice and Bob place orders which match - create_sell_order( alice.id, _izzy(1000), _jill(1500) ); // Alice is willing to sell her 1000 Izzy's for 1.5 Jill - create_sell_order( bob.id, _jill(1500), _izzy(1000) ); // Bob is buying up to 1500 Izzy's for up to 0.6 Jill + create_sell_order( alice.get_id(), _izzy(1000), _jill(1500) ); // Alice is willing to sell her 1000 Izzy's + // for 1.5 Jill + create_sell_order( bob.get_id(), _jill(1500), _izzy(1000) ); // Bob is buying up to 1500 Izzy's + // for up to 0.6 Jill // 1000 Izzys and 1500 Jills are matched, so the fees should be // 100 Izzy (10%) and 300 Jill (20%). @@ -368,7 +370,8 @@ BOOST_AUTO_TEST_CASE(asset_rewards_test) const auto jillcoin_market_fee = calculate_percent(_jill(1500).amount, jillcoin_market_percent); const auto jillcoin_reward = calculate_percent(jillcoin_market_fee, jillcoin_reward_percent); BOOST_CHECK_EQUAL( jillcoin_reward, alice_refereer_reward + alice_registrar_reward ); - BOOST_CHECK_EQUAL( calculate_percent(jillcoin_reward, alice.referrer_rewards_percentage), alice_refereer_reward ); + BOOST_CHECK_EQUAL( calculate_percent(jillcoin_reward, alice.referrer_rewards_percentage), + alice_refereer_reward ); } FC_LOG_AND_RETHROW() } @@ -384,7 +387,8 @@ BOOST_AUTO_TEST_CASE(asset_claim_reward_test) price price(asset(1, asset_id_type(1)), asset(1)); uint16_t market_fee_percent = 20 * GRAPHENE_1_PERCENT; - const asset_object jillcoin = create_user_issued_asset( "JCOIN", jill, charge_market_fee, price, 2, market_fee_percent ); + const asset_object jillcoin = create_user_issued_asset( "JCOIN", jill, charge_market_fee, price, + 2, market_fee_percent ); const account_object alice = create_account("alice", izzy, izzy, 50/*0.5%*/); const account_object bob = create_account("bob", izzy, izzy, 50/*0.5%*/); @@ -739,7 +743,7 @@ BOOST_AUTO_TEST_CASE(create_asset_via_proposal_test) price core_exchange_rate(asset(1, asset_id_type(1)), asset(1)); asset_create_operation create_op; - create_op.issuer = issuer.id; + create_op.issuer = issuer.get_id(); create_op.fee = asset(); create_op.symbol = "ASSET"; create_op.common_options.max_supply = 0; @@ -827,10 +831,12 @@ BOOST_AUTO_TEST_CASE(issue_asset){ price price(asset(1, asset_id_type(1)), asset(1)); constexpr auto izzycoin_market_percent = 10*GRAPHENE_1_PERCENT; - asset_object izzycoin = create_user_issued_asset( "IZZYCOIN", izzy, charge_market_fee, price, 2, izzycoin_market_percent ); + asset_object izzycoin = create_user_issued_asset( "IZZYCOIN", izzy, charge_market_fee, price, + 2, izzycoin_market_percent ); constexpr auto jillcoin_market_percent = 20*GRAPHENE_1_PERCENT; - asset_object jillcoin = create_user_issued_asset( "JILLCOIN", jill, charge_market_fee, price, 2, jillcoin_market_percent ); + asset_object jillcoin = create_user_issued_asset( "JILLCOIN", jill, charge_market_fee, price, + 2, jillcoin_market_percent ); // Alice and Bob create some coins issue_uia( alice, izzycoin.amount( 100000 ) ); @@ -852,8 +858,10 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_before_hf_test) GET_ACTOR(bob); // Alice and Bob place orders which match - create_sell_order( alice_id, izzycoin.amount(100), jillcoin.amount(300) ); // Alice is willing to sell her Izzy's for 3 Jill - create_sell_order( bob_id, jillcoin.amount(700), izzycoin.amount(200) ); // Bob is buying up to 200 Izzy's for up to 3.5 Jill + create_sell_order( alice_id, izzycoin.amount(100), jillcoin.amount(300) ); // Alice is willing to sell + // her Izzy's for 3 Jill + create_sell_order( bob_id, jillcoin.amount(700), izzycoin.amount(200) ); // Bob is buying up to 200 Izzy's + // for up to 3.5 Jill // 100 Izzys and 300 Jills are matched, so the fees should be // 10 Izzy (10%) and 60 Jill (20%). @@ -876,8 +884,10 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_after_hf_test) GET_ACTOR(bob); // Alice and Bob place orders which match - create_sell_order( alice_id, izzycoin.amount(100), jillcoin.amount(300) ); // Alice is willing to sell her Izzy's for 3 Jill - create_sell_order( bob_id, jillcoin.amount(700), izzycoin.amount(200) ); // Bob is buying up to 200 Izzy's for up to 3.5 Jill + create_sell_order( alice_id, izzycoin.amount(100), jillcoin.amount(300) ); // Alice is willing to sell + // her Izzy's for 3 Jill + create_sell_order( bob_id, jillcoin.amount(700), izzycoin.amount(200) ); // Bob is buying up to 200 Izzy's + // for up to 3.5 Jill // 100 Izzys and 300 Jills are matched, so the fees should be // 10 Izzy (10%) and 60 Jill (20%). @@ -907,8 +917,10 @@ BOOST_AUTO_TEST_CASE(accumulated_fees_with_additional_options_after_hf_test) GET_ACTOR(bob); // Alice and Bob place orders which match - create_sell_order( alice_id, izzycoin.amount(100), jillcoin.amount(300) ); // Alice is willing to sell her Izzy's for 3 Jill - create_sell_order( bob_id, jillcoin.amount(700), izzycoin.amount(200) ); // Bob is buying up to 200 Izzy's for up to 3.5 Jill + create_sell_order( alice_id, izzycoin.amount(100), jillcoin.amount(300) ); // Alice is willing to sell + // her Izzy's for 3 Jill + create_sell_order( bob_id, jillcoin.amount(700), izzycoin.amount(200) ); // Bob is buying up to 200 Izzy's + // for up to 3.5 Jill // 100 Izzys and 300 Jills are matched, so the fees should be // 10 Izzy (10%) and 60 Jill (20%). @@ -937,7 +949,7 @@ BOOST_AUTO_TEST_CASE( create_vesting_balance_with_instant_vesting_policy_test ) set_expiration( db, trx ); processed_transaction ptx = PUSH_TX( db, trx, ~0 ); - const vesting_balance_id_type& vbid = ptx.operation_results.back().get(); + const vesting_balance_id_type vbid { ptx.operation_results.back().get() }; auto withdraw = [&](const asset& amount) { vesting_balance_withdraw_operation withdraw_op; @@ -1023,8 +1035,10 @@ BOOST_AUTO_TEST_CASE(white_list_asset_rewards_test) price price(asset(1, asset_id_type(1)), asset(1)); constexpr auto izzycoin_market_percent = 10*GRAPHENE_1_PERCENT; constexpr auto jillcoin_market_percent = 20*GRAPHENE_1_PERCENT; - const asset_id_type izzycoin_id = create_user_issued_asset( "IZZYCOIN", izzy, charge_market_fee|white_list, price, 0, izzycoin_market_percent ).id; - const asset_id_type jillcoin_id = create_user_issued_asset( "JILLCOIN", jill, charge_market_fee|white_list, price, 0, jillcoin_market_percent ).id; + const asset_id_type izzycoin_id = create_user_issued_asset( "IZZYCOIN", izzy, charge_market_fee|white_list, + price, 0, izzycoin_market_percent ).get_id(); + const asset_id_type jillcoin_id = create_user_issued_asset( "JILLCOIN", jill, charge_market_fee|white_list, + price, 0, jillcoin_market_percent ).get_id(); // Alice and Bob create some coins issue_uia( alice, izzycoin_id(db).amount( 200000 ) ); @@ -1047,8 +1061,10 @@ BOOST_AUTO_TEST_CASE(white_list_asset_rewards_test) BOOST_CHECK( !(is_authorized_asset( db, aliceregistrar_id(db), jillcoin_id(db) )) ); // Alice and Bob place orders which match - create_sell_order( alice.id, izzycoin_id(db).amount(1000), jillcoin_id(db).amount(1500) ); // Alice is willing to sell her 1000 Izzy's for 1.5 Jill - create_sell_order( bob.id, jillcoin_id(db).amount(1500), izzycoin_id(db).amount(1000) ); // Bob is buying up to 1500 Izzy's for up to 0.6 Jill + // Alice is willing to sell her 1000 Izzy's for 1.5 Jill + create_sell_order( alice.get_id(), izzycoin_id(db).amount(1000), jillcoin_id(db).amount(1500) ); + // Bob is buying up to 1500 Izzy's for up to 0.6 Jill + create_sell_order( bob.get_id(), jillcoin_id(db).amount(1500), izzycoin_id(db).amount(1000) ); // 1000 Izzys and 1500 Jills are matched, so the fees should be // 100 Izzy (10%) and 300 Jill (20%). @@ -1087,7 +1103,8 @@ BOOST_AUTO_TEST_CASE( create_vesting_balance_object_test ) create_vesting_balance_object(actor_id, vesting_balance_type::worker); create_vesting_balance_object(actor_id, vesting_balance_type::market_fee_sharing); - GRAPHENE_CHECK_THROW(create_vesting_balance_object(actor_id, vesting_balance_type::market_fee_sharing), fc::exception); + GRAPHENE_CHECK_THROW(create_vesting_balance_object(actor_id, vesting_balance_type::market_fee_sharing), + fc::exception); } FC_LOG_AND_RETHROW() } diff --git a/tests/tests/market_rounding_tests.cpp b/tests/tests/market_rounding_tests.cpp index 66698bee45..c3e55d24c0 100644 --- a/tests/tests/market_rounding_tests.cpp +++ b/tests/tests/market_rounding_tests.cpp @@ -49,9 +49,9 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero ) set_expiration( db, trx ); const asset_object& test = create_user_issued_asset( "UIATEST" ); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); const asset_object& core = get_asset( GRAPHENE_SYMBOL ); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const account_object& core_seller = create_account( "seller1" ); const account_object& core_buyer = create_account("buyer1"); @@ -105,9 +105,9 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero_after_hf_184 ) set_expiration( db, trx ); const asset_object& test = create_user_issued_asset( "UIATEST" ); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); const asset_object& core = get_asset( GRAPHENE_SYMBOL ); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); const account_object& core_seller = create_account( "seller1" ); const account_object& core_buyer = create_account("buyer1"); @@ -158,9 +158,9 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test1 ) ACTORS( (seller)(buyer) ); const asset_object& test = create_user_issued_asset( "UIATEST" ); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); const asset_object& core = get_asset( GRAPHENE_SYMBOL ); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); transfer( committee_account(db), seller, asset( 100000000 ) ); @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test1 ) BOOST_CHECK_EQUAL(get_balance(seller, core), 100000000); // seller sells 3 core for 31 test, price 10.33 test per core - limit_order_id_type sell_id = create_sell_order( seller, core.amount(3), test.amount(31) )->id; + limit_order_id_type sell_id = create_sell_order( seller, core.amount(3), test.amount(31) )->get_id(); // buyer buys 2 core with 25 test, price 12.5 test per core // the order is filled immediately @@ -189,11 +189,11 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test1 ) generate_block(); // buyer buys 2 core with 25 test, price 12.5 test per core - limit_order_id_type buy_id = create_sell_order( buyer_id, asset(25,test_id), asset(2,core_id) )->id; + limit_order_id_type buy_id = create_sell_order( buyer_id, asset(25,test_id), asset(2,core_id) )->get_id(); generate_block(); - BOOST_CHECK( !db.find_object( sell_id ) ); // sell order is filled + BOOST_CHECK( !db.find( sell_id ) ); // sell order is filled BOOST_CHECK_EQUAL( buy_id(db).for_sale.value, 15 ); // 10 test sold, 15 remaining BOOST_CHECK_EQUAL(get_balance(seller_id, core_id), 99999997); @@ -224,9 +224,9 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test1_after_hf_342 ) ACTORS( (seller)(buyer) ); const asset_object& test = create_user_issued_asset( "UIATEST" ); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); const asset_object& core = get_asset( GRAPHENE_SYMBOL ); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); transfer( committee_account(db), seller, asset( 100000000 ) ); @@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test1_after_hf_342 ) BOOST_CHECK_EQUAL(get_balance(seller, core), 100000000); // seller sells 3 core for 31 test, price 10.33 test per core - limit_order_id_type sell_id = create_sell_order( seller, core.amount(3), test.amount(31) )->id; + limit_order_id_type sell_id = create_sell_order( seller, core.amount(3), test.amount(31) )->get_id(); // buyer buys 2 core with 25 test, price 12.5 test per core // the order is filled immediately @@ -255,11 +255,11 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test1_after_hf_342 ) set_expiration( db, trx ); // buyer buys 2 core with 25 test, price 12.5 test per core - limit_order_id_type buy_id = create_sell_order( buyer_id, asset(25,test_id), asset(2,core_id) )->id; + limit_order_id_type buy_id = create_sell_order( buyer_id, asset(25,test_id), asset(2,core_id) )->get_id(); generate_block(); - BOOST_CHECK( !db.find_object( sell_id ) ); // sell order is filled + BOOST_CHECK( !db.find( sell_id ) ); // sell order is filled BOOST_CHECK_EQUAL( buy_id(db).for_sale.value, 15 ); // 10 test sold according to price 10.33, and 15 remaining BOOST_CHECK_EQUAL(get_balance(buyer_id, core_id), 3); // buyer got 1 more core @@ -287,9 +287,9 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test2 ) ACTORS( (seller)(buyer) ); const asset_object& test = create_user_issued_asset( "UIATEST" ); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); const asset_object& core = get_asset( GRAPHENE_SYMBOL ); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); transfer( committee_account(db), seller, asset( 100000000 ) ); @@ -301,11 +301,11 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test2 ) BOOST_CHECK_EQUAL(get_balance(seller, core), 100000000); // buyer buys 17 core with 3 test, price 3/17 = 0.176 test per core - limit_order_id_type tmp_buy_id = create_sell_order( buyer, test.amount(3), core.amount(17) )->id; + limit_order_id_type tmp_buy_id = create_sell_order( buyer, test.amount(3), core.amount(17) )->get_id(); // seller sells 33 core for 5 test, price 5/33 = 0.1515 test per core - limit_order_id_type sell_id = create_sell_order( seller, core.amount(33), test.amount(5) )->id; + limit_order_id_type sell_id = create_sell_order( seller, core.amount(33), test.amount(5) )->get_id(); - BOOST_CHECK( !db.find_object( tmp_buy_id ) ); // buy order is filled + BOOST_CHECK( !db.find( tmp_buy_id ) ); // buy order is filled BOOST_CHECK_EQUAL( sell_id(db).for_sale.value, 16 ); // 17 core sold, 16 remaining BOOST_CHECK_EQUAL(get_balance(seller, core), 99999967); @@ -318,11 +318,11 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test2 ) // buyer buys 15 core with 3 test, price 3/15 = 0.2 test per core // even 15 < 16, since it's taker, we'll check with maker's price, then turns out the buy order is bigger - limit_order_id_type buy_id = create_sell_order( buyer_id, asset(3,test_id), asset(15,core_id) )->id; + limit_order_id_type buy_id = create_sell_order( buyer_id, asset(3,test_id), asset(15,core_id) )->get_id(); generate_block(); - BOOST_CHECK( !db.find_object( sell_id ) ); // sell order is filled + BOOST_CHECK( !db.find( sell_id ) ); // sell order is filled BOOST_CHECK_EQUAL( buy_id(db).for_sale.value, 1 ); // 2 test sold, 1 remaining BOOST_CHECK_EQUAL(get_balance(seller_id, core_id), 99999967); // seller paid the 16 core which was remaining in the order @@ -354,9 +354,9 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test2_after_hf_342 ) ACTORS( (seller)(buyer) ); const asset_object& test = create_user_issued_asset( "UIATEST" ); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); const asset_object& core = get_asset( GRAPHENE_SYMBOL ); - const asset_id_type core_id = core.id; + const asset_id_type core_id = core.get_id(); transfer( committee_account(db), seller, asset( 100000000 ) ); @@ -368,11 +368,11 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test2_after_hf_342 ) BOOST_CHECK_EQUAL(get_balance(seller, core), 100000000); // buyer buys 17 core with 3 test, price 3/17 = 0.176 test per core - limit_order_id_type tmp_buy_id = create_sell_order( buyer, test.amount(3), core.amount(17) )->id; + limit_order_id_type tmp_buy_id = create_sell_order( buyer, test.amount(3), core.amount(17) )->get_id(); // seller sells 33 core for 5 test, price 5/33 = 0.1515 test per core - limit_order_id_type sell_id = create_sell_order( seller, core.amount(33), test.amount(5) )->id; + limit_order_id_type sell_id = create_sell_order( seller, core.amount(33), test.amount(5) )->get_id(); - BOOST_CHECK( !db.find_object( tmp_buy_id ) ); // buy order is filled + BOOST_CHECK( !db.find( tmp_buy_id ) ); // buy order is filled BOOST_CHECK_EQUAL( sell_id(db).for_sale.value, 16 ); // 17 core sold, 16 remaining BOOST_CHECK_EQUAL(get_balance(seller, core), 99999967); @@ -385,11 +385,11 @@ BOOST_AUTO_TEST_CASE( limit_limit_rounding_test2_after_hf_342 ) // buyer buys 15 core with 3 test, price 3/15 = 0.2 test per core // even 15 < 16, since it's taker, we'll check with maker's price, then turns out the buy order is bigger - limit_order_id_type buy_id = create_sell_order( buyer_id, asset(3,test_id), asset(15,core_id) )->id; + limit_order_id_type buy_id = create_sell_order( buyer_id, asset(3,test_id), asset(15,core_id) )->get_id(); generate_block(); - BOOST_CHECK( !db.find_object( sell_id ) ); // sell order is filled + BOOST_CHECK( !db.find( sell_id ) ); // sell order is filled BOOST_CHECK_EQUAL( buy_id(db).for_sale.value, 1 ); // 2 test sold, 1 remaining BOOST_CHECK_EQUAL(get_balance(buyer_id, core_id), 31); // buyer got 14 more core according to price 0.1515 @@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test1 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -435,7 +435,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test1 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/175 CORE/USD = 62/700 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(100000), asset(15500)); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 @@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test1 ) // so the seller will pay 10 USD but get nothing. // The remaining 1 USD is too little to get any CORE, so the limit order will be cancelled BOOST_CHECK( !create_sell_order(seller, bitusd.amount(11), core.amount(1)) ); - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 200000, get_balance(seller, bitusd) ); // the seller paid 10 USD BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // the seller got nothing BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); @@ -501,7 +501,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test2 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -510,7 +510,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test2 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(10)); @@ -534,8 +534,8 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test2 ) // This would match with call at price 33 USD / 3 CORE, but call only owes 10 USD, // so the seller will pay 10 USD but get nothing. // The remaining USD will be left in the order on the market - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100010-33, get_balance(seller, bitusd) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // the seller got nothing BOOST_CHECK_EQUAL( 33-10, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -564,8 +564,8 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3 ) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - const asset_id_type bitusd_id = bitusd.id; - const asset_id_type core_id = core.id; + const asset_id_type bitusd_id = bitusd.get_id(); + const asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -583,7 +583,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(10)); @@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3 ) BOOST_CHECK_EQUAL( init_balance-1, get_balance(borrower, core) ); // create a limit order which will be matched later - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); BOOST_CHECK_EQUAL( 33, sell_id(db).for_sale.value ); BOOST_CHECK_EQUAL( 100010-33, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); @@ -615,7 +615,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3 ) // the limit order will match with call at price 33 USD / 3 CORE, but call only owes 10 USD, // so the seller will pay 10 USD but get nothing. // The remaining USD will be in the order on the market - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100010-33, get_balance(seller_id, bitusd_id) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 0, get_balance(seller_id, core_id) ); // the seller got nothing BOOST_CHECK_EQUAL( 33-10, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -649,7 +649,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test1_after_hardfork ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -658,7 +658,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test1_after_hardfork ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/175 CORE/USD = 62/700 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(100000), asset(15500)); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 @@ -689,7 +689,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test1_after_hardfork ) // Since the call would pay off all debt, let it pay 1 CORE from collateral // The remaining 1 USD is too little to get any CORE, so the limit order will be cancelled BOOST_CHECK( !create_sell_order(seller, bitusd.amount(11), core.amount(1)) ); - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 200000, get_balance(seller, bitusd) ); // the seller paid 10 USD BOOST_CHECK_EQUAL( 1, get_balance(seller, core) ); // the seller got 1 CORE BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); @@ -725,7 +725,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test2_after_hardfork ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -734,7 +734,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test2_after_hardfork ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(10)); @@ -759,8 +759,8 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test2_after_hardfork ) // but call only owes 10 USD, // Since the call would pay off all debt, let it pay 1 CORE from collateral // The remaining USD will be left in the order on the market - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100010-33, get_balance(seller, bitusd) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 1, get_balance(seller, core) ); // the seller got 1 CORE BOOST_CHECK_EQUAL( 33-10, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -790,8 +790,8 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3_after_hardfork ) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - const asset_id_type bitusd_id = bitusd.id; - const asset_id_type core_id = core.id; + const asset_id_type bitusd_id = bitusd.get_id(); + const asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -800,7 +800,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3_after_hardfork ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -809,7 +809,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3_after_hardfork ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(10), asset(1)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(10)); @@ -826,7 +826,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3_after_hardfork ) BOOST_CHECK_EQUAL( init_balance-1, get_balance(borrower, core) ); // create a limit order which will be matched later - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); BOOST_CHECK_EQUAL( 33, sell_id(db).for_sale.value ); BOOST_CHECK_EQUAL( 100010-33, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); @@ -841,7 +841,7 @@ BOOST_AUTO_TEST_CASE( issue_132_limit_and_call_test3_after_hardfork ) // the limit order will match with call at price 33 USD / 3 CORE, but call only owes 10 USD, // Since the call would pay off all debt, let it pay 1 CORE from collateral // The remaining USD will be in the order on the market - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100010-33, get_balance(seller_id, bitusd_id) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 1, get_balance(seller_id, core_id) ); // the seller got 1 CORE BOOST_CHECK_EQUAL( 33-10, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -876,7 +876,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test1 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -885,7 +885,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test1 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(20), asset(2)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(20)); @@ -910,8 +910,8 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test1 ) // so the seller will pay the whole 20 USD and get 1 CORE, since 20 USD doesn't worth 2 CORE according to price 33/3, // effective price is 20/1 which is worse than the limit order's desired 33/3. // The remaining USD will be left in the order on the market - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100020-33, get_balance(seller, bitusd) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 1, get_balance(seller, core) ); // the seller got 1 CORE BOOST_CHECK_EQUAL( 33-20, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -947,7 +947,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test1_after_hf_342 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -956,7 +956,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test1_after_hf_342 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(20), asset(2)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(20)); @@ -982,8 +982,8 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test1_after_hf_342 ) // so the seller will pay 20 USD and get 2 CORE, since 20 USD worths a little more than 1 CORE according to price 120/11, // effective price is 20/2 which is not worse than the limit order's desired 33/3. // The remaining USD will be left in the order on the market - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100020-33, get_balance(seller, bitusd) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 2, get_balance(seller, core) ); // the seller got 2 CORE BOOST_CHECK_EQUAL( 33-20, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -1021,7 +1021,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test2 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1030,7 +1030,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test2 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(20), asset(2)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(20)); @@ -1055,7 +1055,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test2 ) // so the seller will pay 15 USD and get 1 CORE, // effective price is 15/1. BOOST_CHECK( !create_sell_order(seller, bitusd.amount(15), core.amount(1)) ); // the sell order is filled - BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled + BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled BOOST_CHECK_EQUAL( 20-15, call.debt.value ); // call paid 15 USD BOOST_CHECK_EQUAL( 2-1, call.collateral.value ); // call got 1 CORE BOOST_CHECK_EQUAL( 100020-15, get_balance(seller, bitusd) ); // the seller paid 15 USD @@ -1093,7 +1093,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test2_after_hf_342 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1102,7 +1102,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test2_after_hf_342 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(20), asset(2)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(20)); @@ -1128,7 +1128,7 @@ BOOST_AUTO_TEST_CASE( limit_call_rounding_test2_after_hf_342 ) // and the extra 4 USD will be returned but not overpaid, // effective price is 11/1 which is close to 120/11. BOOST_CHECK( !create_sell_order(seller, bitusd.amount(15), core.amount(1)) ); // the sell order is filled - BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled + BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled BOOST_CHECK_EQUAL( 20-11, call.debt.value ); // call paid 11 USD BOOST_CHECK_EQUAL( 2-1, call.collateral.value ); // call got 1 CORE BOOST_CHECK_EQUAL( 100020-11, get_balance(seller, bitusd) ); // the seller paid 11 USD @@ -1156,8 +1156,8 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1 ) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - const asset_id_type bitusd_id = bitusd.id; - const asset_id_type core_id = core.id; + const asset_id_type bitusd_id = bitusd.get_id(); + const asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -1166,7 +1166,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1175,7 +1175,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(20), asset(2)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(20)); @@ -1192,7 +1192,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1 ) BOOST_CHECK_EQUAL( init_balance-2, get_balance(borrower, core) ); // create a limit order which will be matched later - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); BOOST_CHECK_EQUAL( 33, sell_id(db).for_sale.value ); BOOST_CHECK_EQUAL( 100020-33, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); @@ -1208,7 +1208,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1 ) // so the seller will pay the whole 20 USD and get 1 CORE, since 20 USD doesn't worth 2 CORE according to price 33/3, // effective price is 20/1 which is worse than the limit order's desired 33/3. // The remaining USD will be left in the order on the market - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100020-33, get_balance(seller_id, bitusd_id) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 1, get_balance(seller_id, core_id) ); // the seller got 1 CORE BOOST_CHECK_EQUAL( 33-20, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -1236,8 +1236,8 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1_after_hf_342 ) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - const asset_id_type bitusd_id = bitusd.id; - const asset_id_type core_id = core.id; + const asset_id_type bitusd_id = bitusd.get_id(); + const asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -1246,7 +1246,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1_after_hf_342 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1255,7 +1255,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1_after_hf_342 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(20), asset(2)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(20)); @@ -1272,7 +1272,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1_after_hf_342 ) BOOST_CHECK_EQUAL( init_balance-2, get_balance(borrower, core) ); // create a limit order which will be matched later - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->id; + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(33), core.amount(3))->get_id(); BOOST_CHECK_EQUAL( 33, sell_id(db).for_sale.value ); BOOST_CHECK_EQUAL( 100020-33, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); @@ -1288,7 +1288,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test1_after_hf_342 ) // so the seller will pay 20 USD and get 2 CORE, since 20 USD worths a little more than 1 CORE according to price 33/3, // effective price is 20/2 which is not worse than the limit order's desired 33/3. // The remaining USD will be left in the order on the market - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled BOOST_CHECK_EQUAL( 100020-33, get_balance(seller_id, bitusd_id) ); // the seller paid 33 USD BOOST_CHECK_EQUAL( 2, get_balance(seller_id, core_id) ); // the seller got 2 CORE BOOST_CHECK_EQUAL( 33-20, sell_id(db).for_sale.value ); // the sell order has some USD left @@ -1315,8 +1315,8 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2 ) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - const asset_id_type bitusd_id = bitusd.id; - const asset_id_type core_id = core.id; + const asset_id_type bitusd_id = bitusd.get_id(); + const asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -1325,7 +1325,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1334,7 +1334,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(50), asset(5)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(50)); @@ -1352,14 +1352,14 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2 ) BOOST_CHECK_EQUAL( init_balance-5, get_balance(borrower, core) ); // create a buy order which will be matched - limit_order_id_type buy_id = create_sell_order(buyer, core.amount(1), bitusd.amount(10))->id; + limit_order_id_type buy_id = create_sell_order(buyer, core.amount(1), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 1, buy_id(db).for_sale.value ); BOOST_CHECK_EQUAL( 1000000-1, get_balance(buyer, core) ); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); // create a limit order to fill the buy order, and remaining amounts will be matched later - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(31), core.amount(2))->id; - BOOST_CHECK( !db.find( buy_id ) ); // the buy order is filled + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(31), core.amount(2))->get_id(); + BOOST_CHECK( !db.find( buy_id ) ); // the buy order is filled BOOST_CHECK_EQUAL( 1000000-1, get_balance(buyer, core) ); BOOST_CHECK_EQUAL( 10, get_balance(buyer, bitusd) ); // buyer got 10 usd BOOST_CHECK_EQUAL( 21, sell_id(db).for_sale.value ); // remaining amount of sell order is 21 @@ -1367,7 +1367,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2 ) BOOST_CHECK_EQUAL( 1, get_balance(seller, core) ); // seller got 1 core // create another limit order which will be matched later - limit_order_id_type sell_id2 = create_sell_order(seller2, bitusd.amount(14), core.amount(1))->id; + limit_order_id_type sell_id2 = create_sell_order(seller2, bitusd.amount(14), core.amount(1))->get_id(); BOOST_CHECK_EQUAL( 14, sell_id2(db).for_sale.value ); BOOST_CHECK_EQUAL( 100000-14, get_balance(seller2, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller2, core) ); @@ -1385,9 +1385,9 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2 ) // effective price is 21/1 which is much bigger than 31/2; // then, call will match with sell_id2, which has 14 USD remaining, with price 14 USD / 1 CORE, // so the seller will pay 14 USD, get 1 CORE since 14 USD worths just 1 CORE according to price 14/1 - BOOST_CHECK( !db.find( sell_id ) ); // the sell order is filled - BOOST_CHECK( !db.find( sell_id2 ) ); // the other sell order is filled - BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled + BOOST_CHECK( !db.find( sell_id ) ); // the sell order is filled + BOOST_CHECK( !db.find( sell_id2 ) ); // the other sell order is filled + BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled BOOST_CHECK_EQUAL( 50-14-21, call_id(db).debt.value ); // call paid 14 USD and 21 USD BOOST_CHECK_EQUAL( 5-1-1, call_id(db).collateral.value ); // call got 1 CORE and 1 CORE BOOST_CHECK_EQUAL( 50-31, get_balance(seller_id, bitusd_id) ); // seller paid 31 USD in total @@ -1418,8 +1418,8 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2_after_hf_342 ) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - const asset_id_type bitusd_id = bitusd.id; - const asset_id_type core_id = core.id; + const asset_id_type bitusd_id = bitusd.get_id(); + const asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -1428,7 +1428,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2_after_hf_342 ) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1437,7 +1437,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2_after_hf_342 ) publish_feed( bitusd, feedproducer, current_feed ); // start out with 200% collateral, call price is 10/175 CORE/USD = 40/700 const call_order_object& call = *borrow( borrower, bitusd.amount(50), asset(5)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create yet another position with 350% collateral, call price is 17.5/175 CORE/USD = 77/700 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(100000), asset(17500)); transfer(borrower, seller, bitusd.amount(50)); @@ -1455,14 +1455,14 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2_after_hf_342 ) BOOST_CHECK_EQUAL( init_balance-5, get_balance(borrower, core) ); // create a buy order which will be matched - limit_order_id_type buy_id = create_sell_order(buyer, core.amount(1), bitusd.amount(10))->id; + limit_order_id_type buy_id = create_sell_order(buyer, core.amount(1), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 1, buy_id(db).for_sale.value ); BOOST_CHECK_EQUAL( 1000000-1, get_balance(buyer, core) ); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); // create a limit order to fill the buy order, and remaining amounts will be matched later - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(31), core.amount(2))->id; - BOOST_CHECK( !db.find( buy_id ) ); // the buy order is filled + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(31), core.amount(2))->get_id(); + BOOST_CHECK( !db.find( buy_id ) ); // the buy order is filled BOOST_CHECK_EQUAL( 1000000-1, get_balance(buyer, core) ); BOOST_CHECK_EQUAL( 10, get_balance(buyer, bitusd) ); // buyer got 10 usd BOOST_CHECK_EQUAL( 21, sell_id(db).for_sale.value ); // remaining amount of sell order is 21 @@ -1470,7 +1470,7 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2_after_hf_342 ) BOOST_CHECK_EQUAL( 1, get_balance(seller, core) ); // seller got 1 core // create another limit order which will be matched later - limit_order_id_type sell_id2 = create_sell_order(seller2, bitusd.amount(14), core.amount(1))->id; + limit_order_id_type sell_id2 = create_sell_order(seller2, bitusd.amount(14), core.amount(1))->get_id(); BOOST_CHECK_EQUAL( 14, sell_id2(db).for_sale.value ); BOOST_CHECK_EQUAL( 100000-14, get_balance(seller2, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller2, core) ); @@ -1490,9 +1490,9 @@ BOOST_AUTO_TEST_CASE( call_limit_rounding_test2_after_hf_342 ) // effective price is 16/1 which is close to 31/2; // secondly, call will match with sell_id2, which has 14 USD remaining, with price 14 USD / 1 CORE, // so the seller will get 1 CORE and pay 14 USD since 14 USD just worths 1 CORE according to price 14/1 - BOOST_CHECK( !db.find( sell_id ) ); // the sell order is filled - BOOST_CHECK( !db.find( sell_id2 ) ); // the other sell order is filled - BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled + BOOST_CHECK( !db.find( sell_id ) ); // the sell order is filled + BOOST_CHECK( !db.find( sell_id2 ) ); // the other sell order is filled + BOOST_CHECK( db.find( call_id ) != nullptr ); // the first call order did not get filled BOOST_CHECK_EQUAL( 50-14-16, call_id(db).debt.value ); // call paid 14 USD and 16 USD BOOST_CHECK_EQUAL( 5-1-1, call_id(db).collateral.value ); // call got 1 CORE and 1 CORE BOOST_CHECK_EQUAL( 50-31+(21-16), get_balance(seller_id, bitusd_id) ); // seller paid 31 USD then get refunded 5 USD diff --git a/tests/tests/market_tests.cpp b/tests/tests/market_tests.cpp index 3cbfcb84bf..aa0be76841 100644 --- a/tests/tests/market_tests.cpp +++ b/tests/tests/market_tests.cpp @@ -50,8 +50,8 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type usd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -68,13 +68,13 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(16000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); BOOST_CHECK_EQUAL( 1000, call.debt.value ); @@ -88,11 +88,11 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) // settlement price = 1/10, mssp = 1/11 // This order slightly below the call price will not be matched #606 - limit_order_id_type sell_low = create_sell_order(seller, bitusd.amount(7), core.amount(59))->id; + limit_order_id_type sell_low = create_sell_order(seller, bitusd.amount(7), core.amount(59))->get_id(); // This order above the MSSP will not be matched - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_med = create_sell_order(seller, bitusd.amount(7), core.amount(60))->id; + limit_order_id_type sell_med = create_sell_order(seller, bitusd.amount(7), core.amount(60))->get_id(); cancel_limit_order( sell_med(db) ); cancel_limit_order( sell_high(db) ); @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) BOOST_CHECK_EQUAL( 993, call.debt.value ); BOOST_CHECK_EQUAL( 14940, call.collateral.value ); - limit_order_id_type buy_low = create_sell_order(buyer, asset(90), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(90), bitusd.amount(10))->get_id(); // margin call takes precedence BOOST_CHECK( !create_sell_order(seller, bitusd.amount(7), core.amount(60)) ); BOOST_CHECK_EQUAL( 986, get_balance(seller, bitusd) ); @@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) BOOST_CHECK_EQUAL( 986, call.debt.value ); BOOST_CHECK_EQUAL( 14880, call.collateral.value ); - limit_order_id_type buy_med = create_sell_order(buyer, asset(105), bitusd.amount(10))->id; + limit_order_id_type buy_med = create_sell_order(buyer, asset(105), bitusd.amount(10))->get_id(); // margin call takes precedence BOOST_CHECK( !create_sell_order(seller, bitusd.amount(7), core.amount(70)) ); BOOST_CHECK_EQUAL( 979, get_balance(seller, bitusd) ); @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) BOOST_CHECK_EQUAL( 979, call.debt.value ); BOOST_CHECK_EQUAL( 14810, call.collateral.value ); - limit_order_id_type buy_high = create_sell_order(buyer, asset(115), bitusd.amount(10))->id; + limit_order_id_type buy_high = create_sell_order(buyer, asset(115), bitusd.amount(10))->get_id(); // margin call still has precedence (!) #625 BOOST_CHECK( !create_sell_order(seller, bitusd.amount(7), core.amount(77)) ); BOOST_CHECK_EQUAL( 972, get_balance(seller, bitusd) ); @@ -203,26 +203,26 @@ BOOST_AUTO_TEST_CASE(issue_338_etc) transfer(borrower3_id, seller_id, asset(1000, usd_id)); // Re-create sell_low, slightly below the call price, will not be matched, will expire soon - sell_low = create_sell_order(seller_id(db), asset(7, usd_id), asset(59), db.head_block_time()+fc::seconds(300) )->id; + sell_low = create_sell_order(seller_id(db), asset(7, usd_id), asset(59), db.head_block_time()+fc::seconds(300) )->get_id(); // This would match but is blocked by sell_low, it has an amount same as call's debt which will be full filled later - sell_med = create_sell_order(seller_id(db), asset(262, usd_id), asset(2620))->id; // 1/10 + sell_med = create_sell_order(seller_id(db), asset(262, usd_id), asset(2620))->get_id(); // 1/10 // Another big order above sell_med, blocked - limit_order_id_type sell_med2 = create_sell_order(seller_id(db), asset(1200, usd_id), asset(12120))->id; // 1/10.1 + limit_order_id_type sell_med2 = create_sell_order(seller_id(db), asset(1200, usd_id), asset(12120))->get_id(); // 1/10.1 // Another small order above sell_med2, blocked - limit_order_id_type sell_med3 = create_sell_order(seller_id(db), asset(120, usd_id), asset(1224))->id; // 1/10.2 + limit_order_id_type sell_med3 = create_sell_order(seller_id(db), asset(120, usd_id), asset(1224))->get_id(); // 1/10.2 // generate a block, sell_low will expire BOOST_TEST_MESSAGE( "Expire sell_low" ); generate_blocks( HARDFORK_615_TIME + fc::hours(26) ); - BOOST_CHECK( db.find( sell_low ) == nullptr ); + BOOST_CHECK( db.find( sell_low ) == nullptr ); // #453 multiple order matching issue occurs - BOOST_CHECK( db.find( sell_med ) == nullptr ); // sell_med get filled - BOOST_CHECK( db.find( sell_med2 ) != nullptr ); // sell_med2 is still there - BOOST_CHECK( db.find( sell_med3 ) == nullptr ); // sell_med3 get filled - BOOST_CHECK( db.find( call_id ) == nullptr ); // the first call order get filled - BOOST_CHECK( db.find( call2_id ) == nullptr ); // the second call order get filled - BOOST_CHECK( db.find( call3_id ) != nullptr ); // the third call order is still there + BOOST_CHECK( db.find( sell_med ) == nullptr ); // sell_med get filled + BOOST_CHECK( db.find( sell_med2 ) != nullptr ); // sell_med2 is still there + BOOST_CHECK( db.find( sell_med3 ) == nullptr ); // sell_med3 get filled + BOOST_CHECK( db.find( call_id ) == nullptr ); // the first call order get filled + BOOST_CHECK( db.find( call2_id ) == nullptr ); // the second call order get filled + BOOST_CHECK( db.find( call3_id ) != nullptr ); // the third call order is still there } FC_LOG_AND_RETHROW() } @@ -250,8 +250,8 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type usd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -268,13 +268,13 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(16000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -300,11 +300,11 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(90), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(90), bitusd.amount(10))->get_id(); // This buy order at MSSP will be matched only if no margin call (margin call takes precedence) - limit_order_id_type buy_med = create_sell_order(buyer, asset(110), bitusd.amount(10))->id; + limit_order_id_type buy_med = create_sell_order(buyer, asset(110), bitusd.amount(10))->get_id(); // This buy order above MSSP will be matched with a sell order (limit order with better price takes precedence) - limit_order_id_type buy_high = create_sell_order(buyer, asset(111), bitusd.amount(10))->id; + limit_order_id_type buy_high = create_sell_order(buyer, asset(111), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 90 - 110 - 111, get_balance(buyer, core) ); @@ -313,9 +313,9 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) BOOST_CHECK( !create_sell_order(seller, bitusd.amount(700), core.amount(5900) ) ); // firstly it will match with buy_high, at buy_high's price: #625 fixed - BOOST_CHECK( !db.find( buy_high ) ); - BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 110 ); - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 90 ); + BOOST_CHECK( !db.find( buy_high ) ); + BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 110 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 90 ); // buy_high pays 111 CORE, receives 10 USD goes to buyer's balance BOOST_CHECK_EQUAL( 10, get_balance(buyer, bitusd) ); @@ -339,8 +339,8 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) // This would match with call before, but would match with call2 after #343 fixed BOOST_CHECK( !create_sell_order(seller, bitusd.amount(700), core.amount(6000) ) ); - BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 110 ); - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 90 ); + BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 110 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 90 ); // fill price would be mssp: 1/11 = 700/7700 : #338 fixed BOOST_CHECK_EQUAL( 1593, get_balance(seller, bitusd) ); @@ -420,9 +420,9 @@ BOOST_AUTO_TEST_CASE(hardfork_core_338_test) // black swan event will occur: #649 fixed BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); // short positions will be closed - BOOST_CHECK( !db.find( call_id ) ); - BOOST_CHECK( !db.find( call2_id ) ); - BOOST_CHECK( !db.find( call3_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call3_id ) ); // generate a block generate_block(); @@ -453,7 +453,7 @@ BOOST_AUTO_TEST_CASE(hardfork_core_453_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); int64_t init_balance(1000000); @@ -461,7 +461,7 @@ BOOST_AUTO_TEST_CASE(hardfork_core_453_test) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -470,13 +470,13 @@ BOOST_AUTO_TEST_CASE(hardfork_core_453_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(16000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -493,11 +493,11 @@ BOOST_AUTO_TEST_CASE(hardfork_core_453_test) // no margin call so far // This order would match call when it's margin called, it has an amount same as call's debt which will be full filled later - limit_order_id_type sell_med = create_sell_order(seller_id(db), asset(1000, usd_id), asset(10000))->id; // 1/10 + limit_order_id_type sell_med = create_sell_order(seller_id(db), asset(1000, usd_id), asset(10000))->get_id(); // 1/10 // Another big order above sell_med, amount bigger than call2's debt - limit_order_id_type sell_med2 = create_sell_order(seller_id(db), asset(1200, usd_id), asset(12120))->id; // 1/10.1 + limit_order_id_type sell_med2 = create_sell_order(seller_id(db), asset(1200, usd_id), asset(12120))->get_id(); // 1/10.1 // Another small order above sell_med2 - limit_order_id_type sell_med3 = create_sell_order(seller_id(db), asset(120, usd_id), asset(1224))->id; // 1/10.2 + limit_order_id_type sell_med3 = create_sell_order(seller_id(db), asset(120, usd_id), asset(1224))->get_id(); // 1/10.2 // adjust price feed to get the call orders into margin call territory current_feed.settlement_price = bitusd.amount( 1 ) / core.amount(10); @@ -505,12 +505,12 @@ BOOST_AUTO_TEST_CASE(hardfork_core_453_test) // settlement price = 1/10, mssp = 1/11 // Fixed #453 multiple order matching issue occurs - BOOST_CHECK( !db.find( sell_med ) ); // sell_med get filled - BOOST_CHECK( !db.find( sell_med2 ) ); // sell_med2 get filled - BOOST_CHECK( !db.find( sell_med3 ) ); // sell_med3 get filled - BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled - BOOST_CHECK( !db.find( call2_id ) ); // the second call order get filled - BOOST_CHECK( db.find( call3_id ) ); // the third call order is still there + BOOST_CHECK( !db.find( sell_med ) ); // sell_med get filled + BOOST_CHECK( !db.find( sell_med2 ) ); // sell_med2 get filled + BOOST_CHECK( !db.find( sell_med3 ) ); // sell_med3 get filled + BOOST_CHECK( !db.find( call_id ) ); // the first call order get filled + BOOST_CHECK( !db.find( call2_id ) ); // the second call order get filled + BOOST_CHECK( db.find( call3_id ) ); // the third call order is still there // generate a block generate_block(); @@ -549,7 +549,7 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -558,10 +558,10 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/1.75 CORE/USD = 100/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(25000)); transfer(borrower, seller, bitusd.amount(1000)); @@ -590,18 +590,18 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) // settlement price = 1/10, mssp = 1/11 // This sell order above MSSP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); BOOST_CHECK_EQUAL( 2993, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->get_id(); // This buy order at MSSP will be matched only if no margin call (margin call takes precedence) - limit_order_id_type buy_med = create_sell_order(buyer2, asset(11000), bitusd.amount(1000))->id; + limit_order_id_type buy_med = create_sell_order(buyer2, asset(11000), bitusd.amount(1000))->get_id(); // This buy order above MSSP will be matched with a sell order (limit order with better price takes precedence) - limit_order_id_type buy_high = create_sell_order(buyer3, asset(111), bitusd.amount(10))->id; + limit_order_id_type buy_high = create_sell_order(buyer3, asset(111), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(buyer2, bitusd) ); @@ -614,19 +614,19 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) BOOST_CHECK( !create_sell_order(seller, bitusd.amount(700*4), core.amount(5900*4) ) ); // firstly it will match with buy_high, at buy_high's price - BOOST_CHECK( !db.find( buy_high ) ); + BOOST_CHECK( !db.find( buy_high ) ); // buy_high pays 111 CORE, receives 10 USD goes to buyer3's balance BOOST_CHECK_EQUAL( 10, get_balance(buyer3, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 111, get_balance(buyer3, core) ); // then it will match with call, at mssp: 1/11 = 1000/11000 - BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call_id ) ); // call pays 11000 CORE, receives 1000 USD to cover borrower's position, remaining CORE goes to borrower's balance BOOST_CHECK_EQUAL( init_balance - 11000, get_balance(borrower, core) ); BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); // then it will match with call2, at mssp: 1/11 = 1000/11000 - BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); // call2 pays 11000 CORE, receives 1000 USD to cover borrower2's position, remaining CORE goes to borrower2's balance BOOST_CHECK_EQUAL( init_balance - 11000, get_balance(borrower2, core) ); BOOST_CHECK_EQUAL( 0, get_balance(borrower2, bitusd) ); @@ -636,14 +636,14 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) BOOST_CHECK_EQUAL( 783, get_balance(buyer2, bitusd) ); // 700*4-10-1000-1000=790, minus 1% market fee 790*100/10000=7 BOOST_CHECK_EQUAL( init_balance - 11000, get_balance(buyer2, core) ); // buy_med pays at 1/11 = 790/8690 - BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 11000-8690 ); + BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 11000-8690 ); // call3 is not in margin call territory so won't be matched BOOST_CHECK_EQUAL( 1000, call3.debt.value ); BOOST_CHECK_EQUAL( 25000, call3.collateral.value ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // check seller balance BOOST_CHECK_EQUAL( 193, get_balance(seller, bitusd) ); // 3000 - 7 - 700*4 @@ -651,13 +651,13 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) // Cancel buy_med cancel_limit_order( buy_med(db) ); - BOOST_CHECK( !db.find( buy_med ) ); + BOOST_CHECK( !db.find( buy_med ) ); BOOST_CHECK_EQUAL( 783, get_balance(buyer2, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 8690, get_balance(buyer2, core) ); // Create another sell order slightly below the call price, won't fill - limit_order_id_type sell_med = create_sell_order( seller, bitusd.amount(7), core.amount(59) )->id; - BOOST_CHECK_EQUAL( db.find( sell_med )->for_sale.value, 7 ); + limit_order_id_type sell_med = create_sell_order( seller, bitusd.amount(7), core.amount(59) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_med )->for_sale.value, 7 ); // check seller balance BOOST_CHECK_EQUAL( 193-7, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 30801, get_balance(seller, core) ); @@ -667,7 +667,7 @@ BOOST_AUTO_TEST_CASE(hardfork_core_625_big_limit_order_test) BOOST_CHECK_EQUAL( 25000, call3.collateral.value ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // generate a block generate_block(); @@ -691,10 +691,10 @@ BOOST_AUTO_TEST_CASE(hard_fork_453_cross_test) const auto& biteur = create_bitasset("EURBIT", feedproducer_id); const auto& bitcny = create_bitasset("CNYBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; - asset_id_type eur_id = biteur.id; - asset_id_type cny_id = bitcny.id; - asset_id_type core_id = core.id; + asset_id_type usd_id = bitusd.get_id(); + asset_id_type eur_id = biteur.get_id(); + asset_id_type cny_id = bitcny.get_id(); + asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -702,9 +702,9 @@ BOOST_AUTO_TEST_CASE(hard_fork_453_cross_test) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); - update_feed_producers( biteur, {feedproducer.id} ); - update_feed_producers( bitcny, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); + update_feed_producers( biteur, {feedproducer.get_id()} ); + update_feed_producers( bitcny, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -717,25 +717,25 @@ BOOST_AUTO_TEST_CASE(hard_fork_453_cross_test) publish_feed( bitcny, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call_usd = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_usd_id = call_usd.id; + call_order_id_type call_usd_id = call_usd.get_id(); const call_order_object& call_eur = *borrow( borrower, biteur.amount(1000), asset(15000)); - call_order_id_type call_eur_id = call_eur.id; + call_order_id_type call_eur_id = call_eur.get_id(); const call_order_object& call_cny = *borrow( borrower, bitcny.amount(1000), asset(15000)); - call_order_id_type call_cny_id = call_cny.id; + call_order_id_type call_cny_id = call_cny.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call_usd2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call_usd2_id = call_usd2.id; + call_order_id_type call_usd2_id = call_usd2.get_id(); const call_order_object& call_eur2 = *borrow( borrower2, biteur.amount(1000), asset(15500)); - call_order_id_type call_eur2_id = call_eur2.id; + call_order_id_type call_eur2_id = call_eur2.get_id(); const call_order_object& call_cny2 = *borrow( borrower2, bitcny.amount(1000), asset(15500)); - call_order_id_type call_cny2_id = call_cny2.id; + call_order_id_type call_cny2_id = call_cny2.get_id(); // create yet another position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7 const call_order_object& call_usd3 = *borrow( borrower3, bitusd.amount(1000), asset(16000)); - call_order_id_type call_usd3_id = call_usd3.id; + call_order_id_type call_usd3_id = call_usd3.get_id(); const call_order_object& call_eur3 = *borrow( borrower3, biteur.amount(1000), asset(16000)); - call_order_id_type call_eur3_id = call_eur3.id; + call_order_id_type call_eur3_id = call_eur3.get_id(); const call_order_object& call_cny3 = *borrow( borrower3, bitcny.amount(1000), asset(16000)); - call_order_id_type call_cny3_id = call_cny3.id; + call_order_id_type call_cny3_id = call_cny3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -779,37 +779,37 @@ BOOST_AUTO_TEST_CASE(hard_fork_453_cross_test) // settlement price = 1/10, mssp = 1/11 // This order below the call price will not be matched before hard fork: 1/8 #606 - limit_order_id_type sell_usd_low = create_sell_order(seller, bitusd.amount(1000), core.amount(7000))->id; + limit_order_id_type sell_usd_low = create_sell_order(seller, bitusd.amount(1000), core.amount(7000))->get_id(); // This is a big order, price below the call price will not be matched before hard fork: 1007/9056 = 1/8 #606 - limit_order_id_type sell_usd_low2 = create_sell_order(seller, bitusd.amount(1007), core.amount(8056))->id; + limit_order_id_type sell_usd_low2 = create_sell_order(seller, bitusd.amount(1007), core.amount(8056))->get_id(); // This order above the MSSP will not be matched before hard fork - limit_order_id_type sell_usd_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; + limit_order_id_type sell_usd_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_usd_med = create_sell_order(seller, bitusd.amount(700), core.amount(6400))->id; + limit_order_id_type sell_usd_med = create_sell_order(seller, bitusd.amount(700), core.amount(6400))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_usd_med2 = create_sell_order(seller, bitusd.amount(7), core.amount(65))->id; + limit_order_id_type sell_usd_med2 = create_sell_order(seller, bitusd.amount(7), core.amount(65))->get_id(); // This order below the call price will not be matched before hard fork: 1/8 #606 - limit_order_id_type sell_eur_low = create_sell_order(seller, biteur.amount(1000), core.amount(7000))->id; + limit_order_id_type sell_eur_low = create_sell_order(seller, biteur.amount(1000), core.amount(7000))->get_id(); // This is a big order, price below the call price will not be matched before hard fork: 1007/9056 = 1/8 #606 - limit_order_id_type sell_eur_low2 = create_sell_order(seller, biteur.amount(1007), core.amount(8056))->id; + limit_order_id_type sell_eur_low2 = create_sell_order(seller, biteur.amount(1007), core.amount(8056))->get_id(); // This order above the MSSP will not be matched before hard fork - limit_order_id_type sell_eur_high = create_sell_order(seller, biteur.amount(7), core.amount(78))->id; + limit_order_id_type sell_eur_high = create_sell_order(seller, biteur.amount(7), core.amount(78))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_eur_med = create_sell_order(seller, biteur.amount(700), core.amount(6400))->id; + limit_order_id_type sell_eur_med = create_sell_order(seller, biteur.amount(700), core.amount(6400))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_eur_med2 = create_sell_order(seller, biteur.amount(7), core.amount(65))->id; + limit_order_id_type sell_eur_med2 = create_sell_order(seller, biteur.amount(7), core.amount(65))->get_id(); // This order below the call price will not be matched before hard fork: 1/8 #606 - limit_order_id_type sell_cny_low = create_sell_order(seller, bitcny.amount(1000), core.amount(7000))->id; + limit_order_id_type sell_cny_low = create_sell_order(seller, bitcny.amount(1000), core.amount(7000))->get_id(); // This is a big order, price below the call price will not be matched before hard fork: 1007/9056 = 1/8 #606 - limit_order_id_type sell_cny_low2 = create_sell_order(seller, bitcny.amount(1007), core.amount(8056))->id; + limit_order_id_type sell_cny_low2 = create_sell_order(seller, bitcny.amount(1007), core.amount(8056))->get_id(); // This order above the MSSP will not be matched before hard fork - limit_order_id_type sell_cny_high = create_sell_order(seller, bitcny.amount(7), core.amount(78))->id; + limit_order_id_type sell_cny_high = create_sell_order(seller, bitcny.amount(7), core.amount(78))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_cny_med = create_sell_order(seller, bitcny.amount(700), core.amount(6400))->id; + limit_order_id_type sell_cny_med = create_sell_order(seller, bitcny.amount(700), core.amount(6400))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_cny_med2 = create_sell_order(seller, bitcny.amount(7), core.amount(65))->id; + limit_order_id_type sell_cny_med2 = create_sell_order(seller, bitcny.amount(7), core.amount(65))->get_id(); BOOST_CHECK_EQUAL( 3000-1000-1007-7-700-7, get_balance(seller_id, usd_id) ); BOOST_CHECK_EQUAL( 3000-1000-1007-7-700-7, get_balance(seller_id, eur_id) ); @@ -822,46 +822,46 @@ BOOST_AUTO_TEST_CASE(hard_fork_453_cross_test) generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); // sell_low and call should get matched first - BOOST_CHECK( !db.find( sell_usd_low ) ); - BOOST_CHECK( !db.find( call_usd_id ) ); + BOOST_CHECK( !db.find( sell_usd_low ) ); + BOOST_CHECK( !db.find( call_usd_id ) ); // sell_low2 and call2 should get matched - BOOST_CHECK( !db.find( call_usd2_id ) ); + BOOST_CHECK( !db.find( call_usd2_id ) ); // sell_low2 and call3 should get matched: fixed #453 - BOOST_CHECK( !db.find( sell_usd_low2 ) ); + BOOST_CHECK( !db.find( sell_usd_low2 ) ); // sell_med and call3 should get matched - BOOST_CHECK( !db.find( sell_usd_med ) ); + BOOST_CHECK( !db.find( sell_usd_med ) ); // call3 now is not at margin call state, so sell_med2 won't get matched - BOOST_CHECK_EQUAL( db.find( sell_usd_med2 )->for_sale.value, 7 ); + BOOST_CHECK_EQUAL( db.find( sell_usd_med2 )->for_sale.value, 7 ); // sell_high should still be there, didn't match anything - BOOST_CHECK_EQUAL( db.find( sell_usd_high )->for_sale.value, 7 ); + BOOST_CHECK_EQUAL( db.find( sell_usd_high )->for_sale.value, 7 ); // sell_low and call should get matched first - BOOST_CHECK( !db.find( sell_eur_low ) ); - BOOST_CHECK( !db.find( call_eur_id ) ); + BOOST_CHECK( !db.find( sell_eur_low ) ); + BOOST_CHECK( !db.find( call_eur_id ) ); // sell_low2 and call2 should get matched - BOOST_CHECK( !db.find( call_eur2_id ) ); + BOOST_CHECK( !db.find( call_eur2_id ) ); // sell_low2 and call3 should get matched: fixed #453 - BOOST_CHECK( !db.find( sell_eur_low2 ) ); + BOOST_CHECK( !db.find( sell_eur_low2 ) ); // sell_med and call3 should get matched - BOOST_CHECK( !db.find( sell_eur_med ) ); + BOOST_CHECK( !db.find( sell_eur_med ) ); // call3 now is not at margin call state, so sell_med2 won't get matched - BOOST_CHECK_EQUAL( db.find( sell_eur_med2 )->for_sale.value, 7 ); + BOOST_CHECK_EQUAL( db.find( sell_eur_med2 )->for_sale.value, 7 ); // sell_high should still be there, didn't match anything - BOOST_CHECK_EQUAL( db.find( sell_eur_high )->for_sale.value, 7 ); + BOOST_CHECK_EQUAL( db.find( sell_eur_high )->for_sale.value, 7 ); // sell_low and call should get matched first - BOOST_CHECK( !db.find( sell_cny_low ) ); - BOOST_CHECK( !db.find( call_cny_id ) ); + BOOST_CHECK( !db.find( sell_cny_low ) ); + BOOST_CHECK( !db.find( call_cny_id ) ); // sell_low2 and call2 should get matched - BOOST_CHECK( !db.find( call_cny2_id ) ); + BOOST_CHECK( !db.find( call_cny2_id ) ); // sell_low2 and call3 should get matched: fixed #453 - BOOST_CHECK( !db.find( sell_cny_low2 ) ); + BOOST_CHECK( !db.find( sell_cny_low2 ) ); // sell_med and call3 should get matched - BOOST_CHECK( !db.find( sell_cny_med ) ); + BOOST_CHECK( !db.find( sell_cny_med ) ); // call3 now is not at margin call state, so sell_med2 won't get matched - BOOST_CHECK_EQUAL( db.find( sell_cny_med2 )->for_sale.value, 7 ); + BOOST_CHECK_EQUAL( db.find( sell_cny_med2 )->for_sale.value, 7 ); // sell_high should still be there, didn't match anything - BOOST_CHECK_EQUAL( db.find( sell_cny_high )->for_sale.value, 7 ); + BOOST_CHECK_EQUAL( db.find( sell_cny_high )->for_sale.value, 7 ); // all match price would be limit order price BOOST_CHECK_EQUAL( 3000-1000-1007-7-700-7, get_balance(seller_id, usd_id) ); @@ -898,8 +898,8 @@ BOOST_AUTO_TEST_CASE(hard_fork_338_cross_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type usd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -908,7 +908,7 @@ BOOST_AUTO_TEST_CASE(hard_fork_338_cross_test) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -917,16 +917,16 @@ BOOST_AUTO_TEST_CASE(hard_fork_338_cross_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(16000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); // create yet another position with 400% collateral, call price is 20/1.75 CORE/USD = 80/7 const call_order_object& call4 = *borrow( borrower4, bitusd.amount(1000), asset(20000)); - call_order_id_type call4_id = call4.id; + call_order_id_type call4_id = call4.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -946,11 +946,11 @@ BOOST_AUTO_TEST_CASE(hard_fork_338_cross_test) // settlement price = 1/10, mssp = 1/11 // This order below the call price will not be matched before hard fork: 1/8 #606 - limit_order_id_type sell_low = create_sell_order(seller, bitusd.amount(1000), core.amount(7000))->id; + limit_order_id_type sell_low = create_sell_order(seller, bitusd.amount(1000), core.amount(7000))->get_id(); // This is a big order, price below the call price will not be matched before hard fork: 1007/9056 = 1/8 #606 - limit_order_id_type sell_low2 = create_sell_order(seller, bitusd.amount(1007), core.amount(8056))->id; + limit_order_id_type sell_low2 = create_sell_order(seller, bitusd.amount(1007), core.amount(8056))->get_id(); // This would match but is blocked by sell_low?! #606 - limit_order_id_type sell_med = create_sell_order(seller, bitusd.amount(7), core.amount(64))->id; + limit_order_id_type sell_med = create_sell_order(seller, bitusd.amount(7), core.amount(64))->get_id(); // adjust price feed to get call_order into black swan territory current_feed.settlement_price = bitusd.amount( 1 ) / core.amount(16); @@ -969,22 +969,22 @@ BOOST_AUTO_TEST_CASE(hard_fork_338_cross_test) generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); // sell_low and call should get matched first - BOOST_CHECK( !db.find( sell_low ) ); - BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( sell_low ) ); + BOOST_CHECK( !db.find( call_id ) ); // sell_low2 and call2 should get matched - BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); // sell_low2 and call3 should get matched: fixed #453 - BOOST_CHECK( !db.find( sell_low2 ) ); + BOOST_CHECK( !db.find( sell_low2 ) ); // sell_med and call3 should get matched - BOOST_CHECK( !db.find( sell_med ) ); + BOOST_CHECK( !db.find( sell_med ) ); // at this moment, // collateralization of call3 is (16000-56-64) / (1000-7-7) = 15880/986 = 16.1, it's > 16 but < 17.6 // although there is no sell order, it should trigger a black swan event right away, // because after hard fork new limit order won't trigger black swan event BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call3_id ) ); - BOOST_CHECK( !db.find( call4_id ) ); + BOOST_CHECK( !db.find( call3_id ) ); + BOOST_CHECK( !db.find( call4_id ) ); // since 16.1 > 16, global settlement should at feed price 16/1 // so settlement fund should be 986*16 + 1000*16 @@ -1018,8 +1018,8 @@ BOOST_AUTO_TEST_CASE(hard_fork_649_cross_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type usd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -1028,7 +1028,7 @@ BOOST_AUTO_TEST_CASE(hard_fork_649_cross_test) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1037,13 +1037,13 @@ BOOST_AUTO_TEST_CASE(hard_fork_649_cross_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 320% collateral, call price is 16/1.75 CORE/USD = 64/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(16000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -1094,9 +1094,9 @@ BOOST_AUTO_TEST_CASE(hard_fork_649_cross_test) // a black swan event should occur BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); - BOOST_CHECK( !db.find( call2_id ) ); - BOOST_CHECK( !db.find( call3_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call3_id ) ); // since least collateral ratio 15.5 < 20, global settlement should execute at price = least collateral ratio 15.5/1 // so settlement fund should be 15500 + 15500 + round_up(15.5 * 293) @@ -1132,8 +1132,8 @@ BOOST_AUTO_TEST_CASE(hard_fork_343_cross_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type usd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); int64_t init_balance(1000000); @@ -1142,7 +1142,7 @@ BOOST_AUTO_TEST_CASE(hard_fork_343_cross_test) transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); transfer(committee_account, borrower4_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1151,13 +1151,13 @@ BOOST_AUTO_TEST_CASE(hard_fork_343_cross_test) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 350% collateral, call price is 17.5/1.75 CORE/USD = 77/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(17500)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -1248,7 +1248,7 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); int64_t init_balance(1000000); @@ -1268,7 +1268,7 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test) PUSH_TX(db, trx, ~0); } - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1278,10 +1278,10 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test) // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 400% collateral, call price is 20/1.75 CORE/USD = 80/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(20000)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); @@ -1295,7 +1295,7 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test) // No margin call at this moment // This order is sufficient to close the first debt position and no GS if margin call fee ratio is 0 - limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(1000), core.amount(14900))->id; + limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(1000), core.amount(14900))->get_id(); BOOST_CHECK_EQUAL( 1000, sell_mid(db).for_sale.value ); @@ -1314,8 +1314,8 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test) // GS occurs even when there is a good sell order BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); - BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); // GS price is 1/18, but the first call order has only 15000 thus capped BOOST_CHECK_EQUAL( 15000 + 18000, usd_id(db).bitasset_data(db).settlement_fund.value ); @@ -1345,7 +1345,7 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test_after_hf_core_2481) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); int64_t init_balance(1000000); @@ -1366,7 +1366,7 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test_after_hf_core_2481) PUSH_TX(db, trx, ~0); } - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1376,13 +1376,13 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test_after_hf_core_2481) // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 400% collateral, call price is 20/1.75 CORE/USD = 80/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(20000)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 800% collateral, call price is 40/1.75 CORE/USD = 160/7 const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(40000)); - call_order_id_type call3_id = call3.id; + call_order_id_type call3_id = call3.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); transfer(borrower3, seller, bitusd.amount(1000)); @@ -1399,7 +1399,7 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test_after_hf_core_2481) // No margin call at this moment // This order is sufficient to close the first debt position and no GS if margin call fee ratio is 0 - limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(1000), core.amount(14900))->id; + limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(1000), core.amount(14900))->get_id(); BOOST_CHECK_EQUAL( 1000, sell_mid(db).for_sale.value ); @@ -1420,9 +1420,9 @@ BOOST_AUTO_TEST_CASE(mcfr_blackswan_test_after_hf_core_2481) // GS occurs even when there is a good sell order BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); - BOOST_CHECK( !db.find( call2_id ) ); - BOOST_CHECK( !db.find( call3_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call3_id ) ); // after the core-2481 hard fork, GS price is not 1/18. // * the first call order would pay all collateral. @@ -1464,14 +1464,14 @@ BOOST_AUTO_TEST_CASE(gs_price_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); int64_t init_balance(1000000); transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1481,10 +1481,10 @@ BOOST_AUTO_TEST_CASE(gs_price_test) // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 800% collateral, call price is 40/1.75 CORE/USD = 160/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(40000)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); @@ -1498,7 +1498,7 @@ BOOST_AUTO_TEST_CASE(gs_price_test) // No margin call at this moment // This order is right at MSSP of the first debt position - limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(2000), core.amount(30000))->id; + limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(2000), core.amount(30000))->get_id(); BOOST_CHECK_EQUAL( 2000, sell_mid(db).for_sale.value ); @@ -1518,8 +1518,8 @@ BOOST_AUTO_TEST_CASE(gs_price_test) { // GS occurs BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); - BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); // sell order did not change BOOST_CHECK_EQUAL( 2000, sell_mid(db).for_sale.value ); } @@ -1527,7 +1527,7 @@ BOOST_AUTO_TEST_CASE(gs_price_test) { // GS does not occur, call got filled BOOST_CHECK( !usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call_id ) ); // sell order got half-filled BOOST_CHECK_EQUAL( 1000, sell_mid(db).for_sale.value ); @@ -1572,7 +1572,7 @@ BOOST_AUTO_TEST_CASE(mcfr_rounding_test) const auto& bitusd = create_bitasset("USDBIT", feedproducer_id); const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); int64_t init_balance(1000000); @@ -1604,10 +1604,10 @@ BOOST_AUTO_TEST_CASE(mcfr_rounding_test) // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7 const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000)); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 800% collateral, call price is 40/1.75 CORE/USD = 160/7 const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(40000)); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); transfer(borrower, seller, bitusd.amount(1000)); transfer(borrower2, seller, bitusd.amount(1000)); @@ -1623,7 +1623,7 @@ BOOST_AUTO_TEST_CASE(mcfr_rounding_test) // No margin call at this moment // This order would be matched later - limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(1100), core.amount(15451))->id; + limit_order_id_type sell_mid = create_sell_order(seller, bitusd.amount(1100), core.amount(15451))->get_id(); // call_pays_price = (15451 / 1100) * 1100 / (1100-70) = 15451 / 1030 // debt * call_pays_price = 1000 * 15451 / 1030 = 15000.9 @@ -1649,8 +1649,8 @@ BOOST_AUTO_TEST_CASE(mcfr_rounding_test) // blackswan BOOST_CHECK( usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); - BOOST_CHECK( !db.find( call2_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_CHECK( !db.find( call2_id ) ); int64_t call_pays_to_fund = (15000 * 10 + 10) / 11; BOOST_CHECK_EQUAL( usd_id(db).bitasset_data(db).settlement_fund.value, call_pays_to_fund * 2 ); @@ -1697,8 +1697,8 @@ BOOST_AUTO_TEST_CASE(mcfr_rounding_test) // The first call order should have been filled BOOST_CHECK( !usd_id(db).bitasset_data(db).has_settlement() ); - BOOST_CHECK( !db.find( call_id ) ); - BOOST_REQUIRE( db.find( call2_id ) ); + BOOST_CHECK( !db.find( call_id ) ); + BOOST_REQUIRE( db.find( call2_id ) ); BOOST_CHECK_EQUAL( 100, sell_mid(db).for_sale.value ); @@ -1746,7 +1746,7 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1755,10 +1755,10 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7, tcr 200% is higher than 175% const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500), 2000); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/1.75 CORE/USD = 100/7, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(25000)); transfer(borrower, seller, bitusd.amount(1000)); @@ -1787,18 +1787,18 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) // settlement price = 1/10, mssp = 1/11 // This sell order above MSSP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); BOOST_CHECK_EQUAL( 2993, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->get_id(); // This buy order at MSSP will be matched only if no margin call (margin call takes precedence) - limit_order_id_type buy_med = create_sell_order(buyer2, asset(33000), bitusd.amount(3000))->id; + limit_order_id_type buy_med = create_sell_order(buyer2, asset(33000), bitusd.amount(3000))->get_id(); // This buy order above MSSP will be matched with a sell order (limit order with better price takes precedence) - limit_order_id_type buy_high = create_sell_order(buyer3, asset(111), bitusd.amount(10))->id; + limit_order_id_type buy_high = create_sell_order(buyer3, asset(111), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(buyer2, bitusd) ); @@ -1820,13 +1820,13 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) BOOST_CHECK( !create_sell_order(seller, bitusd.amount(700*4), core.amount(5900*4) ) ); // firstly it will match with buy_high, at buy_high's price - BOOST_CHECK( !db.find( buy_high ) ); + BOOST_CHECK( !db.find( buy_high ) ); // buy_high pays 111 CORE, receives 10 USD goes to buyer3's balance BOOST_CHECK_EQUAL( 10, get_balance(buyer3, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 111, get_balance(buyer3, core) ); // then it will match with call, at mssp: 1/11 = 1000/11000 - const call_order_object* tmp_call = db.find( call_id ); + const call_order_object* tmp_call = db.find( call_id ); BOOST_CHECK( tmp_call != nullptr ); // call will receive call_to_cover, pay 11*call_to_cover @@ -1841,7 +1841,7 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); // the limit order then will match with call2, at mssp: 1/11 = 1000/11000 - const call_order_object* tmp_call2 = db.find( call2_id ); + const call_order_object* tmp_call2 = db.find( call2_id ); BOOST_CHECK( tmp_call2 != nullptr ); // call2 will receive call2_to_cover, pay 11*call2_to_cover @@ -1862,14 +1862,14 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) buy_med_get -= (buy_med_get/100); // minus 1% market fee BOOST_CHECK_EQUAL( buy_med_get.value, get_balance(buyer2, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 33000, get_balance(buyer2, core) ); - BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 33000-buy_med_pay.value ); + BOOST_CHECK_EQUAL( db.find( buy_med )->for_sale.value, 33000-buy_med_pay.value ); // call3 is not in margin call territory so won't be matched BOOST_CHECK_EQUAL( 1000, call3.debt.value ); BOOST_CHECK_EQUAL( 25000, call3.collateral.value ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // check seller balance BOOST_CHECK_EQUAL( 193, get_balance(seller, bitusd) ); // 3000 - 7 - 700*4 @@ -1877,13 +1877,13 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) // Cancel buy_med cancel_limit_order( buy_med(db) ); - BOOST_CHECK( !db.find( buy_med ) ); + BOOST_CHECK( !db.find( buy_med ) ); BOOST_CHECK_EQUAL( buy_med_get.value, get_balance(buyer2, bitusd) ); BOOST_CHECK_EQUAL( init_balance - buy_med_pay.value, get_balance(buyer2, core) ); // Create another sell order slightly below the call price, won't fill - limit_order_id_type sell_med = create_sell_order( seller, bitusd.amount(7), core.amount(59) )->id; - BOOST_CHECK_EQUAL( db.find( sell_med )->for_sale.value, 7 ); + limit_order_id_type sell_med = create_sell_order( seller, bitusd.amount(7), core.amount(59) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_med )->for_sale.value, 7 ); // check seller balance BOOST_CHECK_EQUAL( 193-7, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 30801, get_balance(seller, core) ); @@ -1893,7 +1893,7 @@ BOOST_AUTO_TEST_CASE(target_cr_test_limit_call) BOOST_CHECK_EQUAL( 25000, call3.collateral.value ); // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // generate a block generate_block(); @@ -1930,7 +1930,7 @@ BOOST_AUTO_TEST_CASE(target_cr_test_call_limit) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); transfer(committee_account, borrower3_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; @@ -1939,10 +1939,10 @@ BOOST_AUTO_TEST_CASE(target_cr_test_call_limit) publish_feed( bitusd, feedproducer, current_feed ); // start out with 300% collateral, call price is 15/1.75 CORE/USD = 60/7, tcr 170% is lower than 175% const call_order_object& call = *borrow( borrower, bitusd.amount(1000), asset(15000), 1700); - call_order_id_type call_id = call.id; + call_order_id_type call_id = call.get_id(); // create another position with 310% collateral, call price is 15.5/1.75 CORE/USD = 62/7, tcr 200% is higher than 175% const call_order_object& call2 = *borrow( borrower2, bitusd.amount(1000), asset(15500), 2000); - call_order_id_type call2_id = call2.id; + call_order_id_type call2_id = call2.get_id(); // create yet another position with 500% collateral, call price is 25/1.75 CORE/USD = 100/7, no tcr const call_order_object& call3 = *borrow( borrower3, bitusd.amount(1000), asset(25000)); transfer(borrower, seller, bitusd.amount(1000)); @@ -1966,21 +1966,21 @@ BOOST_AUTO_TEST_CASE(target_cr_test_call_limit) BOOST_CHECK_EQUAL( 0, get_balance(borrower3, bitusd) ); // This sell order above MSSP will not be matched with a call - limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->id; - BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); + limit_order_id_type sell_high = create_sell_order(seller, bitusd.amount(7), core.amount(78))->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_high )->for_sale.value, 7 ); BOOST_CHECK_EQUAL( 2993, get_balance(seller, bitusd) ); BOOST_CHECK_EQUAL( 0, get_balance(seller, core) ); // This buy order is too low will not be matched with a sell order - limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->id; + limit_order_id_type buy_low = create_sell_order(buyer, asset(80), bitusd.amount(10))->get_id(); BOOST_CHECK_EQUAL( 0, get_balance(buyer, bitusd) ); BOOST_CHECK_EQUAL( init_balance - 80, get_balance(buyer, core) ); // Create a sell order which will be matched with several call orders later, price 1/9 - limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(500), core.amount(4500) )->id; - BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 500 ); + limit_order_id_type sell_id = create_sell_order(seller, bitusd.amount(500), core.amount(4500) )->get_id(); + BOOST_CHECK_EQUAL( db.find( sell_id )->for_sale.value, 500 ); // prepare price feed to get call and call2 (but not call3) into margin call territory current_feed.settlement_price = bitusd.amount( 1 ) / core.amount(10); @@ -1999,7 +1999,7 @@ BOOST_AUTO_TEST_CASE(target_cr_test_call_limit) // settlement price = 1/10, mssp = 1/11 // firstly the limit order will match with call, at limit order's price: 1/9 - const call_order_object* tmp_call = db.find( call_id ); + const call_order_object* tmp_call = db.find( call_id ); BOOST_CHECK( tmp_call != nullptr ); // call will receive call_to_cover, pay 9*call_to_cover @@ -2014,7 +2014,7 @@ BOOST_AUTO_TEST_CASE(target_cr_test_call_limit) BOOST_CHECK_EQUAL( 0, get_balance(borrower, bitusd) ); // the limit order then will match with call2, at limit order's price: 1/9 - const call_order_object* tmp_call2 = db.find( call2_id ); + const call_order_object* tmp_call2 = db.find( call2_id ); BOOST_CHECK( tmp_call2 != nullptr ); // if the limit is big enough, call2 will receive call2_to_cover, pay 11*call2_to_cover @@ -2033,14 +2033,14 @@ BOOST_AUTO_TEST_CASE(target_cr_test_call_limit) BOOST_CHECK_EQUAL( 25000, call3.collateral.value ); // sell_id is completely filled - BOOST_CHECK( !db.find( sell_id ) ); + BOOST_CHECK( !db.find( sell_id ) ); // check seller balance BOOST_CHECK_EQUAL( 2493, get_balance(seller, bitusd) ); // 3000 - 7 - 500 BOOST_CHECK_EQUAL( 4500, get_balance(seller, core) ); // 500*9 // buy_low's price is too low that won't be matched - BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); + BOOST_CHECK_EQUAL( db.find( buy_low )->for_sale.value, 80 ); // generate a block generate_block(); @@ -2066,7 +2066,7 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_before1270) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); @@ -2075,9 +2075,9 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_before1270) publish_feed( bitusd, feedproducer, current_feed ); const call_order_object& b1 = *borrow( borrower, bitusd.amount(1000), asset(1800)); - auto b1_id = b1.id; + auto b1_id = b1.get_id(); const call_order_object& b2 = *borrow( borrower2, bitusd.amount(1000), asset(2000) ); - auto b2_id = b2.id; + auto b2_id = b2.get_id(); BOOST_CHECK_EQUAL( get_balance( borrower, bitusd ), 1000 ); BOOST_CHECK_EQUAL( get_balance( borrower2, bitusd ), 1000 ); @@ -2093,8 +2093,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_before1270) BOOST_CHECK_EQUAL( get_balance( borrower , core ), 998200 ); BOOST_CHECK_EQUAL( get_balance( borrower2, core ), 998000 ); - BOOST_CHECK( db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); // attempt to trade the margin call create_sell_order( borrower2, bitusd.amount(1000), core.amount(1100) ); @@ -2107,8 +2107,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_before1270) print_market(bitusd.symbol, core.symbol); // both calls are still there, no margin call, mcr bug - BOOST_CHECK( db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); } FC_LOG_AND_RETHROW() } @@ -2134,7 +2134,7 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_after1270) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); @@ -2143,9 +2143,9 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_after1270) publish_feed( bitusd, feedproducer, current_feed ); const call_order_object& b1 = *borrow( borrower, bitusd.amount(1000), asset(1800)); - auto b1_id = b1.id; + auto b1_id = b1.get_id(); const call_order_object& b2 = *borrow( borrower2, bitusd.amount(1000), asset(2000) ); - auto b2_id = b2.id; + auto b2_id = b2.get_id(); BOOST_CHECK_EQUAL( get_balance( borrower, bitusd ), 1000 ); BOOST_CHECK_EQUAL( get_balance( borrower2, bitusd ), 1000 ); @@ -2161,8 +2161,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_after1270) BOOST_CHECK_EQUAL( get_balance( borrower , core ), 998200 ); BOOST_CHECK_EQUAL( get_balance( borrower2, core ), 998000 ); - BOOST_CHECK( db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); // attempt to trade the margin call create_sell_order( borrower2, bitusd.amount(1000), core.amount(1100) ); @@ -2175,8 +2175,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_increase_after1270) print_market(bitusd.symbol, core.symbol); // b1 is margin called - BOOST_CHECK( ! db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( ! db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); } FC_LOG_AND_RETHROW() } @@ -2200,7 +2200,7 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_before1270) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); @@ -2209,9 +2209,9 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_before1270) publish_feed( bitusd, feedproducer, current_feed ); const call_order_object& b1 = *borrow( borrower, bitusd.amount(1000), asset(1800)); - auto b1_id = b1.id; + auto b1_id = b1.get_id(); const call_order_object& b2 = *borrow( borrower2, bitusd.amount(1000), asset(2000) ); - auto b2_id = b2.id; + auto b2_id = b2.get_id(); BOOST_CHECK_EQUAL( get_balance( borrower, bitusd ), 1000 ); BOOST_CHECK_EQUAL( get_balance( borrower2, bitusd ), 1000 ); @@ -2231,8 +2231,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_before1270) BOOST_CHECK_EQUAL( get_balance( borrower , core ), 998200 ); BOOST_CHECK_EQUAL( get_balance( borrower2, core ), 998000 ); - BOOST_CHECK( db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); // attempt to trade the margin call create_sell_order( borrower2, bitusd.amount(1000), core.amount(1100) ); @@ -2245,8 +2245,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_before1270) print_market(bitusd.symbol, core.symbol); // margin call at b1, mcr bug - BOOST_CHECK( !db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( !db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); } FC_LOG_AND_RETHROW() } @@ -2273,7 +2273,7 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_after1270) transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); @@ -2282,9 +2282,9 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_after1270) publish_feed( bitusd, feedproducer, current_feed ); const call_order_object& b1 = *borrow( borrower, bitusd.amount(1000), asset(1800)); - auto b1_id = b1.id; + auto b1_id = b1.get_id(); const call_order_object& b2 = *borrow( borrower2, bitusd.amount(1000), asset(2000) ); - auto b2_id = b2.id; + auto b2_id = b2.get_id(); BOOST_CHECK_EQUAL( get_balance( borrower, bitusd ), 1000 ); BOOST_CHECK_EQUAL( get_balance( borrower2, bitusd ), 1000 ); @@ -2304,8 +2304,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_after1270) BOOST_CHECK_EQUAL( get_balance( borrower , core ), 998200 ); BOOST_CHECK_EQUAL( get_balance( borrower2, core ), 998000 ); - BOOST_CHECK( db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); // attempt to trade the margin call create_sell_order( borrower2, bitusd.amount(1000), core.amount(1100) ); @@ -2318,8 +2318,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_decrease_after1270) print_market(bitusd.symbol, core.symbol); // both calls are there, no margin call, good - BOOST_CHECK( db.find( b1_id ) ); - BOOST_CHECK( db.find( b2_id ) ); + BOOST_CHECK( db.find( b1_id ) ); + BOOST_CHECK( db.find( b2_id ) ); } FC_LOG_AND_RETHROW() } @@ -2334,7 +2334,7 @@ BOOST_AUTO_TEST_CASE(mcr_bug_cross1270) const asset_object& core = get_asset(GRAPHENE_SYMBOL); const asset_object& bitusd = get_asset("USDBIT"); - const asset_id_type bitusd_id = bitusd.id; + const asset_id_type bitusd_id = bitusd.get_id(); const account_object& feedproducer = get_account("feedproducer"); // feed is expired @@ -2363,8 +2363,8 @@ BOOST_AUTO_TEST_CASE(mcr_bug_cross1270) print_market(asset_id_type(1)(db).symbol, asset_id_type()(db).symbol); // call b1 not there anymore - BOOST_CHECK( !db.find( call_order_id_type() ) ); - BOOST_CHECK( db.find( call_order_id_type(1) ) ); + BOOST_CHECK( !db.find( call_order_id_type() ) ); + BOOST_CHECK( db.find( call_order_id_type(1) ) ); } FC_LOG_AND_RETHROW() } diff --git a/tests/tests/network_broadcast_api_tests.cpp b/tests/tests/network_broadcast_api_tests.cpp index 17dd7e8857..0a80d1409b 100644 --- a/tests/tests/network_broadcast_api_tests.cpp +++ b/tests/tests/network_broadcast_api_tests.cpp @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE( broadcast_transaction_with_callback_test ) { }; fc::ecc::private_key cid_key = fc::ecc::private_key::regenerate( fc::digest("key") ); - const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).id; + const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).get_id(); fund( cid_id(db) ); auto nb_api = std::make_shared< graphene::app::network_broadcast_api >( app ); @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE( broadcast_transaction_disabled_p2p_test ) { }; fc::ecc::private_key cid_key = fc::ecc::private_key::regenerate( fc::digest("key") ); - const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).id; + const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).get_id(); fund( cid_id(db) ); auto nb_api = std::make_shared< graphene::app::network_broadcast_api >( app ); @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE( broadcast_transaction_too_large ) { try { fc::ecc::private_key cid_key = fc::ecc::private_key::regenerate( fc::digest("key") ); - const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).id; + const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).get_id(); fund( cid_id(db) ); auto nb_api = std::make_shared< graphene::app::network_broadcast_api >( app ); diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 81f678d3c2..88f3d9e012 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -85,12 +85,12 @@ BOOST_AUTO_TEST_CASE( call_order_update_test ) try { ACTORS((dan)(sam)); - const auto& bitusd = create_bitasset("USDBIT", sam.id); + const auto& bitusd = create_bitasset("USDBIT", sam.get_id()); const auto& core = asset_id_type()(db); transfer(committee_account, dan_id, asset(10000000)); transfer(committee_account, sam_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -192,12 +192,12 @@ BOOST_AUTO_TEST_CASE( old_call_order_update_test_after_hardfork_583 ) set_expiration( db, trx ); ACTORS((dan)(sam)); - const auto& bitusd = create_bitasset("USDBIT", sam.id); + const auto& bitusd = create_bitasset("USDBIT", sam.get_id()); const auto& core = asset_id_type()(db); transfer(committee_account, dan_id, asset(10000000)); transfer(committee_account, sam_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -296,15 +296,15 @@ BOOST_AUTO_TEST_CASE( call_order_update_asset_auth_test ) ACTORS((dan)(sam)); const auto& backasset = create_user_issued_asset("BACK", sam, white_list | charge_market_fee); - asset_id_type back_id = backasset.id; + asset_id_type back_id = backasset.get_id(); - const auto& bitusd = create_bitasset("USDBIT", sam.id, 10, white_list | charge_market_fee, 3, back_id); - asset_id_type usd_id = bitusd.id; + const auto& bitusd = create_bitasset("USDBIT", sam.get_id(), 10, white_list | charge_market_fee, 3, back_id); + asset_id_type usd_id = bitusd.get_id(); issue_uia( dan_id, backasset.amount(10000000) ); issue_uia( sam_id, backasset.amount(10000000) ); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.core_exchange_rate = bitusd.amount( 100 ) / asset( 100 ); @@ -453,15 +453,15 @@ BOOST_AUTO_TEST_CASE( asset_settle_operation_asset_auth_test ) ACTORS((dan)(sam)); const auto& backasset = create_user_issued_asset("BACK", sam, white_list | charge_market_fee); - asset_id_type back_id = backasset.id; + asset_id_type back_id = backasset.get_id(); - const auto& bitusd = create_bitasset("USDBIT", sam.id, 10, white_list | charge_market_fee, 3, back_id); - asset_id_type usd_id = bitusd.id; + const auto& bitusd = create_bitasset("USDBIT", sam.get_id(), 10, white_list | charge_market_fee, 3, back_id); + asset_id_type usd_id = bitusd.get_id(); issue_uia( dan_id, backasset.amount(10000000) ); issue_uia( sam_id, backasset.amount(10000000) ); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.core_exchange_rate = bitusd.amount( 100 ) / asset( 100 ); @@ -619,15 +619,15 @@ BOOST_AUTO_TEST_CASE( bid_collateral_operation_asset_auth_test ) ACTORS((dan)(sam)); const auto& backasset = create_user_issued_asset("BACK", sam, white_list | charge_market_fee); - asset_id_type back_id = backasset.id; + asset_id_type back_id = backasset.get_id(); - const auto& bitusd = create_bitasset("USDBIT", sam.id, 10, white_list | charge_market_fee, 3, back_id); - asset_id_type usd_id = bitusd.id; + const auto& bitusd = create_bitasset("USDBIT", sam.get_id(), 10, white_list | charge_market_fee, 3, back_id); + asset_id_type usd_id = bitusd.get_id(); issue_uia( dan_id, backasset.amount(10000000) ); issue_uia( sam_id, backasset.amount(10000000) ); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.core_exchange_rate = bitusd.amount( 100 ) / asset( 100 ); @@ -859,9 +859,9 @@ BOOST_AUTO_TEST_CASE( bsip77_hardfork_time_and_param_valid_range_test ) GRAPHENE_MAX_SHARE_SUPPLY, 32001 ), fc::exception ); // Can create a bitasset without ICR - const auto& bitusd = create_bitasset( "USDBIT", sam.id, 100, charge_market_fee, 2, {}, + const auto& bitusd = create_bitasset( "USDBIT", sam.get_id(), 100, charge_market_fee, 2, {}, GRAPHENE_MAX_SHARE_SUPPLY ); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); // helper function for setting ICR for an asset auto set_icr_for_asset = [&](asset_id_type aid, optional icr) { @@ -958,15 +958,15 @@ BOOST_AUTO_TEST_CASE( bsip77_hardfork_time_and_param_valid_range_test ) BOOST_CHECK_THROW( create_bitasset( "USDBITB", sam_id, 32001, charge_market_fee, 2, {}, GRAPHENE_MAX_SHARE_SUPPLY, 0 ), fc::exception ); // Able to create a bitasset with a valid ICR - asset_id_type usdc_id = create_bitasset( "USDBITC", sam.id, 100, charge_market_fee, 2, {}, - GRAPHENE_MAX_SHARE_SUPPLY, 1001 ).id; - asset_id_type usdd_id = create_bitasset( "USDBITD", sam.id, 100, charge_market_fee, 2, {}, - GRAPHENE_MAX_SHARE_SUPPLY, 1750 ).id; - asset_id_type usde_id = create_bitasset( "USDBITE", sam.id, 100, charge_market_fee, 2, {}, - GRAPHENE_MAX_SHARE_SUPPLY, 32000 ).id; + asset_id_type usdc_id = create_bitasset( "USDBITC", sam.get_id(), 100, charge_market_fee, 2, {}, + GRAPHENE_MAX_SHARE_SUPPLY, 1001 ).get_id(); + asset_id_type usdd_id = create_bitasset( "USDBITD", sam.get_id(), 100, charge_market_fee, 2, {}, + GRAPHENE_MAX_SHARE_SUPPLY, 1750 ).get_id(); + asset_id_type usde_id = create_bitasset( "USDBITE", sam.get_id(), 100, charge_market_fee, 2, {}, + GRAPHENE_MAX_SHARE_SUPPLY, 32000 ).get_id(); // Able to create a bitasset without ICR - asset_id_type usdf_id = create_bitasset( "USDBITF", sam.id, 100, charge_market_fee, 2, {}, - GRAPHENE_MAX_SHARE_SUPPLY, {} ).id; + asset_id_type usdf_id = create_bitasset( "USDBITF", sam.get_id(), 100, charge_market_fee, 2, {}, + GRAPHENE_MAX_SHARE_SUPPLY, {} ).get_id(); BOOST_CHECK( usdc_id(db).bitasset_data(db).options.extensions.value.initial_collateral_ratio == 1001 ); BOOST_CHECK( usdd_id(db).bitasset_data(db).options.extensions.value.initial_collateral_ratio == 1750 ); @@ -1030,14 +1030,14 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test ) try { ACTORS((dan)(sam)(alice)(bob)); - const auto& bitusd = create_bitasset("USDBIT", sam.id); + const auto& bitusd = create_bitasset("USDBIT", sam.get_id()); const auto& core = asset_id_type()(db); transfer(committee_account, dan_id, asset(10000000)); transfer(committee_account, sam_id, asset(10000000)); transfer(committee_account, alice_id, asset(10000000)); transfer(committee_account, bob_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -1055,7 +1055,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test ) BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 ); BOOST_TEST_MESSAGE( "alice place an order to sell usd at 1.05" ); - const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->id; + const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->get_id(); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 ); @@ -1070,7 +1070,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test ) BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 ); BOOST_TEST_MESSAGE( "bob attempting to borrow using 2x collateral at 1:1 price now that there is a valid order" ); - const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->id; + const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->get_id(); BOOST_REQUIRE_EQUAL( get_balance( bob, bitusd ), 100 + 100 ); BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 200 ); @@ -1083,7 +1083,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test ) BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 105 ); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 + 105 ); - BOOST_CHECK( !db.find( bob_call_id ) ); + BOOST_CHECK( !db.find( bob_call_id ) ); BOOST_TEST_MESSAGE( "alice cancel sell order" ); cancel_limit_order( alice_sell_id(db) ); @@ -1140,14 +1140,14 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_583 ) set_expiration( db, trx ); ACTORS((dan)(sam)(alice)(bob)); - const auto& bitusd = create_bitasset("USDBIT", sam.id); + const auto& bitusd = create_bitasset("USDBIT", sam.get_id()); const auto& core = asset_id_type()(db); transfer(committee_account, dan_id, asset(10000000)); transfer(committee_account, sam_id, asset(10000000)); transfer(committee_account, alice_id, asset(10000000)); transfer(committee_account, bob_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -1165,7 +1165,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_583 ) BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 ); BOOST_TEST_MESSAGE( "alice place an order to sell usd at 1.05" ); - const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->id; + const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->get_id(); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 ); @@ -1180,7 +1180,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_583 ) BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 ); BOOST_TEST_MESSAGE( "bob attempting to borrow using 2x collateral at 1:1 price now that there is a valid order" ); - const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->id; + const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->get_id(); BOOST_REQUIRE_EQUAL( get_balance( bob, bitusd ), 100 + 100 ); BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 200 ); @@ -1193,7 +1193,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_583 ) BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 105 ); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 + 105 ); - BOOST_CHECK( !db.find( bob_call_id ) ); + BOOST_CHECK( !db.find( bob_call_id ) ); BOOST_TEST_MESSAGE( "alice cancel sell order" ); cancel_limit_order( alice_sell_id(db) ); @@ -1260,11 +1260,11 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr set_expiration( db, trx ); ACTORS((dan)(sam)(alice)(bob)); - const auto& bitusd = create_bitasset( "USDBIT", sam.id, 100, charge_market_fee, 2, {}, + const auto& bitusd = create_bitasset( "USDBIT", sam.get_id(), 100, charge_market_fee, 2, {}, GRAPHENE_MAX_SHARE_SUPPLY, 1050 ); // ICR = 1.05 const auto& core = asset_id_type()(db); - asset_id_type usd_id = bitusd.id; + asset_id_type usd_id = bitusd.get_id(); // helper function for setting ICR for an asset auto set_icr_for_asset = [&](asset_id_type aid, optional icr) { @@ -1286,7 +1286,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr transfer(committee_account, sam_id, asset(10000000)); transfer(committee_account, alice_id, asset(10000000)); transfer(committee_account, bob_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -1342,7 +1342,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_TEST_MESSAGE( "ICR 1.85, MCR 1.75, Alice CR 4.0000" ); BOOST_TEST_MESSAGE( "alice place an order to sell usd at 1.05" ); - const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->id; + const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->get_id(); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 ); @@ -1357,7 +1357,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 ); BOOST_TEST_MESSAGE( "bob attempting to borrow using 2x collateral at 1:1 price now that there is a valid order" ); - const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->id; + const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->get_id(); BOOST_REQUIRE_EQUAL( get_balance( bob, bitusd ), 100 + 100 ); BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 200 ); @@ -1370,7 +1370,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 105 ); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 + 105 ); - BOOST_CHECK( !db.find( bob_call_id ) ); + BOOST_CHECK( !db.find( bob_call_id ) ); BOOST_TEST_MESSAGE( "alice cancel sell order" ); cancel_limit_order( alice_sell_id(db) ); @@ -1419,7 +1419,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_TEST_MESSAGE( "ICR 1.85, MCR 1.75, Alice CR 2.222222" ); BOOST_TEST_MESSAGE( "alice adding more collateral should be allowed" ); - const call_order_id_type alice_call_id = borrow( alice, bitusd.amount(0), asset(1))->id; + const call_order_id_type alice_call_id = borrow( alice, bitusd.amount(0), asset(1))->get_id(); BOOST_CHECK_EQUAL( alice_call_id(db).collateral.value, 400000 + 1 ); BOOST_CHECK_EQUAL( alice_call_id(db).debt.value, 100000 ); BOOST_TEST_MESSAGE( "ICR 1.85, MCR 1.75, Alice CR 2.222228" ); @@ -1461,7 +1461,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr set_expiration( db, trx ); ACTORS((dan)(sam)(alice)(bob)); - const auto& bitusd = create_bitasset( "USDBIT", sam.id, 100, charge_market_fee, 2, {}, + const auto& bitusd = create_bitasset( "USDBIT", sam.get_id(), 100, charge_market_fee, 2, {}, GRAPHENE_MAX_SHARE_SUPPLY, {} ); // ICR is not set const auto& core = asset_id_type()(db); @@ -1469,7 +1469,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr transfer(committee_account, sam_id, asset(10000000)); transfer(committee_account, alice_id, asset(10000000)); transfer(committee_account, bob_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -1525,7 +1525,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_TEST_MESSAGE( "ICR 1.85, MCR 1.75, Alice CR 4.0000" ); BOOST_TEST_MESSAGE( "alice place an order to sell usd at 1.05" ); - const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->id; + const limit_order_id_type alice_sell_id = create_sell_order( alice, bitusd.amount(1000), core.amount(1050) )->get_id(); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 ); @@ -1540,7 +1540,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 ); BOOST_TEST_MESSAGE( "bob attempting to borrow using 2x collateral at 1:1 price now that there is a valid order" ); - const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->id; + const call_order_id_type bob_call_id = borrow( bob, bitusd.amount(100), asset(200))->get_id(); BOOST_REQUIRE_EQUAL( get_balance( bob, bitusd ), 100 + 100 ); BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 200 ); @@ -1553,7 +1553,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_REQUIRE_EQUAL( get_balance( bob, core ), 10000000 - 105 - 105 ); BOOST_REQUIRE_EQUAL( get_balance( alice, bitusd ), 100000 - 1000 ); BOOST_REQUIRE_EQUAL( get_balance( alice, core ), 10000000 - 400000 + 105 + 105 ); - BOOST_CHECK( !db.find( bob_call_id ) ); + BOOST_CHECK( !db.find( bob_call_id ) ); BOOST_TEST_MESSAGE( "alice cancel sell order" ); cancel_limit_order( alice_sell_id(db) ); @@ -1602,7 +1602,7 @@ BOOST_AUTO_TEST_CASE( more_call_order_update_test_after_hardfork_bsip77_when_icr BOOST_TEST_MESSAGE( "ICR 1.85, MCR 1.75, Alice CR 2.222222" ); BOOST_TEST_MESSAGE( "alice adding more collateral should be allowed" ); - const call_order_id_type alice_call_id = borrow( alice, bitusd.amount(0), asset(1))->id; + const call_order_id_type alice_call_id = borrow( alice, bitusd.amount(0), asset(1))->get_id(); BOOST_CHECK_EQUAL( alice_call_id(db).collateral.value, 400000 + 1 ); BOOST_CHECK_EQUAL( alice_call_id(db).debt.value, 100000 ); BOOST_TEST_MESSAGE( "ICR 1.85, MCR 1.75, Alice CR 2.222228" ); @@ -1694,7 +1694,7 @@ BOOST_AUTO_TEST_CASE( margin_call_limit_test ) transfer(committee_account, buyer_id, asset(init_balance)); transfer(committee_account, borrower_id, asset(init_balance)); transfer(committee_account, borrower2_id, asset(init_balance)); - update_feed_producers( bitusd, {feedproducer.id} ); + update_feed_producers( bitusd, {feedproducer.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 100 ) / core.amount(100); @@ -1765,7 +1765,7 @@ BOOST_AUTO_TEST_CASE( prediction_market ) update_feed_producers( pmark, { judge_id }); price_feed feed; - feed.settlement_price = asset( 1, pmark.id ) / asset( 1 ); + feed.settlement_price = asset( 1, pmark.get_id() ) / asset( 1 ); publish_feed( pmark, judge, feed ); BOOST_TEST_MESSAGE( "Require throw for mismatch collateral amounts" ); @@ -1823,7 +1823,7 @@ BOOST_AUTO_TEST_CASE( prediction_market_resolves_to_0 ) update_feed_producers( pmark, { judge_id }); price_feed feed; - feed.settlement_price = asset( 1, pmark.id ) / asset( 1 ); + feed.settlement_price = asset( 1, pmark.get_id() ) / asset( 1 ); publish_feed( pmark, judge, feed ); borrow( dan, pmark.amount(1000), asset(1000) ); @@ -1866,13 +1866,13 @@ BOOST_AUTO_TEST_CASE( prediction_market_black_swan ) update_feed_producers( pmark, { judge_id }); price_feed feed; - feed.settlement_price = asset( 1, pmark.id ) / asset( 1 ); + feed.settlement_price = asset( 1, pmark.get_id() ) / asset( 1 ); publish_feed( pmark, judge, feed ); borrow( dan, pmark.amount(1000), asset(1000) ); // feed a price that will cause a black swan - feed.settlement_price = asset( 1, pmark.id ) / asset( 1000 ); + feed.settlement_price = asset( 1, pmark.get_id() ) / asset( 1000 ); publish_feed( pmark, judge, feed ); // verify a black swan happened @@ -1887,13 +1887,13 @@ BOOST_AUTO_TEST_CASE( prediction_market_black_swan ) const auto& pmark2 = create_prediction_market("PMARKII", judge_id); update_feed_producers( pmark2, { judge_id }); price_feed feed2; - feed2.settlement_price = asset( 1, pmark2.id ) / asset( 1 ); + feed2.settlement_price = asset( 1, pmark2.get_id() ) / asset( 1 ); publish_feed( pmark2, judge, feed2 ); borrow( dan, pmark2.amount(1000), asset(1000) ); // feed a price that would have caused a black swan - feed2.settlement_price = asset( 1, pmark2.id ) / asset( 1000 ); + feed2.settlement_price = asset( 1, pmark2.get_id() ) / asset( 1000 ); publish_feed( pmark2, judge, feed2 ); // verify a black swan did not happen @@ -1975,7 +1975,7 @@ BOOST_AUTO_TEST_CASE( create_account_test ) BOOST_CHECK(statistics.id.space() == implementation_ids); BOOST_CHECK(statistics.id.type() == impl_account_statistics_object_type); - account_id_type nathan_id = nathan_account.id; + account_id_type nathan_id = nathan_account.get_id(); generate_block(); @@ -2098,7 +2098,7 @@ BOOST_AUTO_TEST_CASE( create_committee_member ) REQUIRE_THROW_WITH_VALUE(op, fee, asset(-600)); trx.operations.back() = op; - committee_member_id_type committee_member_id = db.get_index_type().get_next_id(); + committee_member_id_type committee_member_id { db.get_index_type().get_next_id() }; PUSH_TX( db, trx, ~0 ); const committee_member_object& d = committee_member_id(db); @@ -2182,7 +2182,7 @@ BOOST_AUTO_TEST_CASE( update_mia ) BOOST_AUTO_TEST_CASE( create_uia ) { try { - asset_id_type test_asset_id = db.get_index().get_next_id(); + asset_id_type test_asset_id { db.get_index().get_next_id() }; asset_create_operation creator; creator.issuer = account_id_type(); creator.fee = asset(); @@ -2413,12 +2413,12 @@ BOOST_AUTO_TEST_CASE( update_uia_issuer ) // Create accounts const auto& alice = create_account_2_keys("alice", alice_active, alice_owner); const auto& bob = create_account_2_keys("bob", bob_active, bob_owner); - const account_id_type alice_id = alice.id; - const account_id_type bob_id = bob.id; + const account_id_type alice_id = alice.get_id(); + const account_id_type bob_id = bob.get_id(); // Create asset const auto& test = create_user_issued_asset("UPDATEISSUER", alice_id(db), 0); - const asset_id_type test_id = test.id; + const asset_id_type test_id = test.get_id(); // Fast Forward to Hardfork time generate_blocks( HARDFORK_CORE_199_TIME ); @@ -2532,9 +2532,9 @@ BOOST_AUTO_TEST_CASE( create_buy_uia_multiple_match_new ) BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); - limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(100) )->id; - limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(200) )->id; - limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(300) )->id; + limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(100) )->get_id(); + limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(200) )->get_id(); + limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(300) )->get_id(); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 9700 ); @@ -2572,9 +2572,9 @@ BOOST_AUTO_TEST_CASE( create_buy_exact_match_uia ) BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); - limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(100) )->id; - limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(200) )->id; - limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(300) )->id; + limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(100) )->get_id(); + limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(200) )->get_id(); + limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(300) )->get_id(); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 9700 ); @@ -2613,9 +2613,9 @@ BOOST_AUTO_TEST_CASE( create_buy_uia_multiple_match_new_reverse ) BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 10000 ); - limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(100) )->id; - limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(200) )->id; - limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(300) )->id; + limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(100) )->get_id(); + limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(200) )->get_id(); + limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(300) )->get_id(); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 9700 ); @@ -2655,9 +2655,9 @@ BOOST_AUTO_TEST_CASE( create_buy_uia_multiple_match_new_reverse_fract ) BOOST_CHECK_EQUAL( get_balance( buyer_account, core_asset ), 0 ); BOOST_CHECK_EQUAL( get_balance( seller_account, core_asset ), 30 ); - limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(10) )->id; - limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(20) )->id; - limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(30) )->id; + limit_order_id_type first_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(10) )->get_id(); + limit_order_id_type second_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(20) )->get_id(); + limit_order_id_type third_id = create_sell_order( buyer_account, test_asset.amount(100), core_asset.amount(30) )->get_id(); BOOST_CHECK_EQUAL( get_balance( buyer_account, test_asset ), 9700 ); @@ -3033,7 +3033,7 @@ BOOST_AUTO_TEST_CASE( reserve_asset_test ) BOOST_TEST_MESSAGE( "Test reserve operation on market issued asset" ); transfer( committee_account, alice_id, casset.amount( init_balance*100 ) ); - update_feed_producers( basset, {sam.id} ); + update_feed_producers( basset, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = basset.amount( 2 ) / casset.amount(100); current_feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default @@ -3095,7 +3095,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_evaluator_test ) call_order_update_operation op; op.funding_account = alice_id; op.delta_collateral = asset( 1000000 * GRAPHENE_BLOCKCHAIN_PRECISION ); - op.delta_debt = asset( bitjmj.options.max_supply + 1, bitjmj.id ); + op.delta_debt = asset( bitjmj.options.max_supply + 1, bitjmj.get_id() ); transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); @@ -3128,7 +3128,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_evaluator_test ) call_order_update_operation op; op.funding_account = alice_id; op.delta_collateral = asset( 1000000 * GRAPHENE_BLOCKCHAIN_PRECISION ); - op.delta_debt = asset( bitusd.options.max_supply + 1, bitusd.id ); + op.delta_debt = asset( bitusd.options.max_supply + 1, bitusd.get_id() ); transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); @@ -3140,12 +3140,12 @@ BOOST_AUTO_TEST_CASE( call_order_update_evaluator_test ) call_order_update_operation op; op.funding_account = alice_id; op.delta_collateral = asset( 100 * GRAPHENE_BLOCKCHAIN_PRECISION ); - op.delta_debt = asset( 2, bitusd.id ); + op.delta_debt = asset( 2, bitusd.get_id() ); transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); - transfer( alice_id(db), bob_id(db), asset( 2, bitusd.id ) ); + transfer( alice_id(db), bob_id(db), asset( 2, bitusd.get_id() ) ); } { @@ -3153,7 +3153,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_evaluator_test ) call_order_update_operation op; op.funding_account = alice_id; op.delta_collateral = asset( 100000 * GRAPHENE_BLOCKCHAIN_PRECISION ); - op.delta_debt = asset( bitusd.options.max_supply - 1, bitusd.id ); + op.delta_debt = asset( bitusd.options.max_supply - 1, bitusd.get_id() ); transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); @@ -3165,7 +3165,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_evaluator_test ) call_order_update_operation op; op.funding_account = alice_id; op.delta_collateral = asset( 100000 * GRAPHENE_BLOCKCHAIN_PRECISION ); - op.delta_debt = asset( bitusd.options.max_supply - 2, bitusd.id ); + op.delta_debt = asset( bitusd.options.max_supply - 2, bitusd.get_id() ); transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); @@ -3188,7 +3188,7 @@ BOOST_AUTO_TEST_CASE( cover_with_collateral_test ) BOOST_TEST_MESSAGE( "Setting price feed to $0.02 / 100" ); transfer(committee_account, alice_id, asset(10000000)); - update_feed_producers( bitusd, {sam.id} ); + update_feed_producers( bitusd, {sam.get_id()} ); price_feed current_feed; current_feed.settlement_price = bitusd.amount( 2 ) / core.amount(100); @@ -3229,7 +3229,7 @@ BOOST_AUTO_TEST_CASE( cover_with_collateral_test ) BOOST_TEST_MESSAGE( "Bob offers to sell most of the BitUSD at the feed" ); const limit_order_object* order = create_sell_order( bob_id, bitusd.amount(99), asset(4950) ); BOOST_REQUIRE( order != nullptr ); - limit_order_id_type order1_id = order->id; + limit_order_id_type order1_id = order->get_id(); BOOST_CHECK_EQUAL( order->for_sale.value, 99 ); // wdump( (*call_order) ); @@ -3240,7 +3240,7 @@ BOOST_AUTO_TEST_CASE( cover_with_collateral_test ) BOOST_TEST_MESSAGE( "Bob offers to sell the last of his BitUSD in another order" ); order = create_sell_order( bob_id, bitusd.amount(1), asset(50) ); BOOST_REQUIRE( order != nullptr ); - limit_order_id_type order2_id = order->id; + limit_order_id_type order2_id = order->get_id(); BOOST_CHECK_EQUAL( order->for_sale.value, 1 ); // wdump( (*call_order) ); @@ -3532,7 +3532,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) { // Try withdrawing a single satoshi const vesting_balance_object& vbo = create_vbo( - alice_account.id, alice_account.id, core.amount( 10000 ), 1000, 0); + alice_account.get_id(), alice_account.get_id(), core.amount( 10000 ), 1000, 0); FC_ASSERT( db.get_balance( alice_account, core ).amount == 990000 ); @@ -3559,7 +3559,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) // Make sure we can withdraw the correct amount after 999 seconds { const vesting_balance_object& vbo = create_vbo( - alice_account.id, alice_account.id, core.amount( 10000 ), 1000, 999); + alice_account.get_id(), alice_account.get_id(), core.amount( 10000 ), 1000, 999); FC_ASSERT( db.get_balance( alice_account, core ).amount == 990000 ); @@ -3576,7 +3576,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) // Make sure we can withdraw the whole thing after 1000 seconds { const vesting_balance_object& vbo = create_vbo( - alice_account.id, alice_account.id, core.amount( 10000 ), 1000, 1000); + alice_account.get_id(), alice_account.get_id(), core.amount( 10000 ), 1000, 1000); FC_ASSERT( db.get_balance( alice_account, core ).amount == 990000 ); @@ -3592,7 +3592,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) // Make sure that we can't withdraw a single extra satoshi no matter how old it is { const vesting_balance_object& vbo = create_vbo( - alice_account.id, alice_account.id, core.amount( 10000 ), 1000, 123456); + alice_account.get_id(), alice_account.get_id(), core.amount( 10000 ), 1000, 123456); FC_ASSERT( db.get_balance( alice_account, core ).amount == 990000 ); @@ -3611,7 +3611,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) // 3000 after 1000 more seconds { const vesting_balance_object& vbo = create_vbo( - alice_account.id, alice_account.id, core.amount( 10000 ), 1000, 0); + alice_account.get_id(), alice_account.get_id(), core.amount( 10000 ), 1000, 0); FC_ASSERT( db.get_balance( alice_account, core ).amount == 990000 ); @@ -3648,7 +3648,7 @@ BOOST_AUTO_TEST_CASE( vesting_balance_withdraw_test ) // { const vesting_balance_object& vbo = create_vbo( - alice_account.id, alice_account.id, core.amount( 10000 ), 1000, 0); + alice_account.get_id(), alice_account.get_id(), core.amount( 10000 ), 1000, 0); FC_ASSERT( db.get_balance( alice_account, core ).amount == 990000 ); diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index f154d807d5..90318ae635 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -108,8 +108,8 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_create ) { try { auto nathan_private_key = generate_private_key("nathan"); auto dan_private_key = generate_private_key("dan"); - account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; - account_id_type dan_id = create_account("dan", dan_private_key.get_public_key()).id; + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).get_id(); + account_id_type dan_id = create_account("dan", dan_private_key.get_public_key()).get_id(); transfer(account_id_type(), nathan_id, asset(1000)); generate_block(); @@ -153,8 +153,8 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) auto nathan_private_key = generate_private_key("nathan"); auto dan_private_key = generate_private_key("dan"); - account_id_type nathan_id = get_account("nathan").id; - account_id_type dan_id = get_account("dan").id; + account_id_type nathan_id = get_account("nathan").get_id(); + account_id_type dan_id = get_account("dan").get_id(); withdraw_permission_id_type permit; set_expiration( db, trx ); @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test ) generate_blocks(permit_object.expiration); } // Ensure the permit object has been garbage collected - BOOST_CHECK(db.find_object(permit) == nullptr); + BOOST_CHECK(db.find(permit) == nullptr); { withdraw_permission_claim_operation op; @@ -295,8 +295,8 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_nominal_case ) auto nathan_private_key = generate_private_key("nathan"); auto dan_private_key = generate_private_key("dan"); - account_id_type nathan_id = get_account("nathan").id; - account_id_type dan_id = get_account("dan").id; + account_id_type nathan_id = get_account("nathan").get_id(); + account_id_type dan_id = get_account("dan").get_id(); withdraw_permission_id_type permit; // Wait until the permission period's start time @@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_nominal_case ) PUSH_TX( db, trx ); // tx's involving withdraw_permissions can't delete it even // if no further withdrawals are possible - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); BOOST_CHECK( permit_object.claimed_this_period == 5 ); BOOST_CHECK_EQUAL( permit_object.available_this_period(db.head_block_time()).amount.value, 0 ); BOOST_CHECK_EQUAL( current_period(permit_object, db.head_block_time()).available_this_period.amount.value, 0 ); @@ -328,7 +328,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_nominal_case ) generate_blocks( permit_object.period_start_time + permit_object.withdrawal_period_sec ); - if( db.find_object(permit) == nullptr ) + if( db.find(permit) == nullptr ) break; } @@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_whitelist_asset_test ) ACTORS( (nathan)(dan)(izzy) ); - const asset_id_type uia_id = create_user_issued_asset( "ADVANCED", izzy_id(db), white_list ).id; + const asset_id_type uia_id = create_user_issued_asset( "ADVANCED", izzy_id(db), white_list ).get_id(); issue_uia( nathan_id, asset(1000, uia_id) ); @@ -459,8 +459,8 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) auto nathan_private_key = generate_private_key("nathan"); auto dan_private_key = generate_private_key("dan"); - account_id_type nathan_id = get_account("nathan").id; - account_id_type dan_id = get_account("dan").id; + account_id_type nathan_id = get_account("nathan").get_id(); + account_id_type dan_id = get_account("dan").get_id(); withdraw_permission_id_type permit; // Wait until the permission period's start time @@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) { // Before claiming, check the period description const withdraw_permission_object& permit_object = permit(db); - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); withdrawal_period_descriptor period_descriptor = current_period(permit_object, db.head_block_time()); BOOST_CHECK_EQUAL(period_descriptor.available_this_period.amount.value, 5); BOOST_CHECK_EQUAL(period_descriptor.period_start_time.sec_since_epoch(), expected_first_period_start_time.sec_since_epoch() + (expected_period_duration_seconds * 0)); @@ -499,7 +499,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) PUSH_TX( db, trx ); // After claiming, check the period description - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); BOOST_CHECK( permit_object.claimed_this_period == 4 ); BOOST_CHECK_EQUAL( permit_object.claimed_this_period.value, 4 ); period_descriptor = current_period(permit_object, db.head_block_time()); @@ -518,7 +518,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) { // Before claiming, check the period description const withdraw_permission_object& permit_object = permit(db); - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); withdrawal_period_descriptor period_descriptor = current_period(permit_object, db.head_block_time()); BOOST_CHECK_EQUAL(period_descriptor.available_this_period.amount.value, 5); BOOST_CHECK_EQUAL(period_descriptor.period_start_time.sec_since_epoch(), expected_first_period_start_time.sec_since_epoch() + (expected_period_duration_seconds * 1)); @@ -536,7 +536,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) PUSH_TX( db, trx ); // After claiming, check the period description - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); BOOST_CHECK( permit_object.claimed_this_period == 1 ); BOOST_CHECK_EQUAL( permit_object.claimed_this_period.value, 1 ); period_descriptor = current_period(permit_object, db.head_block_time()); @@ -555,7 +555,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) { // Before claiming, check the period description const withdraw_permission_object& permit_object = permit(db); - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); withdrawal_period_descriptor period_descriptor = current_period(permit_object, db.head_block_time()); BOOST_CHECK_EQUAL(period_descriptor.available_this_period.amount.value, 5); BOOST_CHECK_EQUAL(period_descriptor.period_start_time.sec_since_epoch(), expected_first_period_start_time.sec_since_epoch() + (expected_period_duration_seconds * 2)); @@ -578,7 +578,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) { // Before claiming, check the period description const withdraw_permission_object& permit_object = permit(db); - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); withdrawal_period_descriptor period_descriptor = current_period(permit_object, db.head_block_time()); BOOST_CHECK_EQUAL(period_descriptor.available_this_period.amount.value, 5); BOOST_CHECK_EQUAL(period_descriptor.period_start_time.sec_since_epoch(), expected_first_period_start_time.sec_since_epoch() + (expected_period_duration_seconds * 3)); @@ -596,7 +596,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) PUSH_TX( db, trx ); // After claiming, check the period description - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); BOOST_CHECK( permit_object.claimed_this_period == 5 ); BOOST_CHECK_EQUAL( permit_object.claimed_this_period.value, 5 ); period_descriptor = current_period(permit_object, db.head_block_time()); @@ -615,7 +615,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) { // Before claiming, check the period description const withdraw_permission_object& permit_object = permit(db); - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); withdrawal_period_descriptor period_descriptor = current_period(permit_object, db.head_block_time()); BOOST_CHECK_EQUAL(period_descriptor.available_this_period.amount.value, 5); BOOST_CHECK_EQUAL(period_descriptor.period_start_time.sec_since_epoch(), expected_first_period_start_time.sec_since_epoch() + (expected_period_duration_seconds * 4)); @@ -633,7 +633,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) PUSH_TX( db, trx ); // After claiming, check the period description - BOOST_CHECK(db.find_object(permit) != nullptr); + BOOST_CHECK(db.find(permit) != nullptr); BOOST_CHECK( permit_object.claimed_this_period == 3 ); BOOST_CHECK_EQUAL( permit_object.claimed_this_period.value, 3 ); period_descriptor = current_period(permit_object, db.head_block_time()); @@ -649,7 +649,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_incremental_case ) } // Withdrawal periods completed - BOOST_CHECK(db.find_object(permit) == nullptr); + BOOST_CHECK(db.find(permit) == nullptr); BOOST_CHECK_EQUAL(get_balance(nathan_id, asset_id_type()), 987); BOOST_CHECK_EQUAL(get_balance(dan_id, asset_id_type()), 13); @@ -660,8 +660,8 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_update ) INVOKE(withdraw_permission_create); auto nathan_private_key = generate_private_key("nathan"); - account_id_type nathan_id = get_account("nathan").id; - account_id_type dan_id = get_account("dan").id; + account_id_type nathan_id = get_account("nathan").get_id(); + account_id_type dan_id = get_account("dan").get_id(); withdraw_permission_id_type permit; set_expiration( db, trx ); @@ -714,7 +714,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_delete ) BOOST_AUTO_TEST_CASE( mia_feeds ) { try { ACTORS((nathan)(dan)(ben)(vikram)); - asset_id_type bit_usd_id = create_bitasset("USDBIT").id; + asset_id_type bit_usd_id = create_bitasset("USDBIT").get_id(); { asset_update_operation op; @@ -855,7 +855,7 @@ BOOST_AUTO_TEST_CASE( witness_create ) trx.clear(); // create witness - witness_id_type nathan_witness_id = create_witness(nathan_id, nathan_private_key, skip).id; + witness_id_type nathan_witness_id = create_witness(nathan_id, nathan_private_key, skip).get_id(); // nathan should be in the cache BOOST_CHECK_EQUAL( caching_witnesses.count(nathan_witness_id), 1u ); @@ -1420,7 +1420,7 @@ BOOST_AUTO_TEST_CASE( force_settle_test ) nathan_id, 100, disable_force_settle - ).id; + ).get_id(); asset_id_type core_id = asset_id_type(); @@ -1471,11 +1471,11 @@ BOOST_AUTO_TEST_CASE( force_settle_test ) BOOST_TEST_MESSAGE( "First short batch" ); - call_order_id_type call1_id = borrow( shorter1_id, asset(1000, bitusd_id), asset(2*1000, core_id) )->id; // 2.0000 - call_order_id_type call2_id = borrow( shorter2_id, asset(2000, bitusd_id), asset(2*1999, core_id) )->id; // 1.9990 - call_order_id_type call3_id = borrow( shorter3_id, asset(3000, bitusd_id), asset(2*2890, core_id) )->id; // 1.9267 - call_order_id_type call4_id = borrow( shorter4_id, asset(4000, bitusd_id), asset(2*3950, core_id) )->id; // 1.9750 - call_order_id_type call5_id = borrow( shorter5_id, asset(5000, bitusd_id), asset(2*4900, core_id) )->id; // 1.9600 + call_order_id_type call1_id = borrow( shorter1_id, asset(1000, bitusd_id), asset(2*1000, core_id) )->get_id(); // 2.0000 + call_order_id_type call2_id = borrow( shorter2_id, asset(2000, bitusd_id), asset(2*1999, core_id) )->get_id(); // 1.9990 + call_order_id_type call3_id = borrow( shorter3_id, asset(3000, bitusd_id), asset(2*2890, core_id) )->get_id(); // 1.9267 + call_order_id_type call4_id = borrow( shorter4_id, asset(4000, bitusd_id), asset(2*3950, core_id) )->get_id(); // 1.9750 + call_order_id_type call5_id = borrow( shorter5_id, asset(5000, bitusd_id), asset(2*4900, core_id) )->get_id(); // 1.9600 transfer( shorter1_id, nathan_id, asset(1000, bitusd_id) ); transfer( shorter2_id, nathan_id, asset(2000, bitusd_id) ); @@ -1512,8 +1512,8 @@ BOOST_AUTO_TEST_CASE( force_settle_test ) BOOST_TEST_MESSAGE( "Verify partial settlement of call" ); // Partially settle a call - force_settlement_id_type settle_id = *force_settle( nathan_id, asset( 50, bitusd_id ) ) - .get< extendable_operation_result >().value.new_objects->begin(); + force_settlement_id_type settle_id { *force_settle( nathan_id, asset( 50, bitusd_id ) ) + .get< extendable_operation_result >().value.new_objects->begin() }; // Call does not take effect immediately BOOST_CHECK_EQUAL( get_balance(nathan_id, bitusd_id), 14950); @@ -1618,7 +1618,7 @@ BOOST_AUTO_TEST_CASE( assert_op_test ) // create some objects auto nathan_private_key = generate_private_key("nathan"); public_key_type nathan_public_key = nathan_private_key.get_public_key(); - account_id_type nathan_id = create_account("nathan", nathan_public_key).id; + account_id_type nathan_id = create_account("nathan", nathan_public_key).get_id(); assert_operation op; @@ -1694,8 +1694,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) // Not using fixture's get_balance() here because it uses fixture's db, not my override BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 1); - BOOST_CHECK(db.find_object(balance_id_type()) == nullptr); - BOOST_CHECK(db.find_object(balance_id_type(1)) != nullptr); + BOOST_CHECK(db.find(balance_id_type()) == nullptr); + BOOST_CHECK(db.find(balance_id_type(1)) != nullptr); auto slot = db.get_slot_at_time(starting_time); db.generate_block(starting_time, db.get_scheduled_witness(slot), init_account_priv_key, skip_flags); @@ -1762,7 +1762,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) _sign( trx, n_key ); _sign( trx, v1_key ); PUSH_TX(db, trx); - BOOST_CHECK(db.find_object(op.balance_to_claim) == nullptr); + BOOST_CHECK(db.find(op.balance_to_claim) == nullptr); BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 601); op.balance_to_claim = vesting_balance_2.id; @@ -1786,7 +1786,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) _sign( trx, n_key ); _sign( trx, v2_key ); PUSH_TX(db, trx); - BOOST_CHECK(db.find_object(op.balance_to_claim) == nullptr); + BOOST_CHECK(db.find(op.balance_to_claim) == nullptr); BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 901); } FC_LOG_AND_RETHROW() } @@ -1883,7 +1883,7 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo) sign(create_tx, alice_private_key); processed_transaction ptx = PUSH_TX( db, create_tx ); - vesting_balance_id_type vbid = ptx.operation_results[0].get(); + vesting_balance_id_type vbid { ptx.operation_results[0].get() }; check_vesting_1b( vbid ); } @@ -1902,7 +1902,7 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo) set_expiration( db, create_tx ); sign(create_tx, alice_private_key); processed_transaction ptx = PUSH_TX( db, create_tx ); - worker_id_type wid = ptx.operation_results[0].get(); + worker_id_type wid { ptx.operation_results[0].get() }; // vote it in account_update_operation vote_op; @@ -1943,7 +1943,7 @@ BOOST_AUTO_TEST_CASE( vbo_withdraw_different ) // transfer(account_id_type(), alice_id, asset(1000)); - asset_id_type stuff_id = create_user_issued_asset( "STUFF", izzy_id(db), 0 ).id; + asset_id_type stuff_id = create_user_issued_asset( "STUFF", izzy_id(db), 0 ).get_id(); issue_uia( alice_id, asset( 1000, stuff_id ) ); // deposit STUFF with linear vesting policy @@ -2022,7 +2022,7 @@ BOOST_AUTO_TEST_CASE( top_n_special ) // Alice, Bob, Chloe, Dan (ABCD) // - asset_id_type topn_id = create_user_issued_asset( "TOPN", izzy_id(db), 0 ).id; + asset_id_type topn_id = create_user_issued_asset( "TOPN", izzy_id(db), 0 ).get_id(); authority stan_owner_auth = stan_id(db).owner; authority stan_active_auth = stan_id(db).active; @@ -2174,8 +2174,8 @@ BOOST_AUTO_TEST_CASE( buyback ) // Philbin (registrar) // - asset_id_type nono_id = create_user_issued_asset( "NONO", izzy_id(db), 0 ).id; - asset_id_type buyme_id = create_user_issued_asset( "BUYME", izzy_id(db), 0 ).id; + asset_id_type nono_id = create_user_issued_asset( "NONO", izzy_id(db), 0 ).get_id(); + asset_id_type buyme_id = create_user_issued_asset( "BUYME", izzy_id(db), 0 ).get_id(); // Create a buyback account account_id_type rex_id; @@ -2230,7 +2230,7 @@ BOOST_AUTO_TEST_CASE( buyback ) issue_uia( alice_id, asset( 1000, nono_id ) ); // Alice wants to sell 100 BUYME for 1000 BTS, a middle price. - limit_order_id_type order_id_mid = create_sell_order( alice_id, asset( 100, buyme_id ), asset( 1000, asset_id_type() ) )->id; + limit_order_id_type order_id_mid = create_sell_order( alice_id, asset( 100, buyme_id ), asset( 1000, asset_id_type() ) )->get_id(); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -2254,9 +2254,9 @@ BOOST_AUTO_TEST_CASE( buyback ) set_expiration( db, trx ); // #11 // Selling 10 BUYME for 50 BTS, a low price. - limit_order_id_type order_id_low = create_sell_order( alice_id, asset( 10, buyme_id ), asset( 50, asset_id_type() ) )->id; + limit_order_id_type order_id_low = create_sell_order( alice_id, asset( 10, buyme_id ), asset( 50, asset_id_type() ) )->get_id(); // Selling 10 BUYME for 150 BTS, a high price. - limit_order_id_type order_id_high = create_sell_order( alice_id, asset( 10, buyme_id ), asset( 150, asset_id_type() ) )->id; + limit_order_id_type order_id_high = create_sell_order( alice_id, asset( 10, buyme_id ), asset( 150, asset_id_type() ) )->get_id(); fund( rex_id(db), asset( 250, asset_id_type() ) ); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); diff --git a/tests/tests/pob_tests.cpp b/tests/tests/pob_tests.cpp index cf277bfae4..872e6cf342 100644 --- a/tests/tests/pob_tests.cpp +++ b/tests/tests/pob_tests.cpp @@ -36,8 +36,7 @@ using namespace graphene::chain::test; BOOST_FIXTURE_TEST_SUITE( pob_tests, database_fixture ) BOOST_AUTO_TEST_CASE( hardfork_time_test ) -{ - try { +{ try { // Proceeds to a recent hard fork generate_blocks( HARDFORK_CORE_1270_TIME ); @@ -61,11 +60,7 @@ BOOST_AUTO_TEST_CASE( hardfork_time_test ) ticket_update_operation uop = make_ticket_update_op( tmp_ticket, lock_720_days, {} ); BOOST_CHECK_THROW( propose( uop ), fc::exception ); - } catch (fc::exception& e) { - edump((e.to_detail_string())); - throw; - } -} +} FC_CAPTURE_LOG_AND_RETHROW( (0) ) } BOOST_AUTO_TEST_CASE( validation_and_basic_logic_test ) { try { @@ -170,7 +165,7 @@ BOOST_AUTO_TEST_CASE( validation_and_basic_logic_test ) // negative amount BOOST_CHECK_THROW( update_ticket( tick_1, liquid, asset(-1) ), fc::exception ); // non-core asset - BOOST_CHECK_THROW( update_ticket( tick_1, liquid, asset(1, usd.id) ), fc::exception ); + BOOST_CHECK_THROW( update_ticket( tick_1, liquid, asset(1, usd.get_id()) ), fc::exception ); // too big amount BOOST_CHECK_THROW( update_ticket( tick_1, liquid, asset(2) ), fc::exception ); // target type unchanged @@ -198,9 +193,9 @@ BOOST_AUTO_TEST_CASE( validation_and_basic_logic_test ) BOOST_CHECK_THROW( PUSH_TX(db, trx, ~0), fc::exception ); } - ticket_id_type tick_1_id = tick_1.id; - ticket_id_type tick_2_id = tick_2.id; - ticket_id_type tick_4_id = tick_4.id; + ticket_id_type tick_1_id = tick_1.get_id(); + ticket_id_type tick_2_id = tick_2.get_id(); + ticket_id_type tick_4_id = tick_4.get_id(); // Update ticket 1 to liquid generic_operation_result result = update_ticket( tick_1, liquid, asset(1) ); @@ -244,7 +239,7 @@ BOOST_AUTO_TEST_CASE( validation_and_basic_logic_test ) BOOST_CHECK( *result.updated_objects.begin() == tick_2_id ); BOOST_CHECK_EQUAL( result.removed_objects.size(), 0u ); - ticket_id_type new_ticket_id = *result.new_objects.begin(); + ticket_id_type new_ticket_id { *result.new_objects.begin() }; BOOST_CHECK( new_ticket_id > tick_4_id ); BOOST_REQUIRE( db.find( new_ticket_id ) ); BOOST_CHECK( new_ticket_id(db).account == sam_id ); @@ -269,11 +264,7 @@ BOOST_AUTO_TEST_CASE( validation_and_basic_logic_test ) BOOST_CHECK( new_ticket_id(db).target_type == lock_180_days ); BOOST_CHECK( new_ticket_id(db).amount == asset(3) ); - } catch (fc::exception& e) { - edump((e.to_detail_string())); - throw; - } -} +} FC_CAPTURE_LOG_AND_RETHROW( (0) ) } BOOST_AUTO_TEST_CASE( one_lock_180_ticket ) { try { @@ -291,7 +282,7 @@ BOOST_AUTO_TEST_CASE( one_lock_180_ticket ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_180_days, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_180_days ); @@ -386,7 +377,7 @@ BOOST_AUTO_TEST_CASE( one_lock_360_ticket ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_360_days, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_360_days ); @@ -517,7 +508,7 @@ BOOST_AUTO_TEST_CASE( one_lock_720_ticket ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_720_days, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_720_days ); @@ -684,7 +675,7 @@ BOOST_AUTO_TEST_CASE( one_lock_720_ticket_if_blocks_missed ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_720_days, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_720_days ); @@ -741,7 +732,7 @@ BOOST_AUTO_TEST_CASE( one_lock_forever_ticket ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_forever, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_forever ); @@ -930,7 +921,7 @@ BOOST_AUTO_TEST_CASE( one_lock_forever_ticket_if_blocks_missed ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_forever, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_forever ); @@ -993,7 +984,7 @@ BOOST_AUTO_TEST_CASE( one_lock_forever_ticket_if_too_many_blocks_missed ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_forever, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_forever ); @@ -2202,7 +2193,7 @@ BOOST_AUTO_TEST_CASE( cancel_charging_from_liquid ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_360_days, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_360_days ); @@ -2703,7 +2694,7 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again ) BOOST_CHECK( *result.updated_objects.begin() == tick_1_id ); // the new ticket is stable - ticket_id_type tick_2_id = *result.new_objects.begin(); + ticket_id_type tick_2_id { *result.new_objects.begin() }; BOOST_REQUIRE( db.find( tick_2_id ) ); BOOST_CHECK( tick_2_id(db).target_type == lock_180_days ); @@ -2847,7 +2838,7 @@ BOOST_AUTO_TEST_CASE( update_from_withdrawing_to_charging_then_withdraw_again ) BOOST_CHECK( *result.updated_objects.begin() == tick_1_id ); // the new created ticket is freed already - ticket_id_type tick_3_id = *result.new_objects.begin(); + ticket_id_type tick_3_id { *result.new_objects.begin() }; BOOST_CHECK( *result.removed_objects.begin() == tick_3_id ); BOOST_CHECK( !db.find( tick_3_id ) ); @@ -2961,10 +2952,10 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) ted_balance -= 100000; BOOST_CHECK_EQUAL( db.get_balance( ted_id, asset_id_type() ).amount.value, ted_balance ); - ticket_id_type tick_1_id = tick_1.id; - ticket_id_type tick_2_id = tick_2.id; - ticket_id_type tick_3_id = tick_3.id; - ticket_id_type tick_4_id = tick_4.id; + ticket_id_type tick_1_id = tick_1.get_id(); + ticket_id_type tick_2_id = tick_2.get_id(); + ticket_id_type tick_3_id = tick_3.get_id(); + ticket_id_type tick_4_id = tick_4.get_id(); // one day passed generate_blocks( db.head_block_time() + fc::days(1) ); @@ -2990,7 +2981,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_5_id = *result.new_objects.begin(); + ticket_id_type tick_5_id { *result.new_objects.begin() }; BOOST_REQUIRE( db.find( tick_5_id ) ); BOOST_CHECK( tick_5_id(db).target_type == lock_180_days ); // target type of the new ticket is set BOOST_CHECK( tick_5_id(db).current_type == liquid ); @@ -3085,7 +3076,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_6_id = *result.new_objects.begin(); + ticket_id_type tick_6_id { *result.new_objects.begin() }; BOOST_CHECK( tick_6_id(db).target_type == lock_180_days ); BOOST_CHECK( tick_6_id(db).current_type == lock_180_days ); BOOST_CHECK( tick_6_id(db).status == withdrawing ); // 7 days to finish @@ -3103,7 +3094,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_7_id = *result.new_objects.begin(); + ticket_id_type tick_7_id { *result.new_objects.begin() }; BOOST_CHECK( tick_7_id(db).target_type == liquid ); BOOST_CHECK( tick_7_id(db).current_type == liquid ); BOOST_CHECK( tick_7_id(db).status == withdrawing ); // 180 days to finish @@ -3127,7 +3118,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_51_id = *result.new_objects.begin(); + ticket_id_type tick_51_id { *result.new_objects.begin() }; BOOST_CHECK( tick_51_id(db).target_type == liquid ); BOOST_CHECK( tick_51_id(db).current_type == liquid ); BOOST_CHECK( tick_51_id(db).status == withdrawing ); // 180 days to finish @@ -3147,7 +3138,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_52_id = *result.new_objects.begin(); + ticket_id_type tick_52_id { *result.new_objects.begin() }; BOOST_CHECK( tick_52_id(db).target_type == lock_forever ); BOOST_CHECK( tick_52_id(db).current_type == lock_180_days ); BOOST_CHECK( tick_52_id(db).status == charging ); // 15 days to next step @@ -3214,7 +3205,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_8_id = *result.new_objects.begin(); + ticket_id_type tick_8_id { *result.new_objects.begin() }; BOOST_CHECK( tick_8_id(db).target_type == lock_180_days ); BOOST_CHECK( tick_8_id(db).current_type == liquid ); BOOST_CHECK( tick_8_id(db).status == charging ); // 15 days to finish @@ -3232,7 +3223,7 @@ BOOST_AUTO_TEST_CASE( multiple_tickets ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_9_id = *result.new_objects.begin(); + ticket_id_type tick_9_id { *result.new_objects.begin() }; BOOST_CHECK( tick_9_id(db).target_type == liquid ); BOOST_CHECK( tick_9_id(db).current_type == lock_180_days ); BOOST_CHECK( tick_9_id(db).status == withdrawing ); // 4 days to next step @@ -3534,7 +3525,7 @@ BOOST_AUTO_TEST_CASE( hf2262_test ) // create a ticket const ticket_object& tick_1 = create_ticket( sam_id, lock_180_days, asset(100) ); - ticket_id_type tick_1_id = tick_1.id; + ticket_id_type tick_1_id = tick_1.get_id(); BOOST_CHECK( tick_1_id(db).account == sam_id ); BOOST_CHECK( tick_1_id(db).target_type == lock_180_days ); @@ -3592,7 +3583,7 @@ BOOST_AUTO_TEST_CASE( hf2262_test ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_2_id = *result.new_objects.begin(); + ticket_id_type tick_2_id { *result.new_objects.begin() }; BOOST_CHECK( tick_2_id(db).target_type == liquid ); BOOST_CHECK( tick_2_id(db).current_type == liquid ); BOOST_CHECK( tick_2_id(db).status == withdrawing ); @@ -3629,7 +3620,7 @@ BOOST_AUTO_TEST_CASE( hf2262_test ) BOOST_REQUIRE_EQUAL( result.new_objects.size(), 1u ); - ticket_id_type tick_3_id = *result.new_objects.begin(); + ticket_id_type tick_3_id { *result.new_objects.begin() }; BOOST_CHECK( tick_3_id(db).target_type == liquid ); BOOST_CHECK( tick_3_id(db).current_type == liquid ); BOOST_CHECK( tick_3_id(db).status == withdrawing ); @@ -3650,7 +3641,7 @@ BOOST_AUTO_TEST_CASE( hf2262_test ) // create a new ticket const ticket_object& tick_4 = create_ticket( sam_id, lock_360_days, asset(200) ); - ticket_id_type tick_4_id = tick_4.id; + ticket_id_type tick_4_id = tick_4.get_id(); BOOST_CHECK( tick_4_id(db).account == sam_id ); BOOST_CHECK( tick_4_id(db).target_type == lock_360_days ); diff --git a/tests/tests/samet_fund_tests.cpp b/tests/tests/samet_fund_tests.cpp index 75739f067e..4b669817fd 100644 --- a/tests/tests/samet_fund_tests.cpp +++ b/tests/tests/samet_fund_tests.cpp @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_hardfork_time_test ) // Before the hard fork, unable to create a samet fund or transact against a samet fund, // or do any of them with proposals - BOOST_CHECK_THROW( create_samet_fund( sam_id, core.id, 10000, 100 ), fc::exception ); + BOOST_CHECK_THROW( create_samet_fund( sam_id, core.get_id(), 10000, 100 ), fc::exception ); samet_fund_id_type tmp_sf_id; BOOST_CHECK_THROW( delete_samet_fund( sam_id, tmp_sf_id ), fc::exception ); @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_hardfork_time_test ) BOOST_CHECK_THROW( repay_to_samet_fund( sam_id, tmp_sf_id, core.amount(100), core.amount(100) ), fc::exception ); - samet_fund_create_operation cop = make_samet_fund_create_op( sam_id, core.id, 10000, 100 ); + samet_fund_create_operation cop = make_samet_fund_create_op( sam_id, core.get_id(), 10000, 100 ); BOOST_CHECK_THROW( propose( cop ), fc::exception ); samet_fund_delete_operation dop = make_samet_fund_delete_op( sam_id, tmp_sf_id ); @@ -103,12 +103,12 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( sam, eur.amount(init_amount) ); issue_uia( ted, eur.amount(init_amount) ); // Make a whitelist @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) // Able to propose { - samet_fund_create_operation cop = make_samet_fund_create_op( sam_id, core.id, 10000, 100 ); + samet_fund_create_operation cop = make_samet_fund_create_op( sam_id, core.get_id(), 10000, 100 ); propose( cop ); samet_fund_id_type tmp_sf_id; @@ -180,8 +180,8 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) check_balances(); // Able to create samet funds with valid data - const samet_fund_object& sfo1 = create_samet_fund( sam_id, core.id, 10000, 100u ); - samet_fund_id_type sf1_id = sfo1.id; + const samet_fund_object& sfo1 = create_samet_fund( sam_id, core.get_id(), 10000, 100u ); + samet_fund_id_type sf1_id = sfo1.get_id(); BOOST_CHECK( sfo1.owner_account == sam_id ); BOOST_CHECK( sfo1.asset_type == core.id ); BOOST_CHECK( sfo1.balance == 10000 ); @@ -191,8 +191,8 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) expected_balance_sam_core -= 10000; check_balances(); - const samet_fund_object& sfo2 = create_samet_fund( ted_id, usd.id, 1, 10000000u ); - samet_fund_id_type sf2_id = sfo2.id; + const samet_fund_object& sfo2 = create_samet_fund( ted_id, usd.get_id(), 1, 10000000u ); + samet_fund_id_type sf2_id = sfo2.get_id(); BOOST_CHECK( sfo2.owner_account == ted_id ); BOOST_CHECK( sfo2.asset_type == usd.id ); BOOST_CHECK( sfo2.balance == 1 ); @@ -202,8 +202,8 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) expected_balance_ted_usd -= 1; check_balances(); - const samet_fund_object& sfo3 = create_samet_fund( sam_id, eur.id, 10, 1u ); // Account is whitelisted - samet_fund_id_type sf3_id = sfo3.id; + const samet_fund_object& sfo3 = create_samet_fund( sam_id, eur.get_id(), 10, 1u ); // Account is whitelisted + samet_fund_id_type sf3_id = sfo3.get_id(); BOOST_CHECK( sfo3.owner_account == sam_id ); BOOST_CHECK( sfo3.asset_type == eur_id ); BOOST_CHECK( sfo3.balance == 10 ); @@ -215,14 +215,14 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) // Unable to create a samet fund with invalid data // Non-positive balance - BOOST_CHECK_THROW( create_samet_fund( sam_id, core.id, -1, 100u ), fc::exception ); - BOOST_CHECK_THROW( create_samet_fund( ted_id, usd.id, 0, 10000000u ), fc::exception ); + BOOST_CHECK_THROW( create_samet_fund( sam_id, core.get_id(), -1, 100u ), fc::exception ); + BOOST_CHECK_THROW( create_samet_fund( ted_id, usd.get_id(), 0, 10000000u ), fc::exception ); // Insufficient account balance - BOOST_CHECK_THROW( create_samet_fund( por_id, usd.id, 1, 100u ), fc::exception ); + BOOST_CHECK_THROW( create_samet_fund( por_id, usd.get_id(), 1, 100u ), fc::exception ); // Nonexistent asset type BOOST_CHECK_THROW( create_samet_fund( sam_id, no_asset_id, 1, 100u ), fc::exception ); // Account is not whitelisted - BOOST_CHECK_THROW( create_samet_fund( ted_id, eur.id, 10, 1u ), fc::exception ); + BOOST_CHECK_THROW( create_samet_fund( ted_id, eur.get_id(), 10, 1u ), fc::exception ); check_balances(); @@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) // Unable to delete a fund that does not exist BOOST_CHECK_THROW( delete_samet_fund( sam_id, sf1_id ), fc::exception ); // Unable to delete a fund that is not owned by him - BOOST_CHECK_THROW( delete_samet_fund( sam_id, sfo2.id ), fc::exception ); + BOOST_CHECK_THROW( delete_samet_fund( sam_id, sfo2.get_id() ), fc::exception ); BOOST_REQUIRE( !db.find( sf1_id ) ); BOOST_REQUIRE( db.find( sf2_id ) ); @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_crud_and_proposal_test ) check_balances(); // Sam is unable to recreate the fund - BOOST_CHECK_THROW( create_samet_fund( sam_id, eur.id, 10, 1u ), fc::exception ); + BOOST_CHECK_THROW( create_samet_fund( sam_id, eur.get_id(), 10, 1u ), fc::exception ); check_balances(); generate_block(); @@ -389,12 +389,12 @@ BOOST_AUTO_TEST_CASE( samet_fund_borrow_repay_test ) asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( sam, eur.amount(init_amount) ); issue_uia( ted, eur.amount(init_amount) ); // Make a whitelist @@ -445,20 +445,20 @@ BOOST_AUTO_TEST_CASE( samet_fund_borrow_repay_test ) check_balances(); // create samet funds - const samet_fund_object& sfo1 = create_samet_fund( sam_id, core.id, 10000, 10000u ); // fee rate is 1% - samet_fund_id_type sf1_id = sfo1.id; + const samet_fund_object& sfo1 = create_samet_fund( sam_id, core.get_id(), 10000, 10000u ); // fee rate is 1% + samet_fund_id_type sf1_id = sfo1.get_id(); expected_balance_sam_core -= 10000; check_balances(); - const samet_fund_object& sfo2 = create_samet_fund( ted_id, usd.id, 1, 10000000u ); // fee rate is 1000% - samet_fund_id_type sf2_id = sfo2.id; + const samet_fund_object& sfo2 = create_samet_fund( ted_id, usd.get_id(), 1, 10000000u ); // fee rate is 1000% + samet_fund_id_type sf2_id = sfo2.get_id(); expected_balance_ted_usd -= 1; check_balances(); - const samet_fund_object& sfo3 = create_samet_fund( sam_id, eur.id, 10, 1u ); // Account is whitelisted - samet_fund_id_type sf3_id = sfo3.id; + const samet_fund_object& sfo3 = create_samet_fund( sam_id, eur.get_id(), 10, 1u ); // Account is whitelisted + samet_fund_id_type sf3_id = sfo3.get_id(); expected_balance_sam_eur -= 10; check_balances(); @@ -714,7 +714,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_borrow_repay_test ) trx.operations.push_back( cop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const operation_result& op_result = ptx.operation_results.front(); - proposal_id_type pid = op_result.get(); + proposal_id_type pid { op_result.get() }; proposal_update_operation puo; puo.proposal = pid; @@ -754,7 +754,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_borrow_repay_test ) trx.operations.push_back( cop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const operation_result& op_result = ptx.operation_results.front(); - proposal_id_type pid = op_result.get(); + proposal_id_type pid { op_result.get() }; proposals.push_back( pid ); }; @@ -1042,33 +1042,33 @@ BOOST_AUTO_TEST_CASE( samet_fund_apis_test ) asset_id_type core_id; const asset_object& usd = create_user_issued_asset( "MYUSD" ); - asset_id_type usd_id = usd.id; + asset_id_type usd_id = usd.get_id(); issue_uia( sam, usd.amount(init_amount) ); issue_uia( ted, usd.amount(init_amount) ); const asset_object& eur = create_user_issued_asset( "MYEUR", sam, white_list ); - asset_id_type eur_id = eur.id; + asset_id_type eur_id = eur.get_id(); issue_uia( sam, eur.amount(init_amount) ); issue_uia( ted, eur.amount(init_amount) ); // create samet funds const samet_fund_object& sfo1 = create_samet_fund( sam_id, core_id, 10000, 10000u ); // fee rate is 1% - samet_fund_id_type sf1_id = sfo1.id; + samet_fund_id_type sf1_id = sfo1.get_id(); const samet_fund_object& sfo2 = create_samet_fund( ted_id, usd_id, 1, 10000000u ); // fee rate is 1000% - samet_fund_id_type sf2_id = sfo2.id; + samet_fund_id_type sf2_id = sfo2.get_id(); const samet_fund_object& sfo3 = create_samet_fund( sam_id, eur_id, 10, 1u ); - samet_fund_id_type sf3_id = sfo3.id; + samet_fund_id_type sf3_id = sfo3.get_id(); const samet_fund_object& sfo4 = create_samet_fund( sam_id, eur_id, 10, 2u ); - samet_fund_id_type sf4_id = sfo4.id; + samet_fund_id_type sf4_id = sfo4.get_id(); const samet_fund_object& sfo5 = create_samet_fund( sam_id, usd_id, 100, 20u ); - samet_fund_id_type sf5_id = sfo5.id; + samet_fund_id_type sf5_id = sfo5.get_id(); const samet_fund_object& sfo6 = create_samet_fund( ted_id, usd_id, 1000, 200u ); - samet_fund_id_type sf6_id = sfo6.id; + samet_fund_id_type sf6_id = sfo6.get_id(); generate_block(); @@ -1179,7 +1179,7 @@ BOOST_AUTO_TEST_CASE( samet_fund_account_history_test ) // create samet funds const samet_fund_object& sfo1 = create_samet_fund( sam_id, core_id, 10000, 10000u ); // fee rate is 1% - samet_fund_id_type sf1_id = sfo1.id; + samet_fund_id_type sf1_id = sfo1.get_id(); generate_block(); diff --git a/tests/tests/settle_tests.cpp b/tests/tests/settle_tests.cpp index b6e0ee735f..5fef6aeede 100644 --- a/tests/tests/settle_tests.cpp +++ b/tests/tests/settle_tests.cpp @@ -50,9 +50,9 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) const auto& bitusd = create_bitasset("USDBIT", paul_id); const auto& bitcny = create_bitasset("CNYBIT", paul_id); const auto& core = asset_id_type()(db); - asset_id_type bitusd_id = bitusd.id; - asset_id_type bitcny_id = bitcny.id; - asset_id_type core_id = core.id; + asset_id_type bitusd_id = bitusd.get_id(); + asset_id_type bitcny_id = bitcny.get_id(); + asset_id_type core_id = core.get_id(); // fund accounts transfer(committee_account, michael_id, asset( 100000000 ) ); @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) transfer(committee_account, jim_id, asset(10000000)); // add a feed to asset - update_feed_producers( bitusd, {paul.id} ); + update_feed_producers( bitusd, {paul.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; current_feed.maximum_short_squeeze_ratio = 1100; @@ -71,11 +71,11 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) // paul gets some bitusd const call_order_object& call_paul = *borrow( paul, bitusd.amount(1000), core.amount(100) ); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL( get_balance( paul, bitusd ), 1000 ); // and transfer some to rachel - transfer(paul.id, rachel.id, asset(200, bitusd.id)); + transfer(paul.get_id(), rachel.get_id(), asset(200, bitusd.get_id())); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); BOOST_CHECK_EQUAL(get_balance(rachel, bitusd), 200); @@ -84,12 +84,12 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) // michael gets some bitusd const call_order_object& call_michael = *borrow(michael, bitusd.amount(6), core.amount(8)); - call_order_id_type call_michael_id = call_michael.id; + call_order_id_type call_michael_id = call_michael.get_id(); // add settle order and check rounding issue operation_result result = force_settle(rachel, bitusd.amount(4)); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 4 ); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) set_expiration( db, trx ); operation_result result2 = force_settle(rachel_id(db), bitusd_id(db).amount(34)); - force_settlement_id_type settle_id2 = *result2.get().value.new_objects->begin(); + force_settlement_id_type settle_id2 { *result2.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id2(db).balance.amount.value, 34 ); BOOST_CHECK_EQUAL(get_balance(rachel_id(db), core_id(db)), 0); @@ -194,13 +194,13 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) const operation_result result4 = force_settle(rachel_id(db), bitusd_id(db).amount(434)); const operation_result result5 = force_settle(rachel_id(db), bitusd_id(db).amount(5)); - force_settlement_id_type settle_id3 = *result3.get().value.new_objects->begin(); + force_settlement_id_type settle_id3 { *result3.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id3(db).balance.amount.value, 3 ); - force_settlement_id_type settle_id4 = *result4.get().value.new_objects->begin(); + force_settlement_id_type settle_id4 { *result4.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id4(db).balance.amount.value, 434 ); - force_settlement_id_type settle_id5 = *result5.get().value.new_objects->begin(); + force_settlement_id_type settle_id5 { *result5.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id5(db).balance.amount.value, 5 ); BOOST_CHECK_EQUAL(get_balance(rachel_id(db), core_id(db)), 1); @@ -356,7 +356,8 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) generate_block(); // jim borrow some cny - call_order_id_type call_jim_id = borrow(jim_id(db), bitcny_id(db).amount(2000), core_id(db).amount(2000))->id; + call_order_id_type call_jim_id = borrow(jim_id(db), bitcny_id(db).amount(2000), core_id(db).amount(2000)) + ->get_id(); BOOST_CHECK_EQUAL( 2000, call_jim_id(db).debt.value ); BOOST_CHECK_EQUAL( 2000, call_jim_id(db).collateral.value ); @@ -386,13 +387,13 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) const operation_result result7 = force_settle(ted_id(db), bitusd_id(db).amount(21)); const operation_result result8 = force_settle(ted_id(db), bitusd_id(db).amount(22)); - force_settlement_id_type settle_id6 = *result6.get().value.new_objects->begin(); + force_settlement_id_type settle_id6 { *result6.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id6(db).balance.amount.value, 20 ); - force_settlement_id_type settle_id7 = *result7.get().value.new_objects->begin(); + force_settlement_id_type settle_id7 { *result7.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id7(db).balance.amount.value, 21 ); - force_settlement_id_type settle_id8 = *result8.get().value.new_objects->begin(); + force_settlement_id_type settle_id8 { *result8.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id8(db).balance.amount.value, 22 ); BOOST_CHECK_EQUAL(get_balance(ted_id(db), core_id(db)), 0); @@ -403,16 +404,16 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) const operation_result result102 = force_settle(joe_id(db), bitcny_id(db).amount(1000)); const operation_result result103 = force_settle(joe_id(db), bitcny_id(db).amount(300)); - force_settlement_id_type settle_id101 = *result101.get() - .value.new_objects->begin(); + force_settlement_id_type settle_id101 { *result101.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id101(db).balance.amount.value, 100 ); - force_settlement_id_type settle_id102 = *result102.get() - .value.new_objects->begin(); + force_settlement_id_type settle_id102 { *result102.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id102(db).balance.amount.value, 1000 ); - force_settlement_id_type settle_id103 = *result103.get() - .value.new_objects->begin(); + force_settlement_id_type settle_id103 { *result103.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id103(db).balance.amount.value, 300 ); BOOST_CHECK_EQUAL(get_balance(joe_id(db), core_id(db)), 0); @@ -480,7 +481,7 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test ) // bob borrow some const call_order_object& call_bob = *borrow( bob_id(db), bitusd_id(db).amount(19), core_id(db).amount(2) ); - call_order_id_type call_bob_id = call_bob.id; + call_order_id_type call_bob_id = call_bob.get_id(); BOOST_CHECK_EQUAL(get_balance(bob_id(db), core_id(db)), 9999998); // 10000000 - 2 BOOST_CHECK_EQUAL(get_balance(bob_id(db), bitusd_id(db)), 19); // new @@ -664,9 +665,9 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) const auto& bitusd = create_bitasset("USDBIT", paul_id); const auto& bitcny = create_bitasset("CNYBIT", paul_id); const auto& core = asset_id_type()(db); - asset_id_type bitusd_id = bitusd.id; - asset_id_type bitcny_id = bitcny.id; - asset_id_type core_id = core.id; + asset_id_type bitusd_id = bitusd.get_id(); + asset_id_type bitcny_id = bitcny.get_id(); + asset_id_type core_id = core.get_id(); // fund accounts transfer(committee_account, michael_id, asset( 100000000 ) ); @@ -676,7 +677,7 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) transfer(committee_account, jim_id, asset(10000000)); // add a feed to asset - update_feed_producers( bitusd, {paul.id} ); + update_feed_producers( bitusd, {paul.get_id()} ); price_feed current_feed; current_feed.maintenance_collateral_ratio = 1750; current_feed.maximum_short_squeeze_ratio = 1100; @@ -685,11 +686,11 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) // paul gets some bitusd const call_order_object& call_paul = *borrow( paul, bitusd.amount(1000), core.amount(100) ); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL( get_balance( paul, bitusd ), 1000 ); // and transfer some to rachel - transfer(paul.id, rachel.id, asset(200, bitusd.id)); + transfer(paul.get_id(), rachel.get_id(), asset(200, bitusd.get_id())); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); BOOST_CHECK_EQUAL(get_balance(rachel, bitusd), 200); @@ -698,12 +699,12 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) // michael gets some bitusd const call_order_object& call_michael = *borrow(michael, bitusd.amount(6), core.amount(8)); - call_order_id_type call_michael_id = call_michael.id; + call_order_id_type call_michael_id = call_michael.get_id(); // add settle order and check rounding issue const operation_result result = force_settle(rachel, bitusd.amount(4)); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 4 ); BOOST_CHECK_EQUAL(get_balance(rachel, core), 0); @@ -753,7 +754,7 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) set_expiration( db, trx ); const operation_result result2 = force_settle(rachel_id(db), bitusd_id(db).amount(34)); - force_settlement_id_type settle_id2 = *result2.get().value.new_objects->begin(); + force_settlement_id_type settle_id2 { *result2.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id2(db).balance.amount.value, 34 ); BOOST_CHECK_EQUAL(get_balance(rachel_id(db), core_id(db)), 0); @@ -808,13 +809,13 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) const operation_result result4 = force_settle(rachel_id(db), bitusd_id(db).amount(434)); const operation_result result5 = force_settle(rachel_id(db), bitusd_id(db).amount(5)); - force_settlement_id_type settle_id3 = *result3.get().value.new_objects->begin(); + force_settlement_id_type settle_id3 { *result3.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id3(db).balance.amount.value, 3 ); - force_settlement_id_type settle_id4 = *result4.get().value.new_objects->begin(); + force_settlement_id_type settle_id4 { *result4.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id4(db).balance.amount.value, 434 ); - force_settlement_id_type settle_id5 = *result5.get().value.new_objects->begin(); + force_settlement_id_type settle_id5 { *result5.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id5(db).balance.amount.value, 5 ); BOOST_CHECK_EQUAL(get_balance(rachel_id(db), core_id(db)), 1); @@ -972,7 +973,8 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) BOOST_CHECK_EQUAL( bitusd_id(db).bitasset_data(db).force_settled_volume.value, 203 ); // 182 + 21 // jim borrow some cny - call_order_id_type call_jim_id = borrow(jim_id(db), bitcny_id(db).amount(2000), core_id(db).amount(2000))->id; + call_order_id_type call_jim_id = borrow(jim_id(db), bitcny_id(db).amount(2000), core_id(db).amount(2000)) + ->get_id(); BOOST_CHECK_EQUAL( 2000, call_jim_id(db).debt.value ); BOOST_CHECK_EQUAL( 2000, call_jim_id(db).collateral.value ); @@ -1002,13 +1004,13 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) const operation_result result7 = force_settle(ted_id(db), bitusd_id(db).amount(21)); const operation_result result8 = force_settle(ted_id(db), bitusd_id(db).amount(22)); - force_settlement_id_type settle_id6 = *result6.get().value.new_objects->begin(); + force_settlement_id_type settle_id6 { *result6.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id6(db).balance.amount.value, 20 ); - force_settlement_id_type settle_id7 = *result7.get().value.new_objects->begin(); + force_settlement_id_type settle_id7 { *result7.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id7(db).balance.amount.value, 21 ); - force_settlement_id_type settle_id8 = *result8.get().value.new_objects->begin(); + force_settlement_id_type settle_id8 { *result8.get().value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id8(db).balance.amount.value, 22 ); BOOST_CHECK_EQUAL(get_balance(ted_id(db), core_id(db)), 0); @@ -1019,16 +1021,16 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) const operation_result result102 = force_settle(joe_id(db), bitcny_id(db).amount(1000)); const operation_result result103 = force_settle(joe_id(db), bitcny_id(db).amount(300)); - force_settlement_id_type settle_id101 = *result101.get() - .value.new_objects->begin(); + force_settlement_id_type settle_id101 { *result101.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id101(db).balance.amount.value, 100 ); - force_settlement_id_type settle_id102 = *result102.get() - .value.new_objects->begin(); + force_settlement_id_type settle_id102 { *result102.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id102(db).balance.amount.value, 1000 ); - force_settlement_id_type settle_id103 = *result103.get() - .value.new_objects->begin(); + force_settlement_id_type settle_id103 { *result103.get() + .value.new_objects->begin() }; BOOST_CHECK_EQUAL( settle_id103(db).balance.amount.value, 300 ); BOOST_CHECK_EQUAL(get_balance(joe_id(db), core_id(db)), 0); @@ -1098,7 +1100,7 @@ BOOST_AUTO_TEST_CASE( settle_rounding_test_after_hf_184 ) // bob borrow some const call_order_object& call_bob = *borrow( bob_id(db), bitusd_id(db).amount(19), core_id(db).amount(2) ); - call_order_id_type call_bob_id = call_bob.id; + call_order_id_type call_bob_id = call_bob.get_id(); BOOST_CHECK_EQUAL(get_balance(bob_id(db), core_id(db)), 9999998); // 10000000 - 2 BOOST_CHECK_EQUAL(get_balance(bob_id(db), bitusd_id(db)), 19); // new @@ -1278,8 +1280,8 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test ) // create assets const auto& bitusd = create_bitasset("USDBIT", paul_id); const auto& core = asset_id_type()(db); - asset_id_type bitusd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type bitusd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); // fund accounts transfer(committee_account, michael_id, asset( 100000000 ) ); @@ -1312,7 +1314,7 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test ) // paul gets some bitusd const call_order_object& call_paul = *borrow( paul_id(db), bitusd_id(db).amount(1001), core_id(db).amount(101)); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL( get_balance( paul_id(db), bitusd_id(db) ), 1001 ); BOOST_REQUIRE_EQUAL( get_balance( paul_id(db), core_id(db) ), 10000000-101); @@ -1328,7 +1330,7 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test ) // michael borrow some bitusd const call_order_object& call_michael = *borrow(michael_id(db), bitusd_id(db).amount(6), core_id(db).amount(8)); - call_order_id_type call_michael_id = call_michael.id; + call_order_id_type call_michael_id = call_michael.get_id(); BOOST_CHECK_EQUAL(get_balance(michael_id(db), bitusd_id(db)), 6); BOOST_CHECK_EQUAL(get_balance(michael_id(db), core_id(db)), 100000000-8); @@ -1350,8 +1352,8 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test ) BOOST_CHECK_EQUAL(get_balance(paul_id(db), bitusd_id(db)), 801); // all call orders are gone after global settle - BOOST_CHECK( !db.find_object(call_paul_id) ); - BOOST_CHECK( !db.find_object(call_michael_id) ); + BOOST_CHECK( !db.find(call_paul_id) ); + BOOST_CHECK( !db.find(call_michael_id) ); // add settle order and check rounding issue force_settle(rachel_id(db), bitusd_id(db).amount(4)); @@ -1408,8 +1410,8 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test_after_hf_184 ) // create assets const auto& bitusd = create_bitasset("USDBIT", paul_id); const auto& core = asset_id_type()(db); - asset_id_type bitusd_id = bitusd.id; - asset_id_type core_id = core.id; + asset_id_type bitusd_id = bitusd.get_id(); + asset_id_type core_id = core.get_id(); // fund accounts transfer(committee_account, michael_id, asset( 100000000 ) ); @@ -1442,7 +1444,7 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test_after_hf_184 ) // paul gets some bitusd const call_order_object& call_paul = *borrow( paul_id(db), bitusd_id(db).amount(1001), core_id(db).amount(101)); - call_order_id_type call_paul_id = call_paul.id; + call_order_id_type call_paul_id = call_paul.get_id(); BOOST_REQUIRE_EQUAL( get_balance( paul_id(db), bitusd_id(db) ), 1001 ); BOOST_REQUIRE_EQUAL( get_balance( paul_id(db), core_id(db) ), 10000000-101); @@ -1458,7 +1460,7 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test_after_hf_184 ) // michael borrow some bitusd const call_order_object& call_michael = *borrow(michael_id(db), bitusd_id(db).amount(6), core_id(db).amount(8)); - call_order_id_type call_michael_id = call_michael.id; + call_order_id_type call_michael_id = call_michael.get_id(); BOOST_CHECK_EQUAL(get_balance(michael_id(db), bitusd_id(db)), 6); BOOST_CHECK_EQUAL(get_balance(michael_id(db), core_id(db)), 100000000-8); @@ -1480,8 +1482,8 @@ BOOST_AUTO_TEST_CASE( global_settle_rounding_test_after_hf_184 ) BOOST_CHECK_EQUAL(get_balance(paul_id(db), bitusd_id(db)), 801); // all call orders are gone after global settle - BOOST_CHECK( !db.find_object(call_paul_id)); - BOOST_CHECK( !db.find_object(call_michael_id)); + BOOST_CHECK( !db.find(call_paul_id)); + BOOST_CHECK( !db.find(call_michael_id)); // settle order will not execute after HF due to too small GRAPHENE_REQUIRE_THROW( force_settle(rachel_id(db), bitusd_id(db).amount(4)), fc::exception ); @@ -1539,7 +1541,7 @@ BOOST_AUTO_TEST_CASE( create_bitassets ) constexpr auto referrer_reward_percent = 10 * GRAPHENE_1_PERCENT; const auto& biteur = create_bitasset( "EURBIT", paul_id, market_fee_percent, charge_market_fee, 2 ); - asset_id_type biteur_id = biteur.id; + asset_id_type biteur_id = biteur.get_id(); const auto& bitusd = create_bitasset( "USDBIT", paul_id, market_fee_percent, charge_market_fee, 2, biteur_id ); @@ -1579,9 +1581,9 @@ BOOST_AUTO_TEST_CASE( market_fee_of_settle_order_before_hardfork_1780 ) GET_ACTOR(rachelreferrer); const asset_object &biteur = get_asset( "EURBIT" ); - asset_id_type biteur_id = biteur.id; + asset_id_type biteur_id = biteur.get_id(); const asset_object &bitusd = get_asset( "USDBIT" ); - asset_id_type bitusd_id = bitusd.id; + asset_id_type bitusd_id = bitusd.get_id(); const auto& core = asset_id_type()(db); @@ -1708,9 +1710,9 @@ BOOST_AUTO_TEST_CASE( market_fee_of_settle_order_after_hardfork_1780 ) GET_ACTOR(rachelreferrer); const asset_object &biteur = get_asset( "EURBIT" ); - asset_id_type biteur_id = biteur.id; + asset_id_type biteur_id = biteur.get_id(); const asset_object &bitusd = get_asset( "USDBIT" ); - asset_id_type bitusd_id = bitusd.id; + asset_id_type bitusd_id = bitusd.get_id(); const auto& core = asset_id_type()(db); @@ -1804,9 +1806,9 @@ BOOST_AUTO_TEST_CASE( market_fee_of_instant_settle_order_after_hardfork_1780 ) GET_ACTOR(rachelreferrer); const asset_object &biteur = get_asset( "EURBIT" ); - asset_id_type biteur_id = biteur.id; + asset_id_type biteur_id = biteur.get_id(); const asset_object &bitusd = get_asset( "USDBIT" ); - asset_id_type bitusd_id = bitusd.id; + asset_id_type bitusd_id = bitusd.get_id(); const auto& core = asset_id_type()(db); @@ -2041,7 +2043,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_gs ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // add a price feed publisher and publish a feed update_feed_producers( mpa_id, { feeder_id } ); @@ -2058,7 +2060,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_gs ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // Transfer funds to seller transfer( borrower, seller, asset(100000,mpa_id) ); @@ -2071,7 +2073,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_gs ) // seller settles some auto result = force_settle( seller, asset(11100,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find(settle_id) ); BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 11100 ); @@ -2167,7 +2169,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_feed ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // add a price feed publisher and publish a feed update_feed_producers( mpa_id, { feeder_id } ); @@ -2184,7 +2186,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_feed ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // Transfer funds to seller transfer( borrower, seller, asset(100000,mpa_id) ); @@ -2197,7 +2199,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_no_feed ) // seller settles some auto result = force_settle( seller, asset(11100,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find(settle_id) ); BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 11100 ); @@ -2284,7 +2286,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_zero_amount ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // add a price feed publisher and publish a feed update_feed_producers( mpa_id, { feeder_id } ); @@ -2301,7 +2303,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_zero_amount ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // Transfer funds to seller transfer( borrower, seller, asset(100000,mpa_id) ); @@ -2314,7 +2316,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_zero_amount ) // seller settles some auto result = force_settle( seller, asset(0,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find(settle_id) ); BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 0 ); @@ -2395,7 +2397,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_100_percent_offset ) trx.operations.push_back( acop ); processed_transaction ptx = PUSH_TX(db, trx, ~0); const asset_object& mpa = db.get(ptx.operation_results[0].get()); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // add a price feed publisher and publish a feed update_feed_producers( mpa_id, { feeder_id } ); @@ -2412,7 +2414,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_100_percent_offset ) // undercollateralization price = 100000:2000 * 1250:1000 = 100000:1600 const call_order_object* call_ptr = borrow( borrower, asset(100000, mpa_id), asset(2000) ); BOOST_REQUIRE( call_ptr ); - call_order_id_type call_id = call_ptr->id; + call_order_id_type call_id = call_ptr->get_id(); // Transfer funds to seller transfer( borrower, seller, asset(100000,mpa_id) ); @@ -2425,7 +2427,7 @@ BOOST_AUTO_TEST_CASE( settle_order_cancel_due_to_100_percent_offset ) // seller settles some auto result = force_settle( seller, asset(11100,mpa_id) ); - force_settlement_id_type settle_id = *result.get().value.new_objects->begin(); + force_settlement_id_type settle_id { *result.get().value.new_objects->begin() }; BOOST_REQUIRE( db.find(settle_id) ); BOOST_CHECK_EQUAL( settle_id(db).balance.amount.value, 11100 ); diff --git a/tests/tests/simple_maker_taker_fee_tests.cpp b/tests/tests/simple_maker_taker_fee_tests.cpp index 90cc65568c..4d287b1538 100644 --- a/tests/tests/simple_maker_taker_fee_tests.cpp +++ b/tests/tests/simple_maker_taker_fee_tests.cpp @@ -111,7 +111,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Initialize actors ACTORS((jill)(izzy)); - account_id_type issuer_id = jill.id; + account_id_type issuer_id = jill.get_id(); fc::ecc::private_key issuer_private_key = jill_private_key; // Initialize tokens @@ -273,12 +273,12 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Approve the proposal trx.clear(); - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = jill.id; pup.proposal = pid; - pup.active_approvals_to_add.insert(jill.id); + pup.active_approvals_to_add.insert(jill.get_id()); trx.operations.push_back(pup); set_expiration(db, trx); sign(trx, jill_private_key); @@ -329,12 +329,12 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Approve the proposal trx.clear(); - proposal_id_type pid = processed.operation_results[0].get(); + proposal_id_type pid { processed.operation_results[0].get() }; proposal_update_operation pup; pup.fee_paying_account = jill.id; pup.proposal = pid; - pup.active_approvals_to_add.insert(jill.id); + pup.active_approvals_to_add.insert(jill.get_id()); trx.operations.push_back(pup); set_expiration(db, trx); sign(trx, jill_private_key); @@ -372,7 +372,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa ACTORS((smartissuer)(feedproducer)); // Initialize tokens - create_bitasset("SMARTBIT", smartissuer.id); + create_bitasset("SMARTBIT", smartissuer.get_id()); // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); const asset_object &bitsmart = get_asset("SMARTBIT"); @@ -492,11 +492,11 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa charlie2coin_market_fee_percent); const uint16_t bitsmart1coin_market_fee_percent = 7 * GRAPHENE_1_PERCENT; - create_bitasset("SMARTBIT1", smartissuer.id, bitsmart1coin_market_fee_percent); + create_bitasset("SMARTBIT1", smartissuer.get_id(), bitsmart1coin_market_fee_percent); const uint16_t bitsmart2coin_market_fee_percent = 8 * GRAPHENE_1_PERCENT; - create_bitasset("SMARTBIT2", smartissuer.id, bitsmart2coin_market_fee_percent); + create_bitasset("SMARTBIT2", smartissuer.get_id(), bitsmart2coin_market_fee_percent); // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); @@ -765,7 +765,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 IZZYCOIN - limit_order_create_operation alice_sell_op = create_sell_operation(alice.id, + limit_order_create_operation alice_sell_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), izzycoin.amount(300 * IZZY_PRECISION)); @@ -774,13 +774,14 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; - const limit_order_object* alice_order_before = db.find(alice_order_id); + const limit_order_object* alice_order_before = db.find(alice_order_id); BOOST_CHECK(alice_order_before != nullptr); // Bob is willing to sell 300 IZZYCOIN for at least 10 JILLCOIN - limit_order_create_operation bob_sell_op = create_sell_operation(bob.id, izzycoin.amount(300 * IZZY_PRECISION), + limit_order_create_operation bob_sell_op = create_sell_operation(bob.get_id(), + izzycoin.amount(300 * IZZY_PRECISION), jillcoin.amount( 10 * JILL_PRECISION)); @@ -789,12 +790,12 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset bob_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type bob_order_id = ptx.operation_results[0].get(); + limit_order_id_type bob_order_id { ptx.operation_results[0].get() }; // Check that the orders were filled by ensuring that they are no longer on the order books - const limit_order_object* alice_order = db.find(alice_order_id); + const limit_order_object* alice_order = db.find(alice_order_id); BOOST_CHECK(alice_order == nullptr); - const limit_order_object* bob_order = db.find(bob_order_id); + const limit_order_object* bob_order = db.find(bob_order_id); BOOST_CHECK(bob_order == nullptr); @@ -930,7 +931,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 IZZYCOIN - limit_order_create_operation alice_sell_op = create_sell_operation(alice.id, + limit_order_create_operation alice_sell_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), izzycoin.amount(300 * IZZY_PRECISION)); @@ -939,13 +940,14 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; - const limit_order_object* alice_order_before = db.find(alice_order_id); + const limit_order_object* alice_order_before = db.find(alice_order_id); BOOST_CHECK(alice_order_before != nullptr); // Bob is willing to sell 300 IZZYCOIN for at least 10 JILLCOIN - limit_order_create_operation bob_sell_op = create_sell_operation(bob.id, izzycoin.amount(300 * IZZY_PRECISION), + limit_order_create_operation bob_sell_op = create_sell_operation(bob.get_id(), + izzycoin.amount(300 * IZZY_PRECISION), jillcoin.amount( 10 * JILL_PRECISION)); @@ -954,12 +956,12 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset bob_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type bob_order_id = ptx.operation_results[0].get(); + limit_order_id_type bob_order_id { ptx.operation_results[0].get() }; // Check that the orders were filled by ensuring that they are no longer on the order books - const limit_order_object* alice_order = db.find(alice_order_id); + const limit_order_object* alice_order = db.find(alice_order_id); BOOST_CHECK(alice_order == nullptr); - const limit_order_object* bob_order = db.find(bob_order_id); + const limit_order_object* bob_order = db.find(bob_order_id); BOOST_CHECK(bob_order == nullptr); @@ -1095,7 +1097,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 IZZYCOIN - limit_order_create_operation alice_sell_op = create_sell_operation(alice.id, + limit_order_create_operation alice_sell_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), izzycoin.amount(300 * IZZY_PRECISION)); @@ -1104,13 +1106,14 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; - const limit_order_object* alice_order_before = db.find(alice_order_id); + const limit_order_object* alice_order_before = db.find(alice_order_id); BOOST_CHECK(alice_order_before != nullptr); // Bob is willing to sell 300 IZZYCOIN for at least 10 JILLCOIN - limit_order_create_operation bob_sell_op = create_sell_operation(bob.id, izzycoin.amount(300 * IZZY_PRECISION), + limit_order_create_operation bob_sell_op = create_sell_operation(bob.get_id(), + izzycoin.amount(300 * IZZY_PRECISION), jillcoin.amount( 10 * JILL_PRECISION)); @@ -1119,12 +1122,12 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset bob_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type bob_order_id = ptx.operation_results[0].get(); + limit_order_id_type bob_order_id { ptx.operation_results[0].get() }; // Check that the orders were filled by ensuring that they are no longer on the order books - const limit_order_object* alice_order = db.find(alice_order_id); + const limit_order_object* alice_order = db.find(alice_order_id); BOOST_CHECK(alice_order == nullptr); - const limit_order_object* bob_order = db.find(bob_order_id); + const limit_order_object* bob_order = db.find(bob_order_id); BOOST_CHECK(bob_order == nullptr); @@ -1229,7 +1232,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 IZZYCOIN - limit_order_create_operation alice_sell_op = create_sell_operation(alice.id, + limit_order_create_operation alice_sell_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), izzycoin.amount(300 * IZZY_PRECISION)); @@ -1238,13 +1241,14 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; - const limit_order_object* alice_order_before = db.find(alice_order_id); + const limit_order_object* alice_order_before = db.find(alice_order_id); BOOST_CHECK(alice_order_before != nullptr); // Bob is willing to sell 300 IZZYCOIN for at least 10 JILLCOIN - limit_order_create_operation bob_sell_op = create_sell_operation(bob.id, izzycoin.amount(300 * IZZY_PRECISION), + limit_order_create_operation bob_sell_op = create_sell_operation(bob.get_id(), + izzycoin.amount(300 * IZZY_PRECISION), jillcoin.amount( 10 * JILL_PRECISION)); @@ -1253,12 +1257,12 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset bob_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type bob_order_id = ptx.operation_results[0].get(); + limit_order_id_type bob_order_id { ptx.operation_results[0].get() }; // Check that the orders were filled by ensuring that they are no longer on the order books - const limit_order_object* alice_order = db.find(alice_order_id); + const limit_order_object* alice_order = db.find(alice_order_id); BOOST_CHECK(alice_order == nullptr); - const limit_order_object* bob_order = db.find(bob_order_id); + const limit_order_object* bob_order = db.find(bob_order_id); BOOST_CHECK(bob_order == nullptr); @@ -1309,7 +1313,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa const uint16_t SMARTBIT_PRECISION = 10000; const uint16_t smartbit_market_fee_percent = 2 * GRAPHENE_1_PERCENT; - create_bitasset("SMARTBIT", smartissuer.id, smartbit_market_fee_percent, + create_bitasset("SMARTBIT", smartissuer.get_id(), smartbit_market_fee_percent, charge_market_fee, 4); // Obtain asset object after a block is generated to obtain the final object that is commited to the database @@ -1318,7 +1322,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa const auto &core = asset_id_type()(db); - update_feed_producers(smartbit, {feedproducer.id}); + update_feed_producers(smartbit, {feedproducer.get_id()}); price_feed current_feed; current_feed.settlement_price = smartbit.amount(100) / core.amount(100); @@ -1402,7 +1406,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa BOOST_REQUIRE_EQUAL(get_balance(alice, jillcoin), 10 * JILL_PRECISION); BOOST_TEST_MESSAGE("Issuing 300 SMARTBIT to bob"); - transfer(committee_account, bob.id, asset(10000000)); + transfer(committee_account, bob.get_id(), asset(10000000)); publish_feed(smartbit, feedproducer, current_feed); // Publish a recent feed borrow(bob, smartbit.amount(300 * SMARTBIT_PRECISION), asset(2 * 300 * SMARTBIT_PRECISION)); BOOST_TEST_MESSAGE("Checking bob's balance"); @@ -1410,7 +1414,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 SMARTBIT - limit_order_create_operation alice_sell_op = create_sell_operation(alice.id, + limit_order_create_operation alice_sell_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), smartbit.amount(300 * SMARTBIT_PRECISION)); trx.clear(); @@ -1418,27 +1422,27 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type alice_order_id = ptx.operation_results[0].get(); + limit_order_id_type alice_order_id { ptx.operation_results[0].get() }; - const limit_order_object *alice_order_before = db.find(alice_order_id); + const limit_order_object *alice_order_before = db.find(alice_order_id); BOOST_CHECK(alice_order_before != nullptr); // Bob is willing to sell 300 SMARTBIT for at least 10 JILLCOIN limit_order_create_operation bob_sell_op - = create_sell_operation(bob.id, smartbit.amount(300 * SMARTBIT_PRECISION), + = create_sell_operation(bob.get_id(), smartbit.amount(300 * SMARTBIT_PRECISION), jillcoin.amount(10 * JILL_PRECISION)); trx.clear(); trx.operations.push_back(bob_sell_op); asset bob_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type bob_order_id = ptx.operation_results[0].get(); + limit_order_id_type bob_order_id { ptx.operation_results[0].get() }; // Check that the orders were filled by ensuring that they are no longer on the order books - const limit_order_object *alice_order = db.find(alice_order_id); + const limit_order_object *alice_order = db.find(alice_order_id); BOOST_CHECK(alice_order == nullptr); - const limit_order_object *bob_order = db.find(bob_order_id); + const limit_order_object *bob_order = db.find(bob_order_id); BOOST_CHECK(bob_order == nullptr); @@ -1503,7 +1507,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa const uint16_t SMARTBIT_PRECISION = 10000; const uint16_t smartbit_market_fee_percent = 2 * GRAPHENE_1_PERCENT; - create_bitasset("SMARTBIT", smartissuer.id, smartbit_market_fee_percent, + create_bitasset("SMARTBIT", smartissuer.get_id(), smartbit_market_fee_percent, charge_market_fee, 4); // Obtain asset object after a block is generated to obtain the final object that is commited to the database generate_block(); @@ -1511,7 +1515,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa const auto &core = asset_id_type()(db); - update_feed_producers(smartbit, {feedproducer.id}); + update_feed_producers(smartbit, {feedproducer.get_id()}); price_feed current_feed; current_feed.settlement_price = smartbit.amount(100) / core.amount(100); @@ -1601,7 +1605,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa BOOST_REQUIRE_EQUAL(get_balance(alice, jillcoin), 10 * JILL_PRECISION); BOOST_TEST_MESSAGE("Issuing 600 SMARTBIT to bob"); - transfer(committee_account, bob.id, asset(2 * 1000 * SMARTBIT_PRECISION)); + transfer(committee_account, bob.get_id(), asset(2 * 1000 * SMARTBIT_PRECISION)); publish_feed(smartbit, feedproducer, current_feed); // Publish a recent feed borrow(bob, smartbit.amount(600 * SMARTBIT_PRECISION), asset(2 * 600 * SMARTBIT_PRECISION)); BOOST_TEST_MESSAGE("Checking bob's balance"); @@ -1609,7 +1613,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 SMARTBIT - limit_order_create_operation order_1_op = create_sell_operation(alice.id, + limit_order_create_operation order_1_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), smartbit.amount(300 * SMARTBIT_PRECISION)); trx.clear(); @@ -1617,28 +1621,28 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type order_1_id = ptx.operation_results[0].get(); + limit_order_id_type order_1_id { ptx.operation_results[0].get() }; - const limit_order_object *order_1_before = db.find(order_1_id); + const limit_order_object *order_1_before = db.find(order_1_id); BOOST_CHECK(order_1_before != nullptr); // Bob is willing to sell 600 SMARTBIT for at least 20 JILLCOIN limit_order_create_operation order_2_op - = create_sell_operation(bob.id, smartbit.amount(600 * SMARTBIT_PRECISION), + = create_sell_operation(bob.get_id(), smartbit.amount(600 * SMARTBIT_PRECISION), jillcoin.amount(20 * JILL_PRECISION)); trx.clear(); trx.operations.push_back(order_2_op); asset order_2_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type order_2_id = ptx.operation_results[0].get(); + limit_order_id_type order_2_id { ptx.operation_results[0].get() }; // Check that order 1 was completely filled by ensuring that they it is no longer on the order book - const limit_order_object *order_1 = db.find(order_1_id); + const limit_order_object *order_1 = db.find(order_1_id); BOOST_CHECK(order_1 == nullptr); // Check that order 2 was partially filled by ensuring that they it is still on the order book - const limit_order_object *order_2 = db.find(order_2_id); + const limit_order_object *order_2 = db.find(order_2_id); BOOST_CHECK(order_2 != nullptr); @@ -1678,7 +1682,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa BOOST_REQUIRE_EQUAL(get_balance(charlie, jillcoin), 5 * JILL_PRECISION); // Charlie is is willing to sell 5 JILLCOIN for at least 150 SMARTBIT - limit_order_create_operation order_3_op = create_sell_operation(charlie.id, + limit_order_create_operation order_3_op = create_sell_operation(charlie.get_id(), jillcoin.amount(5 * JILL_PRECISION), smartbit.amount(150 * SMARTBIT_PRECISION)); trx.clear(); @@ -1686,14 +1690,14 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset charlie_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, charlie_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type order_3_id = ptx.operation_results[0].get(); + limit_order_id_type order_3_id { ptx.operation_results[0].get() }; // Order 3 should be completely filled - const limit_order_object *order_3 = db.find(order_3_id); + const limit_order_object *order_3 = db.find(order_3_id); BOOST_CHECK(order_3 == nullptr); // Order 2 should be partially filled and still present on the order books - const limit_order_object *order_2_after = db.find(order_2_id); + const limit_order_object *order_2_after = db.find(order_2_id); BOOST_CHECK(order_2_after != nullptr); // Check the new balance of the taker @@ -1766,7 +1770,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa const uint16_t SMARTBIT_PRECISION = 10000; const uint16_t smartbit_market_fee_percent = 2 * GRAPHENE_1_PERCENT; - create_bitasset("SMARTBIT", smartissuer.id, smartbit_market_fee_percent, + create_bitasset("SMARTBIT", smartissuer.get_id(), smartbit_market_fee_percent, charge_market_fee, 4); uint16_t jill_maker_fee_percent = jill_market_fee_percent; @@ -1782,7 +1786,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa const auto &core = asset_id_type()(db); - update_feed_producers(smartbit, {feedproducer.id}); + update_feed_producers(smartbit, {feedproducer.get_id()}); price_feed current_feed; current_feed.settlement_price = smartbit.amount(100) / core.amount(100); @@ -1803,7 +1807,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa BOOST_REQUIRE_EQUAL(get_balance(alice, jillcoin), 10 * JILL_PRECISION); BOOST_TEST_MESSAGE("Issuing 600 SMARTBIT to bob"); - transfer(committee_account, bob.id, asset(2 * 1000 * SMARTBIT_PRECISION)); + transfer(committee_account, bob.get_id(), asset(2 * 1000 * SMARTBIT_PRECISION)); publish_feed(smartbit, feedproducer, current_feed); // Publish a recent feed borrow(bob, smartbit.amount(600 * SMARTBIT_PRECISION), asset(2 * 600 * SMARTBIT_PRECISION)); BOOST_TEST_MESSAGE("Checking bob's balance"); @@ -1811,7 +1815,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa // Alice and Bob place orders which match, and are completely filled by each other // Alice is willing to sell 10 JILLCOIN for at least 300 SMARTBIT - limit_order_create_operation order_1_op = create_sell_operation(alice.id, + limit_order_create_operation order_1_op = create_sell_operation(alice.get_id(), jillcoin.amount(10 * JILL_PRECISION), smartbit.amount(300 * SMARTBIT_PRECISION)); trx.clear(); @@ -1819,28 +1823,28 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset alice_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, alice_private_key); processed_transaction ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type order_1_id = ptx.operation_results[0].get(); + limit_order_id_type order_1_id { ptx.operation_results[0].get() }; - const limit_order_object *order_1_before = db.find(order_1_id); + const limit_order_object *order_1_before = db.find(order_1_id); BOOST_CHECK(order_1_before != nullptr); // Bob is willing to sell 600 SMARTBIT for at least 20 JILLCOIN limit_order_create_operation order_2_op - = create_sell_operation(bob.id, smartbit.amount(600 * SMARTBIT_PRECISION), + = create_sell_operation(bob.get_id(), smartbit.amount(600 * SMARTBIT_PRECISION), jillcoin.amount(20 * JILL_PRECISION)); trx.clear(); trx.operations.push_back(order_2_op); asset order_2_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, bob_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type order_2_id = ptx.operation_results[0].get(); + limit_order_id_type order_2_id { ptx.operation_results[0].get() }; // Check that order 1 was completely filled by ensuring that they it is no longer on the order book - const limit_order_object *order_1 = db.find(order_1_id); + const limit_order_object *order_1 = db.find(order_1_id); BOOST_CHECK(order_1 == nullptr); // Check that order 2 was partially filled by ensuring that they it is still on the order book - const limit_order_object *order_2 = db.find(order_2_id); + const limit_order_object *order_2 = db.find(order_2_id); BOOST_CHECK(order_2 != nullptr); @@ -1900,7 +1904,7 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa BOOST_REQUIRE_EQUAL(get_balance(charlie, jillcoin), 5 * JILL_PRECISION); // Charlie is is willing to sell 5 JILLCOIN for at least 150 SMARTBIT - limit_order_create_operation order_3_op = create_sell_operation(charlie.id, + limit_order_create_operation order_3_op = create_sell_operation(charlie.get_id(), jillcoin.amount(5 * JILL_PRECISION), smartbit.amount(150 * SMARTBIT_PRECISION)); trx.clear(); @@ -1908,14 +1912,14 @@ BOOST_FIXTURE_TEST_SUITE(simple_maker_taker_fee_tests, simple_maker_taker_databa asset charlie_sell_fee = db.current_fee_schedule().set_fee(trx.operations.back()); sign(trx, charlie_private_key); ptx = PUSH_TX(db, trx); // No exception should be thrown - limit_order_id_type order_3_id = ptx.operation_results[0].get(); + limit_order_id_type order_3_id { ptx.operation_results[0].get() }; // Order 3 should be completely filled - const limit_order_object *order_3 = db.find(order_3_id); + const limit_order_object *order_3 = db.find(order_3_id); BOOST_CHECK(order_3 == nullptr); // Order 2 should be partially filled and still present on the order books - const limit_order_object *order_2_after = db.find(order_2_id); + const limit_order_object *order_2_after = db.find(order_2_id); BOOST_CHECK(order_2_after != nullptr); // Check the new balance of the taker diff --git a/tests/tests/smartcoin_tests.cpp b/tests/tests/smartcoin_tests.cpp index 7d69caaa05..43fe290ec3 100644 --- a/tests/tests/smartcoin_tests.cpp +++ b/tests/tests/smartcoin_tests.cpp @@ -71,18 +71,18 @@ BOOST_AUTO_TEST_CASE(bsip36) upgrade_to_lifetime_member(witness11_id); // Create all the witnesses - const witness_id_type witness0_witness_id = create_witness(witness0_id, witness0_private_key).id; - const witness_id_type witness1_witness_id = create_witness(witness1_id, witness1_private_key).id; - const witness_id_type witness2_witness_id = create_witness(witness2_id, witness2_private_key).id; - const witness_id_type witness3_witness_id = create_witness(witness3_id, witness3_private_key).id; - const witness_id_type witness4_witness_id = create_witness(witness4_id, witness4_private_key).id; - const witness_id_type witness5_witness_id = create_witness(witness5_id, witness5_private_key).id; - const witness_id_type witness6_witness_id = create_witness(witness6_id, witness6_private_key).id; - const witness_id_type witness7_witness_id = create_witness(witness7_id, witness7_private_key).id; - const witness_id_type witness8_witness_id = create_witness(witness8_id, witness8_private_key).id; - const witness_id_type witness9_witness_id = create_witness(witness9_id, witness9_private_key).id; - const witness_id_type witness10_witness_id = create_witness(witness10_id, witness10_private_key).id; - const witness_id_type witness11_witness_id = create_witness(witness11_id, witness11_private_key).id; + const witness_id_type witness0_witness_id = create_witness(witness0_id, witness0_private_key).get_id(); + const witness_id_type witness1_witness_id = create_witness(witness1_id, witness1_private_key).get_id(); + const witness_id_type witness2_witness_id = create_witness(witness2_id, witness2_private_key).get_id(); + const witness_id_type witness3_witness_id = create_witness(witness3_id, witness3_private_key).get_id(); + const witness_id_type witness4_witness_id = create_witness(witness4_id, witness4_private_key).get_id(); + const witness_id_type witness5_witness_id = create_witness(witness5_id, witness5_private_key).get_id(); + const witness_id_type witness6_witness_id = create_witness(witness6_id, witness6_private_key).get_id(); + const witness_id_type witness7_witness_id = create_witness(witness7_id, witness7_private_key).get_id(); + const witness_id_type witness8_witness_id = create_witness(witness8_id, witness8_private_key).get_id(); + const witness_id_type witness9_witness_id = create_witness(witness9_id, witness9_private_key).get_id(); + const witness_id_type witness10_witness_id = create_witness(witness10_id, witness10_private_key).get_id(); + const witness_id_type witness11_witness_id = create_witness(witness11_id, witness11_private_key).get_id(); // Create a vector with private key of all witnesses, will be used to activate 11 witnesses at a time const vector private_keys = { @@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(bsip36) }; // Create the asset - const asset_id_type bit_usd_id = create_bitasset("USDBIT").id; + const asset_id_type bit_usd_id = create_bitasset("USDBIT").get_id(); // Update the asset to be fed by system witnesses asset_update_operation op; @@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) ACTORS( (sam)(alice)(paul)(bob) ); // Create the asset - const asset_id_type bit_usd_id = create_bitasset("USDBIT").id; + const asset_id_type bit_usd_id = create_bitasset("USDBIT").get_id(); // Update asset issuer const asset_object &asset_obj = bit_usd_id(db); @@ -482,14 +482,14 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) INVOKE( bsip36 ); // get the stuff needed from invoked test - const asset_id_type bit_usd_id = get_asset("USDBIT").id; + const asset_id_type bit_usd_id = get_asset("USDBIT").get_id(); const asset_id_type core_id = asset_id_type(); - const account_id_type witness5_id= get_account("witness5").id; - const account_id_type witness6_id= get_account("witness6").id; - const account_id_type witness7_id= get_account("witness7").id; - const account_id_type witness8_id= get_account("witness8").id; - const account_id_type witness9_id= get_account("witness9").id; - const account_id_type witness10_id= get_account("witness10").id; + const account_id_type witness5_id= get_account("witness5").get_id(); + const account_id_type witness6_id= get_account("witness6").get_id(); + const account_id_type witness7_id= get_account("witness7").get_id(); + const account_id_type witness8_id= get_account("witness8").get_id(); + const account_id_type witness9_id= get_account("witness9").get_id(); + const account_id_type witness10_id= get_account("witness10").get_id(); set_expiration( db, trx ); diff --git a/tests/tests/swan_tests.cpp b/tests/tests/swan_tests.cpp index 7253f4134d..4711f46e0d 100644 --- a/tests/tests/swan_tests.cpp +++ b/tests/tests/swan_tests.cpp @@ -79,7 +79,7 @@ struct swan_fixture : database_fixture { bitusd_ptr = &db.get(ptx.operation_results[0].get()); } const auto& bitusd = *bitusd_ptr; - _swan = bitusd.id; + _swan = bitusd.get_id(); _back = asset_id_type(); update_feed_producers(swan(), {_feedproducer}); } @@ -99,7 +99,7 @@ struct swan_fixture : database_fixture { set_feed( 1, 2 ); // this sell order is designed to trigger a black swan - limit_order_id_type oid = create_sell_order( borrower2(), swan().amount(1), back().amount(3) )->id; + limit_order_id_type oid = create_sell_order( borrower2(), swan().amount(1), back().amount(3) )->get_id(); FC_ASSERT( get_balance(borrower(), swan()) == amount1 ); FC_ASSERT( get_balance(borrower2(), swan()) == amount2 - 1 ); @@ -228,16 +228,16 @@ BOOST_AUTO_TEST_CASE( black_swan_issue_346 ) { int64_t bal = get_balance( *actor, core ); if( bal < init_balance ) - transfer( committee_account, actor->id, asset(init_balance - bal) ); + transfer( committee_account, actor->get_id(), asset(init_balance - bal) ); else if( bal > init_balance ) - transfer( actor->id, committee_account, asset(bal - init_balance) ); + transfer( actor->get_id(), committee_account, asset(bal - init_balance) ); } }; auto setup_asset = [&]() -> const asset_object& { const asset_object& bitusd = create_bitasset("USDBIT"+fc::to_string(trial)+"X", feeder_id); - update_feed_producers( bitusd, {feeder.id} ); + update_feed_producers( bitusd, {feeder.get_id()} ); BOOST_CHECK( !bitusd.bitasset_data(db).has_settlement() ); trial++; return bitusd; @@ -306,17 +306,17 @@ BOOST_AUTO_TEST_CASE( black_swan_issue_346 ) borrow( borrower, bitusd.amount(100), asset(5000) ); // 2x collat transfer( borrower, seller, bitusd.amount(100) ); // this order is at $0.019, we should not be able to match against it - limit_order_id_type oid_019 = create_sell_order( seller, bitusd.amount(39), core.amount(2000) )->id; + limit_order_id_type oid_019 = create_sell_order( seller, bitusd.amount(39), core.amount(2000) )->get_id(); // this order is at $0.020, we should be able to match against it - limit_order_id_type oid_020 = create_sell_order( seller, bitusd.amount(40), core.amount(2000) )->id; + limit_order_id_type oid_020 = create_sell_order( seller, bitusd.amount(40), core.amount(2000) )->get_id(); set_price( bitusd, bitusd.amount(21) / core.amount(1000) ); // $0.021 // // We attempt to match against $0.019 order and black swan, // and this is intended behavior. See discussion in ticket. // BOOST_CHECK( bitusd.bitasset_data(db).has_settlement() ); - BOOST_CHECK( db.find_object( oid_019 ) != nullptr ); - BOOST_CHECK( db.find_object( oid_020 ) == nullptr ); + BOOST_CHECK( db.find( oid_019 ) != nullptr ); + BOOST_CHECK( db.find( oid_020 ) == nullptr ); } } catch( const fc::exception& e) { @@ -562,7 +562,7 @@ BOOST_AUTO_TEST_CASE( recollateralize ) update_feed_producers(bitcny, {_feedproducer}); price_feed feed; feed.settlement_price = bitcny.amount(1) / asset(1); - publish_feed( bitcny.id, _feedproducer, feed ); + publish_feed( bitcny.get_id(), _feedproducer, feed ); borrow( borrower2(), bitcny.amount(100), asset(1000) ); // can't bid wrong collateral type @@ -828,7 +828,7 @@ BOOST_AUTO_TEST_CASE( revive_empty_with_bid ) set_feed( 1, 2 ); // this sell order is designed to trigger a black swan - limit_order_id_type oid = create_sell_order( borrower2(), swan().amount(1), back().amount(3) )->id; + limit_order_id_type oid = create_sell_order( borrower2(), swan().amount(1), back().amount(3) )->get_id(); BOOST_CHECK( swan().bitasset_data(db).has_settlement() ); cancel_limit_order( oid(db) ); @@ -1016,15 +1016,15 @@ BOOST_AUTO_TEST_CASE( hf2281_asset_permissions_flags_test ) // create a PM with a zero market_fee_percent const asset_object& pm = create_prediction_market( "TESTPM", sam_id, 0, charge_market_fee ); - asset_id_type pm_id = pm.id; + asset_id_type pm_id = pm.get_id(); // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); // create a UIA with a zero market_fee_percent const asset_object& uia = create_user_issued_asset( "TESTUIA", sam_id(db), charge_market_fee ); - asset_id_type uia_id = uia.id; + asset_id_type uia_id = uia.get_id(); // Prepare for asset update asset_update_operation auop; @@ -1168,7 +1168,7 @@ BOOST_AUTO_TEST_CASE( hf2281_asset_owner_permission_test ) // create a MPA with a zero market_fee_percent const asset_object& mpa = create_bitasset( "TESTBIT", sam_id, 0, charge_market_fee ); - asset_id_type mpa_id = mpa.id; + asset_id_type mpa_id = mpa.get_id(); BOOST_CHECK( mpa_id(db).can_bid_collateral() ); @@ -1300,7 +1300,7 @@ BOOST_AUTO_TEST_CASE( disable_collateral_bidding_test ) // Disable collateral bidding asset_update_operation auop; auop.issuer = swan().issuer; - auop.asset_to_update = swan().id; + auop.asset_to_update = swan().get_id(); auop.new_options = swan().options; auop.new_options.flags |= disable_collateral_bidding; trx.operations.clear(); @@ -1428,7 +1428,7 @@ BOOST_AUTO_TEST_CASE( update_bitasset_after_gs ) // unable to update backing asset - asset_id_type uia_id = create_user_issued_asset( "MYUIA" ).id; + asset_id_type uia_id = create_user_issued_asset( "MYUIA" ).get_id(); aubop.new_options.short_backing_asset = uia_id; diff --git a/tests/tests/uia_tests.cpp b/tests/tests/uia_tests.cpp index fff0947c09..320c0bc255 100644 --- a/tests/tests/uia_tests.cpp +++ b/tests/tests/uia_tests.cpp @@ -44,7 +44,7 @@ BOOST_FIXTURE_TEST_SUITE( uia_tests, database_fixture ) BOOST_AUTO_TEST_CASE( create_advanced_uia ) { try { - asset_id_type test_asset_id = db.get_index().get_next_id(); + asset_id_type test_asset_id { db.get_index().get_next_id() }; asset_create_operation creator; creator.issuer = account_id_type(); creator.fee = asset(); @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE( override_transfer_whitelist_test ) { try { ACTORS( (dan)(eric)(sam) ); const asset_object& advanced = create_user_issued_asset( "ADVANCED", sam, white_list | override_authority ); - asset_id_type advanced_id = advanced.id; + asset_id_type advanced_id = advanced.get_id(); BOOST_TEST_MESSAGE( "Issuing 1000 ADVANCED to dan" ); issue_uia( dan, advanced.amount( 1000 ) ); BOOST_TEST_MESSAGE( "Checking dan's balance" ); @@ -223,11 +223,11 @@ BOOST_AUTO_TEST_CASE( override_transfer_whitelist_test ) BOOST_AUTO_TEST_CASE( issue_whitelist_uia ) { try { - account_id_type izzy_id = create_account("izzy").id; + account_id_type izzy_id = create_account("izzy").get_id(); const asset_id_type uia_id = create_user_issued_asset( - "ADVANCED", izzy_id(db), white_list ).id; - account_id_type nathan_id = create_account("nathan").id; - account_id_type vikram_id = create_account("vikram").id; + "ADVANCED", izzy_id(db), white_list ).get_id(); + account_id_type nathan_id = create_account("nathan").get_id(); + account_id_type vikram_id = create_account("vikram").get_id(); trx.clear(); asset_issue_operation op; @@ -306,10 +306,10 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia ) try { INVOKE(issue_whitelist_uia); const asset_object& advanced = get_asset("ADVANCED"); - const asset_id_type uia_id = advanced.id; + const asset_id_type uia_id = advanced.get_id(); const account_object& nathan = get_account("nathan"); const account_object& dan = create_account("dan"); - account_id_type izzy_id = get_account("izzy").id; + account_id_type izzy_id = get_account("izzy").get_id(); upgrade_to_lifetime_member(dan); trx.clear(); @@ -382,10 +382,11 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia ) op.asset_to_update = advanced.id; op.new_options = advanced.options; op.new_options.blacklist_authorities.clear(); - op.new_options.blacklist_authorities.insert(dan.id); + op.new_options.blacklist_authorities.insert(dan.get_id()); trx.operations.back() = op; PUSH_TX( db, trx, ~0 ); - BOOST_CHECK(advanced.options.blacklist_authorities.find(dan.id) != advanced.options.blacklist_authorities.end()); + BOOST_CHECK(advanced.options.blacklist_authorities.find(dan.get_id()) + != advanced.options.blacklist_authorities.end()); } BOOST_TEST_MESSAGE( "Attempting to transfer from dan back to nathan" ); @@ -669,11 +670,14 @@ BOOST_AUTO_TEST_CASE( asset_name_test ) do { if ( (c >= 48 && c <= 57) ) // numbers - BOOST_CHECK_MESSAGE( test_asset_char(this, alice_id(db), c, false, true, true), "Failed on good ASCII value " + std::to_string(c) ); + BOOST_CHECK_MESSAGE( test_asset_char(this, alice_id(db), c, false, true, true), + "Failed on good ASCII value " + std::to_string(c) ); else if ( c >= 65 && c <= 90) // letters - BOOST_CHECK_MESSAGE( test_asset_char(this, alice_id(db), c, true, true, true), "Failed on good ASCII value " + std::to_string(c) ); + BOOST_CHECK_MESSAGE( test_asset_char(this, alice_id(db), c, true, true, true), + "Failed on good ASCII value " + std::to_string(c) ); else // everything else - BOOST_CHECK_MESSAGE( test_asset_char(this, alice_id(db), c, false, false, false), "Failed on bad ASCII value " + std::to_string(c) ); + BOOST_CHECK_MESSAGE( test_asset_char(this, alice_id(db), c, false, false, false), + "Failed on bad ASCII value " + std::to_string(c) ); c++; } while (c != 0); } diff --git a/tests/tests/voting_tests.cpp b/tests/tests/voting_tests.cpp index 019c60fc20..22bde94bec 100644 --- a/tests/tests/voting_tests.cpp +++ b/tests/tests/voting_tests.cpp @@ -117,20 +117,20 @@ BOOST_AUTO_TEST_CASE(put_my_witnesses) upgrade_to_lifetime_member(witness13_id); // Create all the witnesses - const witness_id_type witness0_witness_id = create_witness(witness0_id, witness0_private_key).id; - const witness_id_type witness1_witness_id = create_witness(witness1_id, witness1_private_key).id; - const witness_id_type witness2_witness_id = create_witness(witness2_id, witness2_private_key).id; - const witness_id_type witness3_witness_id = create_witness(witness3_id, witness3_private_key).id; - const witness_id_type witness4_witness_id = create_witness(witness4_id, witness4_private_key).id; - const witness_id_type witness5_witness_id = create_witness(witness5_id, witness5_private_key).id; - const witness_id_type witness6_witness_id = create_witness(witness6_id, witness6_private_key).id; - const witness_id_type witness7_witness_id = create_witness(witness7_id, witness7_private_key).id; - const witness_id_type witness8_witness_id = create_witness(witness8_id, witness8_private_key).id; - const witness_id_type witness9_witness_id = create_witness(witness9_id, witness9_private_key).id; - const witness_id_type witness10_witness_id = create_witness(witness10_id, witness10_private_key).id; - const witness_id_type witness11_witness_id = create_witness(witness11_id, witness11_private_key).id; - const witness_id_type witness12_witness_id = create_witness(witness12_id, witness12_private_key).id; - const witness_id_type witness13_witness_id = create_witness(witness13_id, witness13_private_key).id; + const witness_id_type witness0_witness_id = create_witness(witness0_id, witness0_private_key).get_id(); + const witness_id_type witness1_witness_id = create_witness(witness1_id, witness1_private_key).get_id(); + const witness_id_type witness2_witness_id = create_witness(witness2_id, witness2_private_key).get_id(); + const witness_id_type witness3_witness_id = create_witness(witness3_id, witness3_private_key).get_id(); + const witness_id_type witness4_witness_id = create_witness(witness4_id, witness4_private_key).get_id(); + const witness_id_type witness5_witness_id = create_witness(witness5_id, witness5_private_key).get_id(); + const witness_id_type witness6_witness_id = create_witness(witness6_id, witness6_private_key).get_id(); + const witness_id_type witness7_witness_id = create_witness(witness7_id, witness7_private_key).get_id(); + const witness_id_type witness8_witness_id = create_witness(witness8_id, witness8_private_key).get_id(); + const witness_id_type witness9_witness_id = create_witness(witness9_id, witness9_private_key).get_id(); + const witness_id_type witness10_witness_id = create_witness(witness10_id, witness10_private_key).get_id(); + const witness_id_type witness11_witness_id = create_witness(witness11_id, witness11_private_key).get_id(); + const witness_id_type witness12_witness_id = create_witness(witness12_id, witness12_private_key).get_id(); + const witness_id_type witness13_witness_id = create_witness(witness13_id, witness13_private_key).get_id(); // Create a vector with private key of all witnesses, will be used to activate 9 witnesses at a time const vector private_keys = { @@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_enabled) INVOKE(put_my_witnesses); - const account_id_type witness1_id= get_account("witness1").id; + const account_id_type witness1_id= get_account("witness1").get_id(); auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name); BOOST_CHECK_EQUAL(witness1_object->total_votes, 111u); @@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_disabled) INVOKE(put_my_witnesses); - const account_id_type witness1_id= get_account("witness1").id; + const account_id_type witness1_id= get_account("witness1").get_id(); auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name); BOOST_CHECK_EQUAL(witness1_object->total_votes, 0u); @@ -289,20 +289,20 @@ BOOST_AUTO_TEST_CASE(put_my_committee_members) upgrade_to_lifetime_member(committee13_id); // Create all the committee - const committee_member_id_type committee0_committee_id = create_committee_member(committee0_id(db)).id; - const committee_member_id_type committee1_committee_id = create_committee_member(committee1_id(db)).id; - const committee_member_id_type committee2_committee_id = create_committee_member(committee2_id(db)).id; - const committee_member_id_type committee3_committee_id = create_committee_member(committee3_id(db)).id; - const committee_member_id_type committee4_committee_id = create_committee_member(committee4_id(db)).id; - const committee_member_id_type committee5_committee_id = create_committee_member(committee5_id(db)).id; - const committee_member_id_type committee6_committee_id = create_committee_member(committee6_id(db)).id; - const committee_member_id_type committee7_committee_id = create_committee_member(committee7_id(db)).id; - const committee_member_id_type committee8_committee_id = create_committee_member(committee8_id(db)).id; - const committee_member_id_type committee9_committee_id = create_committee_member(committee9_id(db)).id; - const committee_member_id_type committee10_committee_id = create_committee_member(committee10_id(db)).id; - const committee_member_id_type committee11_committee_id = create_committee_member(committee11_id(db)).id; - const committee_member_id_type committee12_committee_id = create_committee_member(committee12_id(db)).id; - const committee_member_id_type committee13_committee_id = create_committee_member(committee13_id(db)).id; + const committee_member_id_type committee0_committee_id = create_committee_member(committee0_id(db)).get_id(); + const committee_member_id_type committee1_committee_id = create_committee_member(committee1_id(db)).get_id(); + const committee_member_id_type committee2_committee_id = create_committee_member(committee2_id(db)).get_id(); + const committee_member_id_type committee3_committee_id = create_committee_member(committee3_id(db)).get_id(); + const committee_member_id_type committee4_committee_id = create_committee_member(committee4_id(db)).get_id(); + const committee_member_id_type committee5_committee_id = create_committee_member(committee5_id(db)).get_id(); + const committee_member_id_type committee6_committee_id = create_committee_member(committee6_id(db)).get_id(); + const committee_member_id_type committee7_committee_id = create_committee_member(committee7_id(db)).get_id(); + const committee_member_id_type committee8_committee_id = create_committee_member(committee8_id(db)).get_id(); + const committee_member_id_type committee9_committee_id = create_committee_member(committee9_id(db)).get_id(); + const committee_member_id_type committee10_committee_id = create_committee_member(committee10_id(db)).get_id(); + const committee_member_id_type committee11_committee_id = create_committee_member(committee11_id(db)).get_id(); + const committee_member_id_type committee12_committee_id = create_committee_member(committee12_id(db)).get_id(); + const committee_member_id_type committee13_committee_id = create_committee_member(committee13_id(db)).get_id(); // Create a vector with private key of all committee members, will be used to activate 9 members at a time const vector private_keys = { @@ -410,7 +410,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_enabled) INVOKE(put_my_committee_members); - const account_id_type committee1_id= get_account("committee1").id; + const account_id_type committee1_id= get_account("committee1").get_id(); auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name); BOOST_CHECK_EQUAL(committee1_object->total_votes, 111u); @@ -425,7 +425,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_disabled) INVOKE(put_my_committee_members); - const account_id_type committee1_id= get_account("committee1").id; + const account_id_type committee1_id= get_account("committee1").get_id(); auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name); BOOST_CHECK_EQUAL(committee1_object->total_votes, 0u); @@ -614,7 +614,7 @@ BOOST_AUTO_TEST_CASE( witness_votes_calculation ) { auto wit_object = db_api1.get_witness_by_account( wit_account_ids[i](db).name ); BOOST_REQUIRE( wit_object.valid() ); - wit_ids.push_back( wit_object->id ); + wit_ids.push_back( wit_object->get_id() ); } generate_blocks( HARDFORK_CORE_2103_TIME - 750 * 86400 ); @@ -878,7 +878,7 @@ BOOST_AUTO_TEST_CASE( committee_votes_calculation ) { auto com_object = db_api1.get_committee_member_by_account( com_account_ids[i](db).name ); BOOST_REQUIRE( com_object.valid() ); - com_ids.push_back( com_object->id ); + com_ids.push_back( com_object->get_id() ); } generate_blocks( HARDFORK_CORE_2103_TIME - 750 * 86400 );