From 9fc07f191fdad91ce695060f1c1ca0c1ec5239a9 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 12 Sep 2019 19:13:36 +0530 Subject: [PATCH] Fixed test failures and compilation issue --- libraries/chain/db_block.cpp | 6 +++--- libraries/chain/db_init.cpp | 2 +- tests/tests/affiliate_tests.cpp | 25 ++++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index b8bc7c25..da978a16 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -729,9 +729,9 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx ptrx.operation_results = std::move(eval_state.operation_results); //Make sure the temp account has no non-zero balances - const auto& index = get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >(); - auto range = index.equal_range( boost::make_tuple( GRAPHENE_TEMP_ACCOUNT ) ); - std::for_each(range.first, range.second, [](const account_balance_object& b) { FC_ASSERT(b.balance == 0); }); + const auto& balances = get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( GRAPHENE_TEMP_ACCOUNT ); + for( const auto b : balances ) + FC_ASSERT(b.second->balance == 0); return ptrx; } FC_CAPTURE_AND_RETHROW( (trx) ) } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 9db7a9b0..5e972df8 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -295,7 +295,7 @@ void database::initialize_indexes() add_index< primary_index >(); add_index< primary_index> >(); add_index< primary_index> >(); - add_index< primary_index >(); // 1 Mi + add_index< primary_index> >(); add_index< primary_index> >(); add_index< primary_index> >(); add_index< primary_index > >(); diff --git a/tests/tests/affiliate_tests.cpp b/tests/tests/affiliate_tests.cpp index 51fa3cac..72482a0a 100644 --- a/tests/tests/affiliate_tests.cpp +++ b/tests/tests/affiliate_tests.cpp @@ -401,20 +401,19 @@ BOOST_AUTO_TEST_CASE( affiliate_payout_helper_test ) } { - // // Fix total supply - // //auto& index = db.get_index_type().indices().get(); - // auto& index = db.get_index_type< primary_index< account_balance_index, 8 > >().get_secondary_index< direct_index< account_balance_object, 8> >(); - // auto itr = index.find( boost::make_tuple( account_id_type(), asset_id_type() ) ); - // BOOST_CHECK( itr != nullptr ); - // db.modify( *itr, [&ath]( account_balance_object& bal ) { - // bal.balance -= ath.alice_ppy + ath.ann_ppy + ath.audrey_ppy; - // }); + // Fix total supply + auto& index = db.get_index_type< primary_index< account_balance_index > >().get_secondary_index(); + auto abo = index.get_account_balance( account_id_type(), asset_id_type() ); + BOOST_CHECK( abo != nullptr ); + db.modify( *abo, [&ath]( account_balance_object& bal ) { + bal.balance -= ath.alice_ppy + ath.ann_ppy + ath.audrey_ppy; + }); - // itr = index.find( boost::make_tuple( irene_id, btc_id ) ); - // BOOST_CHECK( itr != nullptr ); - // db.modify( *itr, [alice_btc,ann_btc,audrey_btc]( account_balance_object& bal ) { - // bal.balance -= alice_btc + ann_btc + audrey_btc; - // }); + abo = index.get_account_balance( irene_id, btc_id ); + BOOST_CHECK( abo != nullptr ); + db.modify( *abo, [alice_btc,ann_btc,audrey_btc]( account_balance_object& bal ) { + bal.balance -= alice_btc + ann_btc + audrey_btc; + }); } }