Merge branch 'master' of github.com:cryptonomex/graphene
This commit is contained in:
commit
5d5604f673
4 changed files with 50 additions and 7 deletions
|
|
@ -78,15 +78,12 @@ void account_statistics_object::process_fees(const account_object& a, database&
|
|||
|
||||
auto pay_out_fees = [&](const account_object& account, share_type core_fee_total, bool require_vesting)
|
||||
{
|
||||
// Check the referrer and registrar -- if they're no longer members, pay up to the lifetime member instead.
|
||||
// Check the referrer -- if he's no longer a member, pay to the lifetime referrer instead.
|
||||
// No need to check the registrar; registrars are required to be lifetime members.
|
||||
if( account.referrer(d).is_basic_account(d.head_block_time()) )
|
||||
d.modify(account, [](account_object& a) {
|
||||
a.referrer = a.lifetime_referrer;
|
||||
});
|
||||
if( account.registrar(d).is_basic_account(d.head_block_time()) )
|
||||
d.modify(account, [](account_object& a) {
|
||||
a.registrar = a.lifetime_referrer;
|
||||
});
|
||||
|
||||
share_type network_cut = cut_fee(core_fee_total, account.network_fee_percentage);
|
||||
assert( network_cut <= core_fee_total );
|
||||
|
|
|
|||
|
|
@ -306,8 +306,6 @@ signed_block database::_generate_block(
|
|||
if( !(skip & skip_delegate_signature) ) _pending_block.sign( block_signing_private_key );
|
||||
|
||||
FC_ASSERT( fc::raw::pack_size(_pending_block) <= get_global_properties().parameters.maximum_block_size );
|
||||
//This line used to std::move(_pending_block) but this is unsafe as _pending_block is later referenced without being
|
||||
//reinitialized. Future optimization could be to move it, then reinitialize it with the values we need to preserve.
|
||||
signed_block tmp = _pending_block;
|
||||
tmp.transaction_merkle_root = tmp.calculate_merkle_root();
|
||||
_pending_block.transactions.clear();
|
||||
|
|
|
|||
|
|
@ -130,4 +130,45 @@ BOOST_AUTO_TEST_CASE( cashback_test )
|
|||
BOOST_CHECK_EQUAL(stud_id(db).cashback_balance(db).balance.amount.value, 25750);
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bulk_discount)
|
||||
{ try {
|
||||
ACTOR(nathan);
|
||||
// Give nathan ALLLLLL the money!
|
||||
transfer(GRAPHENE_COMMITTEE_ACCOUNT, nathan_id, db.get_balance(GRAPHENE_COMMITTEE_ACCOUNT, asset_id_type()));
|
||||
enable_fees(GRAPHENE_BLOCKCHAIN_PRECISION*10);
|
||||
upgrade_to_lifetime_member(nathan_id);
|
||||
share_type new_fees;
|
||||
while( nathan_id(db).statistics(db).lifetime_fees_paid + new_fees < GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN )
|
||||
{
|
||||
transfer(nathan_id, GRAPHENE_COMMITTEE_ACCOUNT, asset(1));
|
||||
new_fees += transfer_operation().calculate_fee(db.current_fee_schedule());
|
||||
}
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
enable_fees(GRAPHENE_BLOCKCHAIN_PRECISION*10);
|
||||
auto old_cashback = nathan_id(db).cashback_balance(db).balance;
|
||||
|
||||
transfer(nathan_id, GRAPHENE_COMMITTEE_ACCOUNT, asset(1));
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
enable_fees(GRAPHENE_BLOCKCHAIN_PRECISION*10);
|
||||
|
||||
BOOST_CHECK_EQUAL(nathan_id(db).cashback_balance(db).balance.amount.value,
|
||||
old_cashback.amount.value + GRAPHENE_BLOCKCHAIN_PRECISION * 8);
|
||||
|
||||
new_fees = 0;
|
||||
while( nathan_id(db).statistics(db).lifetime_fees_paid + new_fees < GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX )
|
||||
{
|
||||
transfer(nathan_id, GRAPHENE_COMMITTEE_ACCOUNT, asset(1));
|
||||
new_fees += transfer_operation().calculate_fee(db.current_fee_schedule());
|
||||
}
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
enable_fees(GRAPHENE_BLOCKCHAIN_PRECISION*10);
|
||||
old_cashback = nathan_id(db).cashback_balance(db).balance;
|
||||
|
||||
transfer(nathan_id, GRAPHENE_COMMITTEE_ACCOUNT, asset(1));
|
||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||
|
||||
BOOST_CHECK_EQUAL(nathan_id(db).cashback_balance(db).balance.amount.value,
|
||||
old_cashback.amount.value + GRAPHENE_BLOCKCHAIN_PRECISION * 9);
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
|
|
@ -133,6 +133,9 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia )
|
|||
trx.operations.back() = op;
|
||||
//Fail because nathan is blacklisted
|
||||
BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception);
|
||||
trx.operations = {asset_burn_operation{asset(), nathan.id, advanced.amount(10)}};
|
||||
//Fail because nathan is blacklisted
|
||||
BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception);
|
||||
std::swap(op.from, op.to);
|
||||
trx.operations.back() = op;
|
||||
//Fail because nathan is blacklisted
|
||||
|
|
@ -181,6 +184,10 @@ BOOST_AUTO_TEST_CASE( transfer_whitelist_uia )
|
|||
//Fail because nathan is not whitelisted
|
||||
BOOST_CHECK(!nathan.is_authorized_asset(advanced));
|
||||
BOOST_REQUIRE_THROW(PUSH_TX( db, trx, ~0 ), fc::exception);
|
||||
|
||||
trx.operations = {asset_burn_operation{asset(), dan.id, advanced.amount(10)}};
|
||||
PUSH_TX(db, trx, ~0);
|
||||
BOOST_CHECK_EQUAL(get_balance(dan, advanced), 40);
|
||||
} catch(fc::exception& e) {
|
||||
edump((e.to_detail_string()));
|
||||
throw;
|
||||
|
|
|
|||
Loading…
Reference in a new issue