Skip to content

Commit

Permalink
Merge pull request steemit#2108 from steemit/2048-smt_setup_operation…
Browse files Browse the repository at this point in the history
…-does-not-contain-launch_expiration_time

Extended smt_setup_operation with launch_expiration_time
Michael Vandeberg authored Feb 13, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9b94f61 + 004835b commit 823ba2c
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ class smt_token_object : public object< smt_token_object_type, smt_token_object
time_point_sec generation_begin_time;
time_point_sec generation_end_time;
time_point_sec announced_launch_time;
time_point_sec launch_expiration_time;
};

typedef smt_token_object::id_type smt_token_id_type;
@@ -66,5 +67,6 @@ FC_REFLECT( steem::plugins::smt_test::smt_token_object,
(generation_begin_time)
(generation_end_time)
(announced_launch_time)
(launch_expiration_time)
)
CHAINBASE_SET_INDEX_TYPE( steem::plugins::smt_test::smt_token_object, steem::plugins::smt_test::smt_token_index )
2 changes: 2 additions & 0 deletions libraries/protocol/include/steem/protocol/smt_operations.hpp
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@ struct smt_setup_operation : public base_operation
time_point_sec generation_begin_time;
time_point_sec generation_end_time;
time_point_sec announced_launch_time;
time_point_sec launch_expiration_time;

asset smt_creation_fee;

@@ -287,6 +288,7 @@ FC_REFLECT(
(generation_begin_time)
(generation_end_time)
(announced_launch_time)
(launch_expiration_time)
(smt_creation_fee)
(extensions)
)
1 change: 1 addition & 0 deletions libraries/protocol/smt_operations.cpp
Original file line number Diff line number Diff line change
@@ -210,6 +210,7 @@ void smt_setup_operation::validate()const
FC_ASSERT( generation_begin_time > STEEM_GENESIS_TIME );
FC_ASSERT( generation_end_time > generation_begin_time );
FC_ASSERT( announced_launch_time >= generation_end_time );
FC_ASSERT( launch_expiration_time >= announced_launch_time );

// TODO: Support using STEEM as well
// TODO: Move amount check to evaluator, symbol check should remain here
40 changes: 40 additions & 0 deletions tests/tests/smt_tests.cpp
Original file line number Diff line number Diff line change
@@ -599,6 +599,46 @@ BOOST_AUTO_TEST_CASE( runtime_parameters_apply )
FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_CASE( smt_setup_validate )
{
try
{
smt_setup_operation op;
fc::time_point_sec start_time = fc::variant( "2021-01-01T00:00:00" ).as< fc::time_point_sec >();
fc::time_point_sec start_time_plus_1 = start_time + fc::seconds(1);
// Do minimal operation setup that allows successful validatation.
{
smt_capped_generation_policy gpolicy;
uint64_t max_supply = STEEM_MAX_SHARE_SUPPLY / 6000;
// set steem unit, total is 100 STEEM-satoshis = 0.1 STEEM
gpolicy.pre_soft_cap_unit.steem_unit.emplace( "founder", 100 );
// set token unit, total is 5 token-satoshis = 0.0005 SMT
gpolicy.pre_soft_cap_unit.token_unit.emplace( "$from", 5 );
// Note - no soft cap -> no soft cap unit
gpolicy.min_steem_units_commitment.fillin_nonhidden_value( 1 );
gpolicy.hard_cap_steem_units_commitment.fillin_nonhidden_value( max_supply );
gpolicy.soft_cap_percent = STEEM_100_PERCENT;

// Note that neither tested SMT nor even its creator is necessary to validate this operation.
op.control_account = "alice";
op.decimal_places = 4;
op.initial_generation_policy = gpolicy;
op.generation_begin_time = start_time;
op.generation_end_time = op.announced_launch_time = op.launch_expiration_time = start_time_plus_1;
op.smt_creation_fee = asset( 1000000, SBD_SYMBOL );
}

op.validate();
// TODO put other negative scenarios here.

// Launch expiration time can't be earlier than announced launch time.
op.launch_expiration_time = start_time;
STEEM_REQUIRE_THROW( op.validate(), fc::assert_exception );
op.launch_expiration_time = start_time_plus_1; // Restored valid value.
}
FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_CASE( smt_transfer_validate )
{
try

0 comments on commit 823ba2c

Please sign in to comment.