From 9070c31892d9c51074cb531c6934bd9bec5f0a93 Mon Sep 17 00:00:00 2001 From: Martin Lees Date: Tue, 25 Feb 2020 01:02:21 +0100 Subject: [PATCH] Checks for emission to null or steem.dao --- libraries/protocol/smt_operations.cpp | 10 ++++++++++ tests/tests/smt_operation_tests.cpp | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/protocol/smt_operations.cpp b/libraries/protocol/smt_operations.cpp index 644bf8c1cd..0589882292 100644 --- a/libraries/protocol/smt_operations.cpp +++ b/libraries/protocol/smt_operations.cpp @@ -193,6 +193,16 @@ void smt_setup_emissions_operation::validate()const FC_ASSERT( lep_abs_amount > 0 || lep_rel_amount_numerator > 0 || rep_abs_amount > 0 || rep_rel_amount_numerator > 0, "An emission operation must have positive non-zero emission" ); + for ( const auto& e : emissions_unit.token_unit ) + { + if ( smt::unit_target::is_account_name_type( e.first ) ) + { + std::string name = smt::unit_target::get_unit_target_account( e.first ); + FC_ASSERT( name != STEEM_TREASURY_ACCOUNT, "Invalid emission destination, cannot emit to the treasury account ${a}", ("a", STEEM_TREASURY_ACCOUNT) ); + FC_ASSERT( name != STEEM_NULL_ACCOUNT, "Invalid emission destination, cannot emit to ${a}", ("a", STEEM_NULL_ACCOUNT) ); + } + } + // rel_amount_denom_bits <- any value of unsigned int is OK } diff --git a/tests/tests/smt_operation_tests.cpp b/tests/tests/smt_operation_tests.cpp index b1ac2664c0..b5349f5b02 100644 --- a/tests/tests/smt_operation_tests.cpp +++ b/tests/tests/smt_operation_tests.cpp @@ -1,6 +1,5 @@ #include -#if defined IS_TEST_NET #include @@ -2137,6 +2136,15 @@ BOOST_AUTO_TEST_CASE( smt_setup_emissions_validate ) op.emissions_unit.token_unit[ "@@@@" ] = 10; STEEM_REQUIRE_THROW( op.validate(), fc::exception ); op.emissions_unit.token_unit.clear(); + + BOOST_TEST_MESSAGE( " -- Invalid emission unit token unit account is the treasury account" ); + op.emissions_unit.token_unit[ STEEM_TREASURY_ACCOUNT ] = 10; + STEEM_REQUIRE_THROW( op.validate(), fc::exception ); + op.emissions_unit.token_unit.clear(); + BOOST_TEST_MESSAGE( " -- Invalid emission unit token unit account is the null account" ); + op.emissions_unit.token_unit[ STEEM_NULL_ACCOUNT ] = 10; + STEEM_REQUIRE_THROW( op.validate(), fc::exception ); + op.emissions_unit.token_unit.clear(); op.emissions_unit.token_unit[ SMT_DESTINATION_REWARDS ] = 1; op.emissions_unit.token_unit[ SMT_DESTINATION_MARKET_MAKER ] = 1; op.emissions_unit.token_unit[ SMT_DESTINATION_VESTING ] = 1; @@ -5179,4 +5187,3 @@ BOOST_AUTO_TEST_CASE( smt_setup_ico_tier_apply ) } BOOST_AUTO_TEST_SUITE_END() -#endif