Skip to content

Commit

Permalink
steemit#3573: Cleanup automated actions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgerbino committed Jan 10, 2020
1 parent cdb6299 commit 4db2f55
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/tests/automated_action_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,30 @@ BOOST_AUTO_TEST_CASE( push_pending_required_actions )
BOOST_REQUIRE_THROW( req_action.validate(), fc::assert_exception );

BOOST_REQUIRE_THROW( db->push_required_action( req_action, db->head_block_time() ), fc::assert_exception );
const auto& idx = db->get_index< pending_required_action_index, by_execution >();

BOOST_TEST_MESSAGE( "--- Success pushing future action" );
req_action.account = STEEM_INIT_MINER_NAME;
req_action.validate();
db->push_required_action( req_action, db->head_block_time() + ( STEEM_BLOCK_INTERVAL * 2 ) );
auto pending_req_action = db->get_index< pending_required_action_index, by_execution >().begin()->action.get< example_required_action >();
auto pending_execution = db->get_index< pending_required_action_index, by_execution> ().begin()->execution_time;
auto itr = idx.begin();
auto pending_req_action = itr->action.get< example_required_action >();
auto pending_execution = itr->execution_time;
BOOST_REQUIRE( pending_req_action == req_action );
BOOST_REQUIRE( pending_execution == db->head_block_time() + ( STEEM_BLOCK_INTERVAL * 2 ) );

BOOST_TEST_MESSAGE( "--- Success pushing past action" );
db->push_required_action( req_action, db->head_block_time() - STEEM_BLOCK_INTERVAL );
pending_req_action = db->get_index< pending_required_action_index, by_execution >().begin()->action.get< example_required_action >();
pending_execution = db->get_index< pending_required_action_index, by_execution> ().begin()->execution_time;
itr = idx.begin();
pending_req_action = itr->action.get< example_required_action >();
pending_execution = itr->execution_time;
BOOST_REQUIRE( pending_req_action == req_action );
BOOST_REQUIRE( pending_execution == db->head_block_time() + STEEM_BLOCK_INTERVAL );

BOOST_TEST_MESSAGE( "--- Success pushing action now" );
req_action.account = STEEM_TEMP_ACCOUNT;
db->push_required_action( req_action, db->head_block_time() );
auto itr = db->get_index< pending_required_action_index, by_execution >().begin();
++itr;
itr = ++idx.begin();
pending_req_action = itr->action.get< example_required_action >();
pending_execution = itr->execution_time;
BOOST_REQUIRE( pending_req_action == req_action );
Expand All @@ -69,28 +71,30 @@ BOOST_AUTO_TEST_CASE( push_pending_optional_actions )
BOOST_REQUIRE_THROW( opt_action.validate(), fc::assert_exception );

BOOST_REQUIRE_THROW( db->push_optional_action( opt_action, db->head_block_time() ), fc::assert_exception );
const auto& idx = db->get_index< pending_optional_action_index, by_execution >();

BOOST_TEST_MESSAGE( "--- Success pushing future action" );
opt_action.account = STEEM_INIT_MINER_NAME;
opt_action.validate();
db->push_optional_action( opt_action, db->head_block_time() + ( STEEM_BLOCK_INTERVAL * 2 ) );
auto pending_opt_action = db->get_index< pending_optional_action_index, by_execution >().begin()->action.get< example_optional_action >();
auto pending_execution = db->get_index< pending_optional_action_index, by_execution> ().begin()->execution_time;
auto itr = idx.begin();
auto pending_opt_action = itr->action.get< example_optional_action >();
auto pending_execution = itr->execution_time;
BOOST_REQUIRE( pending_opt_action.account == opt_action.account );
BOOST_REQUIRE( pending_execution == db->head_block_time() + ( STEEM_BLOCK_INTERVAL * 2 ) );

BOOST_TEST_MESSAGE( "--- Success pushing past action" );
db->push_optional_action( opt_action, db->head_block_time() - STEEM_BLOCK_INTERVAL );
pending_opt_action = db->get_index< pending_optional_action_index, by_execution >().begin()->action.get< example_optional_action >();
pending_execution = db->get_index< pending_optional_action_index, by_execution> ().begin()->execution_time;
itr = idx.begin();
pending_opt_action = itr->action.get< example_optional_action >();
pending_execution = itr->execution_time;
BOOST_REQUIRE( pending_opt_action.account == opt_action.account );
BOOST_REQUIRE( pending_execution == db->head_block_time() + STEEM_BLOCK_INTERVAL );

BOOST_TEST_MESSAGE( "--- Success pushing action now" );
opt_action.account = STEEM_TEMP_ACCOUNT;
db->push_optional_action( opt_action, db->head_block_time() );
auto itr = db->get_index< pending_optional_action_index, by_execution >().begin();
++itr;
itr = ++idx.begin();
pending_opt_action = itr->action.get< example_optional_action >();
pending_execution = itr->execution_time;
BOOST_REQUIRE( pending_opt_action.account == opt_action.account );
Expand Down

0 comments on commit 4db2f55

Please sign in to comment.