diff --git a/libraries/chain/smt_evaluator.cpp b/libraries/chain/smt_evaluator.cpp index 2f215bbf84..dd8c875e26 100644 --- a/libraries/chain/smt_evaluator.cpp +++ b/libraries/chain/smt_evaluator.cpp @@ -100,6 +100,7 @@ void smt_create_evaluator::do_apply( const smt_create_operation& o ) FC_ASSERT( token_ptr->control_account == o.control_account, "You do not control this SMT. Control Account: ${a}", ("a", token_ptr->control_account) ); FC_ASSERT( token_ptr->phase == smt_phase::setup, "SMT cannot be reset if setup is completed. Phase: ${p}", ("p", token_ptr->phase) ); FC_ASSERT( !util::smt::last_emission_time( _db, token_ptr->liquid_symbol ), "Cannot reset an SMT that has existing token emissions." ); + FC_ASSERT( util::smt::ico::ico_tier_size(_db, token_ptr->liquid_symbol ) == 0, "Cannot reset an SMT that has existing ICO tiers." ); _db.remove( *token_ptr ); } diff --git a/tests/tests/smt_operation_tests.cpp b/tests/tests/smt_operation_tests.cpp index 5109d04c6c..b7efb08c0d 100644 --- a/tests/tests/smt_operation_tests.cpp +++ b/tests/tests/smt_operation_tests.cpp @@ -1949,10 +1949,21 @@ BOOST_AUTO_TEST_CASE( smt_create_reset ) op4.control_account = "alice"; op4.symbol = alice_symbol; + smt_capped_generation_policy valid_capped_generation_policy; + valid_capped_generation_policy.generation_unit.steem_unit[ "alice" ] = 2; + valid_capped_generation_policy.generation_unit.token_unit[ "alice" ] = 2; + + smt_setup_ico_tier_operation op5; + op5.control_account = "alice"; + op5.steem_units_cap = 100000; + op5.generation_policy = valid_capped_generation_policy; + op5.symbol = alice_symbol; + tx.operations.push_back( op1 ); tx.operations.push_back( op2 ); tx.operations.push_back( op3 ); tx.operations.push_back( op4 ); + tx.operations.push_back( op5 ); tx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION ); sign( tx, alice_private_key ); db->push_transaction( tx, 0 ); @@ -1992,6 +2003,20 @@ BOOST_AUTO_TEST_CASE( smt_create_reset ) sign( tx, alice_private_key ); db->push_transaction( tx, 0 ); + BOOST_TEST_MESSAGE( "--- Failure resetting SMT" ); + op.smt_creation_fee = ASSET( "0.000 TBD" ); + tx.clear(); + tx.operations.push_back( op ); + sign( tx, alice_private_key ); + STEEM_REQUIRE_THROW( db->push_transaction( tx, 0 ), fc::assert_exception ); + + BOOST_TEST_MESSAGE( "--- Success deleting ICO tier" ); + op5.remove = true; + tx.clear(); + tx.operations.push_back( op5 ); + sign( tx, alice_private_key ); + db->push_transaction( tx, 0 ); + BOOST_TEST_MESSAGE( "--- Success resetting SMT" ); op.smt_creation_fee = ASSET( "0.000 TBD" ); tx.clear();