Commit 96254ae5 authored by Howo's avatar Howo Committed by Bartek Wrona

Supplemented FC_REFLECT for sps_convert_operation.

New virtual operation mooved to last one in protocol::operation definition for better compatibility to 3rd party libs like hive-js, beem.
parent 7f24f988
......@@ -4685,7 +4685,15 @@ void database::update_virtual_supply()
{
uint16_t percent_hbd = 0;
if( has_hardfork( HIVE_HARDFORK_0_21 ) )
if( has_hardfork( HIVE_HARDFORK_0_24 ) )
{
// Removing the hbd in the treasury from the debt ratio calculations
const auto &treasury_account = get_treasury();
const auto hdb_supply_without_treasury = (dgp.get_current_hbd_supply() - treasury_account.hbd_balance).amount < 0 ? asset(0, HBD_SYMBOL) : (dgp.get_current_hbd_supply() - treasury_account.hbd_balance) ;
const auto virtual_supply_without_treasury = hdb_supply_without_treasury * get_feed_history().current_median_history + dgp.current_supply;
percent_hbd = uint16_t( ( ( fc::uint128_t( ( hdb_supply_without_treasury * get_feed_history().current_median_history ).amount.value ) * HIVE_100_PERCENT + virtual_supply_without_treasury.amount.value/2 )
/ virtual_supply_without_treasury.amount.value ).to_uint64() );
} else if( has_hardfork( HIVE_HARDFORK_0_21 ) )
{
percent_hbd = uint16_t( ( ( fc::uint128_t( ( dgp.get_current_hbd_supply() * get_feed_history().current_median_history ).amount.value ) * HIVE_100_PERCENT + dgp.virtual_supply.amount.value/2 )
/ dgp.virtual_supply.amount.value ).to_uint64() );
......
......@@ -1175,11 +1175,25 @@ void escrow_release_evaluator::do_apply( const escrow_release_operation& o )
void transfer_evaluator::do_apply( const transfer_operation& o )
{
FC_TODO( "Remove is producing after HF 21" );
if( _db.is_producing() || _db.has_hardfork( HIVE_HARDFORK_0_21__3343 ) )
if ( _db.has_hardfork(HIVE_HARDFORK_0_24) && o.amount.symbol == HIVE_SYMBOL && _db.is_treasury( o.to ) ) {
const auto &fhistory = _db.get_feed_history();
FC_ASSERT(!fhistory.current_median_history.is_null(), "Cannot send HIVE to ${s} because there is no price feed.", ("s", o.to ));
auto amount_to_transfer = o.amount * fhistory.current_median_history;
_db.adjust_balance(o.from, -o.amount);
_db.adjust_balance(o.to, amount_to_transfer);
_db.adjust_supply(-o.amount);
if (amount_to_transfer.amount > 0)
_db.adjust_supply(amount_to_transfer);
return;
} else if( _db.has_hardfork( HIVE_HARDFORK_0_21__3343 ) )
{
FC_ASSERT( o.amount.symbol == HBD_SYMBOL || !_db.is_treasury( o.to ),
"Can only transfer HBD to ${s}", ("s", o.to ) );
FC_ASSERT( o.amount.symbol == HBD_SYMBOL || !_db.is_treasury( o.to ), "Can only transfer HBD or HIVE to ${s}", ("s", o.to ) );
}
_db.adjust_balance( o.from, -o.amount );
......
......@@ -155,9 +155,11 @@ namespace hive { namespace chain {
uint16_t hbd_stop_percent = HIVE_HBD_STOP_PERCENT_HF14;
uint16_t hbd_start_percent = HIVE_HBD_START_PERCENT_HF14;
//settings used to compute payments for every proposal
// Settings used to compute payments for every proposal
time_point_sec next_maintenance_time = HIVE_GENESIS_TIME;
time_point_sec last_budget_time = HIVE_GENESIS_TIME;
// Setting to convert hive to HBD in the treasury account
time_point_sec next_daily_maintenance_time = HIVE_GENESIS_TIME;
uint16_t content_reward_percent = HIVE_CONTENT_REWARD_PERCENT_HF16;
uint16_t vesting_reward_percent = HIVE_VESTING_FUND_PERCENT_HF16;
......@@ -226,6 +228,7 @@ FC_REFLECT( hive::chain::dynamic_global_property_object,
(hbd_start_percent)
(next_maintenance_time)
(last_budget_time)
(next_daily_maintenance_time)
(content_reward_percent)
(vesting_reward_percent)
(sps_fund_percent)
......
......@@ -2,6 +2,7 @@
#include <hive/chain/hive_fwd.hpp>
#include <hive/chain/hive_object_types.hpp>
#include <hive/chain/hive_objects.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <hive/protocol/asset.hpp>
......
......@@ -30,6 +30,7 @@ class sps_processor
chain::database& db;
bool is_maintenance_period( const time_point_sec& head_time ) const;
bool is_daily_maintenance_period( const time_point_sec& head_time ) const;
void remove_proposals( const time_point_sec& head_time );
......@@ -56,6 +57,7 @@ class sps_processor
void make_payments( const block_notification& note );
void record_funding( const block_notification& note );
void convert_funds( const block_notification& note );
public:
......
#include <hive/protocol/authority.hpp>
#include <hive/chain/database.hpp>
#include <hive/chain/util/impacted.hpp>
#include <fc/utility.hpp>
......@@ -327,6 +328,11 @@ struct get_impacted_account_visitor
_impacted.insert( op.account );
}
void operator()( const sps_convert_operation& op )
{
_impacted.insert( op.fund_account );
}
//void operator()( const operation& op ){}
};
......
......@@ -26,6 +26,11 @@ bool sps_processor::is_maintenance_period( const time_point_sec& head_time ) con
return db.get_dynamic_global_properties().next_maintenance_time <= head_time;
}
bool sps_processor::is_daily_maintenance_period( const time_point_sec& head_time ) const
{
return db.get_dynamic_global_properties().next_daily_maintenance_time <= head_time;
}
void sps_processor::remove_proposals( const time_point_sec& head_time )
{
FC_TODO("implement proposal removal based on automatic actions")
......@@ -307,6 +312,7 @@ void sps_processor::run( const block_notification& note )
{
remove_old_proposals( note );
record_funding( note );
convert_funds( note );
make_payments( note );
}
......@@ -329,4 +335,40 @@ void sps_processor::record_funding( const block_notification& note )
});
}
void sps_processor::convert_funds( const block_notification& note )
{
if( !is_daily_maintenance_period( note.block.timestamp ) )
return;
db.modify( db.get_dynamic_global_properties(), [&]( dynamic_global_property_object& _dgpo )
{
_dgpo.next_daily_maintenance_time = note.block.timestamp + fc::seconds( HIVE_DAILY_PROPOSAL_MAINTENANCE_PERIOD );
} );
const auto &treasury_account = db.get_treasury();
if (treasury_account.balance.amount == 0) {
return;
}
const auto to_convert = asset(HIVE_PROPOSAL_CONVERSION_RATE * treasury_account.balance.amount / HIVE_100_PERCENT, HIVE_SYMBOL);
const feed_history_object& fhistory = db.get_feed_history();
if( fhistory.current_median_history.is_null() )
return;
auto converted_hbd = to_convert * fhistory.current_median_history;
// Don't convert if the conversion would result in an amount lower than the dust threshold
if(converted_hbd < HIVE_MIN_PAYOUT_HBD )
return;
db.adjust_balance( treasury_account, -to_convert );
db.adjust_balance(treasury_account, converted_hbd );
db.adjust_supply( -to_convert );
db.adjust_supply( converted_hbd );
operation vop = sps_convert_operation(treasury_account.name, to_convert, converted_hbd );
db.push_virtual_operation( vop );
}
} } // namespace hive::chain
......@@ -391,6 +391,7 @@ struct extended_dynamic_global_properties
hbd_start_percent( o.hbd_start_percent ),
next_maintenance_time( o.next_maintenance_time ),
last_budget_time( o.last_budget_time ),
next_daily_maintenance_time( o.next_daily_maintenance_time ),
content_reward_percent( o.content_reward_percent ),
vesting_reward_percent( o.vesting_reward_percent ),
sps_fund_percent( o.sps_fund_percent ),
......@@ -442,6 +443,8 @@ struct extended_dynamic_global_properties
time_point_sec next_maintenance_time;
time_point_sec last_budget_time;
time_point_sec next_daily_maintenance_time;
uint16_t content_reward_percent = HIVE_CONTENT_REWARD_PERCENT_HF16;
uint16_t vesting_reward_percent = HIVE_VESTING_FUND_PERCENT_HF16;
uint16_t sps_fund_percent = HIVE_PROPOSAL_FUND_PERCENT_HF0;
......@@ -1236,7 +1239,7 @@ FC_REFLECT( hive::plugins::condenser_api::extended_dynamic_global_properties,
(hbd_interest_rate)(hbd_print_rate)
(maximum_block_size)(required_actions_partition_percent)(current_aslot)(recent_slots_filled)(participation_count)(last_irreversible_block_num)
(vote_power_reserve_rate)(delegation_return_period)(reverse_auction_seconds)(available_account_subsidies)(hbd_stop_percent)(hbd_start_percent)
(next_maintenance_time)(last_budget_time)(content_reward_percent)(vesting_reward_percent)(sps_fund_percent)(sps_interval_ledger)(downvote_pool_percent)
(next_maintenance_time)(last_budget_time)(next_daily_maintenance_time)(content_reward_percent)(vesting_reward_percent)(sps_fund_percent)(sps_interval_ledger)(downvote_pool_percent)
)
FC_REFLECT( hive::plugins::condenser_api::api_witness_object,
......
......@@ -226,6 +226,7 @@ struct api_dynamic_global_property_object
hbd_start_percent( o.hbd_start_percent ),
next_maintenance_time( o.next_maintenance_time ),
last_budget_time( o.last_budget_time ),
next_daily_maintenance_time( o.next_daily_maintenance_time ),
content_reward_percent( o.content_reward_percent ),
vesting_reward_percent( o.vesting_reward_percent ),
sps_fund_percent( o.sps_fund_percent ),
......@@ -271,6 +272,7 @@ struct api_dynamic_global_property_object
uint16_t hbd_start_percent;
time_point_sec next_maintenance_time;
time_point_sec last_budget_time;
time_point_sec next_daily_maintenance_time;
uint16_t content_reward_percent;
uint16_t vesting_reward_percent;
uint16_t sps_fund_percent;
......@@ -1056,7 +1058,7 @@ FC_REFLECT( hive::plugins::database_api::api_dynamic_global_property_object,
(current_aslot)(recent_slots_filled)(participation_count)(last_irreversible_block_num)
(vote_power_reserve_rate)(delegation_return_period)(reverse_auction_seconds)
(available_account_subsidies)(hbd_stop_percent)(hbd_start_percent)(next_maintenance_time)
(last_budget_time)(content_reward_percent)(vesting_reward_percent)(sps_fund_percent)
(last_budget_time)(next_daily_maintenance_time)(content_reward_percent)(vesting_reward_percent)(sps_fund_percent)
(sps_interval_ledger)(downvote_pool_percent)
#ifdef HIVE_ENABLE_SMT
(smt_creation_fee)
......
......@@ -406,6 +406,7 @@ struct count_operation_visitor
void operator()( const delayed_voting_operation& ) const {}
void operator()( const proposal_pay_operation& ) const {}
void operator()( const sps_fund_operation& ) const {}
void operator()( const sps_convert_operation& ) const {}
void operator()( const hardfork_hive_operation& ) const {}
void operator()( const hardfork_hive_restore_operation& ) const {}
......
......@@ -43,6 +43,10 @@
/// Allows to limit number of total produced blocks.
#define TESTNET_BLOCK_LIMIT (3000000)
#define HIVE_PROPOSAL_MAINTENANCE_PERIOD 3600
#define HIVE_PROPOSAL_MAINTENANCE_CLEANUP (60*60*24*1) // 1 day
#define HIVE_DAILY_PROPOSAL_MAINTENANCE_PERIOD (60*60) /// 1 hour
#else // IS LIVE HIVE NETWORK
#define HIVE_BLOCKCHAIN_VERSION ( version(0, 24, 0) )
......@@ -74,6 +78,10 @@
#define HIVE_INIT_SUPPLY int64_t(0)
#define HIVE_HBD_INIT_SUPPLY int64_t(0)
#define HIVE_PROPOSAL_MAINTENANCE_PERIOD 3600
#define HIVE_PROPOSAL_MAINTENANCE_CLEANUP (60*60*24*1) /// 1 day
#define HIVE_DAILY_PROPOSAL_MAINTENANCE_PERIOD HIVE_ONE_DAY_SECONDS
#endif
#define VESTS_SYMBOL (hive::protocol::asset_symbol_type::from_asset_num( HIVE_ASSET_NUM_VESTS ) )
......@@ -84,6 +92,7 @@
#define HIVE_100_PERCENT 10000
#define HIVE_1_PERCENT (HIVE_100_PERCENT/100)
#define HIVE_1_BASIS_POINT (HIVE_100_PERCENT/10000) // 0.01%
#define HIVE_BLOCK_INTERVAL 3
#define HIVE_BLOCKS_PER_YEAR (365*24*60*60/HIVE_BLOCK_INTERVAL)
......@@ -354,14 +363,13 @@
/// HIVE PROPOSAL SYSTEM support
#define HIVE_TREASURY_FEE (10 * HIVE_BLOCKCHAIN_PRECISION)
#define HIVE_PROPOSAL_MAINTENANCE_PERIOD 3600
#define HIVE_PROPOSAL_MAINTENANCE_CLEANUP (60*60*24*1) /// 1 day
#define HIVE_PROPOSAL_SUBJECT_MAX_LENGTH 80
/// Max number of IDs passed at once to the update_proposal_voter_operation or remove_proposal_operation.
#define HIVE_PROPOSAL_MAX_IDS_NUMBER 5
#define HIVE_PROPOSAL_FEE_INCREASE_DAYS 60
#define HIVE_PROPOSAL_FEE_INCREASE_DAYS_SEC (60*60*24*HIVE_PROPOSAL_FEE_INCREASE_DAYS) /// 60 days
#define HIVE_PROPOSAL_FEE_INCREASE_AMOUNT (1 * HIVE_BLOCKCHAIN_PRECISION)
#define HIVE_PROPOSAL_CONVERSION_RATE (5 * HIVE_1_BASIS_POINT)
#ifdef HIVE_ENABLE_SMT
......
......@@ -238,6 +238,16 @@ namespace hive { namespace protocol {
asset additional_funds;
};
struct sps_convert_operation : public virtual_operation
{
sps_convert_operation() {}
sps_convert_operation(account_name_type f, const asset& c, const asset& a) : fund_account(f), hive_amount_in( c ), hbd_amount_out( a ) {}
account_name_type fund_account;
asset hive_amount_in;
asset hbd_amount_out;
};
// TODO : Fix legacy error itr != to_full_tag.end(): Invalid operation name: hardfork_hive {"n":"hardfork_hive"}
struct hardfork_hive_operation : public virtual_operation
{
......@@ -290,5 +300,6 @@ FC_REFLECT( hive::protocol::clear_null_account_balance_operation, (total_cleared
FC_REFLECT( hive::protocol::consolidate_treasury_balance_operation, ( total_moved ) )
FC_REFLECT( hive::protocol::delayed_voting_operation, (voter)(votes) )
FC_REFLECT( hive::protocol::sps_fund_operation, (fund_account)(additional_funds) )
FC_REFLECT( hive::protocol::sps_convert_operation, (fund_account)(hive_amount_in)(hbd_amount_out) )
FC_REFLECT( hive::protocol::hardfork_hive_operation, (account)(treasury)(hbd_transferred)(hive_transferred)(vests_converted)(total_hive_from_vests) )
FC_REFLECT( hive::protocol::hardfork_hive_restore_operation, (account)(treasury)(hbd_transferred)(hive_transferred) )
......@@ -108,7 +108,8 @@ namespace hive { namespace protocol {
delayed_voting_operation,
consolidate_treasury_balance_operation,
effective_comment_vote_operation,
ineffective_delete_comment_operation
ineffective_delete_comment_operation,
sps_convert_operation
> operation;
/*void operation_get_required_authorities( const operation& op,
......
......@@ -230,6 +230,7 @@ add_boost_test( chain_test
proposal_tests/proposals_removing_with_threshold
proposal_tests/proposals_removing_with_threshold_01
proposal_tests/proposals_removing_with_threshold_02
proposal_tests/converting_hive_to_dhf
serialization_tests/serialization_raw_test
serialization_tests/serialization_json_test
serialization_tests/legacy_asset_test
......
......@@ -1085,6 +1085,18 @@ uint64_t sps_proposal_database_fixture::get_nr_blocks_until_maintenance_block()
return ret;
}
uint64_t sps_proposal_database_fixture::get_nr_blocks_until_daily_maintenance_block()
{
auto block_time = db->head_block_time();
auto next_maintenance_time = db->get_dynamic_global_properties().next_daily_maintenance_time;
auto ret = ( next_maintenance_time - block_time ).to_seconds() / HIVE_BLOCK_INTERVAL;
FC_ASSERT( next_maintenance_time >= block_time );
return ret;
}
void sps_proposal_database_fixture::post_comment( std::string _authro, std::string _permlink, std::string _title, std::string _body, std::string _parent_permlink, const fc::ecc::private_key& _key)
{
generate_blocks( db->head_block_time() + HIVE_MIN_ROOT_COMMENT_INTERVAL + fc::seconds( HIVE_BLOCK_INTERVAL ), true );
......
......@@ -374,6 +374,7 @@ struct sps_proposal_database_fixture : public virtual clean_database_fixture
bool find_vote_for_proposal(const std::string& _user, int64_t _proposal_id);
uint64_t get_nr_blocks_until_maintenance_block();
uint64_t get_nr_blocks_until_daily_maintenance_block();
void post_comment( std::string _authro, std::string _permlink, std::string _title, std::string _body, std::string _parent_permlink, const fc::ecc::private_key& _key);
......
......@@ -50,24 +50,6 @@ BOOST_AUTO_TEST_CASE( blocked_operations )
signed_transaction tx;
tx.set_expiration( db->head_block_time() + HIVE_MAX_TIME_UNTIL_EXPIRATION );
//check transfer of non-HBD
{
transfer_operation op;
op.from = "alice";
op.to = OBSOLETE_TREASURY_ACCOUNT;
op.amount = ASSET( "1.000 TESTS" );
tx.operations.push_back( op );
sign( tx, alice_private_key );
BOOST_REQUIRE_THROW( db->push_transaction( tx, 0 ), fc::assert_exception ); //still blocked even though old is no longer active treasury
tx.clear();
op.to = NEW_HIVE_TREASURY_ACCOUNT;
tx.operations.push_back( op );
sign( tx, alice_private_key );
BOOST_REQUIRE_THROW( db->push_transaction( tx, 0 ), fc::assert_exception ); //blocked for new treasury as well
}
tx.clear();
//check vesting of non-HBD
{
transfer_to_vesting_operation op;
......@@ -312,6 +294,31 @@ BOOST_AUTO_TEST_CASE( consolidate_balance )
FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_CASE( treasury_debt_ratio )
{
try
{
ACTORS((alice))
BOOST_TEST_MESSAGE( "After HF24 funds in the treasury don't count towards the HBD debt ratio" );
set_price_feed( price( ASSET( "1.000 TBD" ), ASSET( "10.000 TESTS" ) ) );
generate_block();
auto& dgpo = db->get_dynamic_global_properties();
const auto before_hbd_print_rate = dgpo.hbd_print_rate;
FUND("alice", ASSET( "1000000.000 TBD" ));
const auto during_hbd_print_rate = dgpo.hbd_print_rate;
transfer( "alice", db->get_treasury_name(), asset( 1000000000, HBD_SYMBOL ) );
generate_block();
const auto after_hbd_print_rate = dgpo.hbd_print_rate;
BOOST_REQUIRE( after_hbd_print_rate == before_hbd_print_rate );
BOOST_REQUIRE( after_hbd_print_rate != during_hbd_print_rate );
database_fixture::validate_database();
}
FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_SUITE_END()
#endif
......@@ -1442,22 +1442,25 @@ BOOST_AUTO_TEST_CASE( transfer_apply )
BOOST_REQUIRE( new_bob.get_balance().amount.value == ASSET( "10.000 TESTS" ).amount.value );
validate_database();
BOOST_TEST_MESSAGE( "--- Test failure transfering HIVE to treasury" );
BOOST_TEST_MESSAGE( "--- Test successfully transfering HIVE to treasury and converting it to HBD" );
set_price_feed( price( ASSET( "1.000 TBD" ), ASSET( "1.000 TESTS" ) ) );
generate_block();
auto treasury_hbd_balance = db->get_treasury().get_hbd_balance();
op.from = "bob";
op.to = db->get_treasury_name();
op.amount = ASSET( "1.000 TESTS" );
tx.set_expiration( db->head_block_time() + HIVE_MAX_TIME_UNTIL_EXPIRATION );
tx.signatures.clear();
tx.operations.clear();
tx.operations.push_back( op );
sign( tx, bob_private_key );
HIVE_REQUIRE_THROW( db->push_transaction( tx ), fc::exception );
BOOST_REQUIRE( get_balance( "bob" ) == ASSET( "10.000 TESTS" ) );
BOOST_REQUIRE( db->get_treasury().get_balance() == ASSET( "0.000 TESTS" ) );
db->push_transaction( tx );
BOOST_REQUIRE( get_balance( "bob" ) == ASSET( "9.000 TESTS" ) );
BOOST_REQUIRE( db->get_treasury().get_hbd_balance() == treasury_hbd_balance + ASSET( "1.000 TBD" ) );
validate_database();
BOOST_TEST_MESSAGE( "--- Test transfering HBD to treasury" );
auto treasury_hbd_balance = db->get_treasury().get_hbd_balance();
treasury_hbd_balance = db->get_treasury().get_hbd_balance();
op.amount = ASSET( "1.000 TBD" );
tx.signatures.clear();
tx.operations.clear();
......
......@@ -3241,4 +3241,47 @@ BOOST_AUTO_TEST_CASE( generating_payments )
FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_CASE( converting_hive_to_dhf )
{
try
{
BOOST_TEST_MESSAGE( "Testing: converting hive to hbd in the dhf" );
const auto& dgpo = db->get_dynamic_global_properties();
const account_object& _treasury = db->get_treasury();
set_price_feed( price( ASSET( "1.000 TBD" ), ASSET( "1.000 TESTS" ) ) );
auto before_inflation_treasury_hbd_balance = _treasury.get_hbd_balance();
generate_block();
auto treasury_per_block_inflation = _treasury.get_hbd_balance() - before_inflation_treasury_hbd_balance;
FUND( db->get_treasury_name(), ASSET( "100.000 TESTS" ) );
generate_block();
auto before_treasury_hbd_balance = _treasury.get_hbd_balance();
auto before_treasury_hive_balance = _treasury.get_balance();
const auto hive_converted = asset(HIVE_PROPOSAL_CONVERSION_RATE * before_treasury_hive_balance.amount / HIVE_100_PERCENT, HIVE_SYMBOL);
// Same because of the 1:1 tests to tbd ratio
const auto hbd_converted = asset(hive_converted.amount, HBD_SYMBOL);
// Generate until the next daily maintenance
auto next_block = get_nr_blocks_until_daily_maintenance_block();
auto before_daily_maintenance_time = dgpo.next_daily_maintenance_time;
generate_blocks( next_block - 1);
auto treasury_hbd_inflation = _treasury.get_hbd_balance() - before_treasury_hbd_balance;
generate_block();
treasury_hbd_inflation += treasury_per_block_inflation;
auto after_daily_maintenance_time = dgpo.next_daily_maintenance_time;
auto after_treasury_hbd_balance = _treasury.get_hbd_balance();
auto after_treasury_hive_balance = _treasury.get_balance();
BOOST_REQUIRE( before_treasury_hbd_balance == after_treasury_hbd_balance - treasury_hbd_inflation - hbd_converted );
BOOST_REQUIRE( before_treasury_hive_balance == after_treasury_hive_balance + hive_converted );
BOOST_REQUIRE( before_daily_maintenance_time == after_daily_maintenance_time - fc::seconds( HIVE_DAILY_PROPOSAL_MAINTENANCE_PERIOD ) );
validate_database();
}
FC_LOG_AND_RETHROW()
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -3077,6 +3077,8 @@ BOOST_AUTO_TEST_CASE( smt_transfer_apply )
BOOST_REQUIRE( db->get_balance( "alice", symbol ) == asset( 5000, symbol ) );
BOOST_REQUIRE( db->get_balance( "bob", symbol ) == asset( 5000, symbol ) );
tx.signatures.clear();
tx.operations.clear();
validate_database();
BOOST_TEST_MESSAGE( "--- Generating a block" );
......@@ -3086,7 +3088,28 @@ BOOST_AUTO_TEST_CASE( smt_transfer_apply )
BOOST_REQUIRE( db->get_balance( "bob", symbol ) == asset( 5000, symbol ) );
validate_database();
BOOST_TEST_MESSAGE( "--- Test transfer to old treasury account" );
op.to = OBSOLETE_TREASURY_ACCOUNT;
tx.operations.push_back( op );
tx.set_expiration( db->head_block_time() + HIVE_MAX_TIME_UNTIL_EXPIRATION );
sign( tx, alice_private_key );
BOOST_REQUIRE_THROW( db->push_transaction( tx, 0 ), fc::assert_exception ); //still blocked even though old is no longer active treasury
tx.signatures.clear();
tx.operations.clear();
validate_database();
BOOST_TEST_MESSAGE( "--- Test transfer to new treasury account" );
op.to = NEW_HIVE_TREASURY_ACCOUNT;
tx.operations.push_back( op );
tx.set_expiration( db->head_block_time() + HIVE_MAX_TIME_UNTIL_EXPIRATION );
sign( tx, alice_private_key );
BOOST_REQUIRE_THROW( db->push_transaction( tx, 0 ), fc::assert_exception );
tx.signatures.clear();
tx.operations.clear();
validate_database();
BOOST_TEST_MESSAGE( "--- Test emptying an account" );
op.to = "bob";
tx.signatures.clear();
tx.operations.clear();
tx.operations.push_back( op );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment