Skip to content

Commit

Permalink
Allows accounts to cancel a power down when they control less than 10…
Browse files Browse the repository at this point in the history
…x the account creation fee of VESTS #562
  • Loading branch information
Michael Vandeberg committed Nov 23, 2016
1 parent 61167d2 commit f10d0bd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions libraries/chain/hardfork.d/0_16.hf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef STEEMIT_HARDFORK_0_16
#define STEEMIT_HARDFORK_0_16 16
#define STEEMIT_HARDFORK_0_16__551 (STEEMIT_HARDFORK_0_16)
#define STEEMIT_HARDFORK_0_16__562 (STEEMIT_HARDFORK_0_16)

#define STEEMIT_HARDFORK_0_16_TIME 1481040000 // Tue, 6 Dec 2016 16:00:00 UTC (11:00:00 EST)

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ void withdraw_vesting_evaluator::do_apply( const withdraw_vesting_operation& o )
asset min_vests = wso.median_props.account_creation_fee * props.get_vesting_share_price();
min_vests.amount.value *= 10;

FC_ASSERT( account.vesting_shares > min_vests,
FC_ASSERT( account.vesting_shares > min_vests || ( db().has_hardfork( STEEMIT_HARDFORK_0_16__562 ) && o.vesting_shares.amount == 0 ),
"Account registered by another account requires 10x account creation fee worth of Steem Power before it can be powered down." );
}

Expand Down
39 changes: 39 additions & 0 deletions tests/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,46 @@ BOOST_AUTO_TEST_CASE( withdraw_vesting_apply )
BOOST_REQUIRE( alice.vesting_withdraw_rate.amount.value == 0 );
BOOST_REQUIRE( alice.to_withdraw.value == 0 );
BOOST_REQUIRE( alice.next_vesting_withdrawal == fc::time_point_sec::maximum() );


BOOST_TEST_MESSAGE( "--- Test cancelling a withdraw when below the account creation fee" );
op.vesting_shares = alice.vesting_shares;
tx.clear();
tx.operations.push_back( op );
tx.sign( alice_private_key, db.get_chain_id() );
db.push_transaction( tx, 0 );
generate_block();
}

db_plugin->debug_update( [=]( database& db )
{
auto& wso = db.get_witness_schedule_object();

db.modify( wso, [&]( witness_schedule_object& w )
{
w.median_props.account_creation_fee = ASSET( "10.000 TESTS" );
});

db.modify( db.get_dynamic_global_properties(), [&]( dynamic_global_property_object& gpo )
{
gpo.current_supply += wso.median_props.account_creation_fee - ASSET( "0.001 TESTS" ) - gpo.total_vesting_fund_steem;
gpo.total_vesting_fund_steem = wso.median_props.account_creation_fee - ASSET( "0.001 TESTS" );
});

db.update_virtual_supply();
}, database::skip_witness_signature );

withdraw_vesting_operation op;
signed_transaction tx;
op.account = "alice";
op.vesting_shares = ASSET( "0.000000 VESTS" );
tx.operations.push_back( op );
tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION );
tx.sign( alice_private_key, db.get_chain_id() );
db.push_transaction( tx, 0 );

BOOST_REQUIRE( db.get_account( "alice" ).vesting_withdraw_rate == ASSET( "0.000000 VESTS" ) );
validate_database();
}
FC_LOG_AND_RETHROW()
}
Expand Down

0 comments on commit f10d0bd

Please sign in to comment.