Skip to content

Commit

Permalink
Merge pull request steemit#3594 from steemit/3592-smt-reset-ico-tier
Browse files Browse the repository at this point in the history
Prevent SMT reset when ICO tiers exists
  • Loading branch information
Michael Vandeberg authored Feb 10, 2020
2 parents 27e397c + 3b30d96 commit 8b49220
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions libraries/chain/smt_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
25 changes: 25 additions & 0 deletions tests/tests/smt_operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8b49220

Please sign in to comment.