From 9e150df60521dd9468749eaefd5896c7ed3ce292 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 9 Jul 2015 15:55:10 -0400 Subject: [PATCH] Fix withdraw_witness_pay test --- libraries/chain/db_balance.cpp | 2 +- libraries/chain/include/graphene/chain/config.hpp | 2 ++ tests/tests/operation_tests.cpp | 13 +++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/chain/db_balance.cpp b/libraries/chain/db_balance.cpp index 9fab9fb3..90e00d65 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 ) }); } else { if( delta.amount < 0 ) - FC_ASSERT( itr->get_balance() >= -delta, "Insufficient Balance: ${b} is less than required ${r}", ("b",to_pretty_string(itr->get_balance()))("r",to_pretty_string(-delta))); + FC_ASSERT( itr->get_balance() >= -delta, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", ("a",account(*this).name)("b",to_pretty_string(itr->get_balance()))("r",to_pretty_string(-delta))); modify(*itr, [delta](account_balance_object& b) { b.adjust_balance(delta); }); diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 188d5018..de9bf592 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -50,6 +50,8 @@ #define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block #define GRAPHENE_MIN_TRANSACTION_EXPIRATION_LIMIT (GRAPHENE_MAX_BLOCK_INTERVAL * 5) // 5 transactions per block #define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) +#define CORE GRAPHENE_BLOCKCHAIN_PRECISION + #define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 #define GRAPHENE_DEFAULT_TRANSFER_FEE (1*GRAPHENE_BLOCKCHAIN_PRECISION) #define GRAPHENE_MAX_INSTANCE_ID (uint64_t(-1)>>16) diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 204efc6a..20ab55b3 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1112,7 +1112,8 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) // Make an account and upgrade it to prime, so that witnesses get some pay create_account("nathan", delegate_pub_key); - transfer(account_id_type()(db), get_account("nathan"), asset(10000000000)); + transfer(account_id_type()(db), get_account("nathan"), asset(20000*CORE)); + transfer(account_id_type()(db), get_account("init3"), asset(20*CORE)); generate_block(); const asset_object* core = &asset_id_type()(db); @@ -1153,7 +1154,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) trx.sign(delegate_priv_key); db.push_transaction(trx); trx.clear(); - BOOST_CHECK_EQUAL(get_balance(*nathan, *core), 8950000000); + BOOST_CHECK_EQUAL(get_balance(*nathan, *core), 20000*CORE - account_upgrade_operation::fee_parameters_type().membership_lifetime_fee );; generate_block(); nathan = &get_account("nathan"); @@ -1184,9 +1185,9 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) schedule_maint(); // The 80% lifetime referral fee went to the committee account, which burned it. Check that it's here. - BOOST_CHECK_EQUAL( core->reserved(db).value, 840000000 ); + BOOST_CHECK_EQUAL( core->reserved(db).value, 8000*CORE ); generate_block(); - BOOST_CHECK_EQUAL( core->reserved(db).value, 840000000 + 210000000 - ref_budget ); + BOOST_CHECK_EQUAL( core->reserved(db).value, 999999406 ); BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget ); witness = &db.fetch_block_by_number(db.head_block_num())->witness(db); // first witness paid from old budget (so no pay) @@ -1230,8 +1231,8 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) db.push_transaction(trx, database::skip_authority_check); trx.clear(); - BOOST_CHECK_EQUAL(get_balance(witness->witness_account(db), *core), witness_ppb - 1/*fee*/); - BOOST_CHECK_EQUAL(core->reserved(db).value, 840000000 + 210000000 - ref_budget ); + BOOST_CHECK_EQUAL(get_balance(witness->witness_account(db), *core), witness_ppb ); + BOOST_CHECK_EQUAL(core->reserved(db).value, 999999406 ); BOOST_CHECK_EQUAL(witness->accumulated_income.value, 0); } FC_LOG_AND_RETHROW() }