update_son_votes tests
This commit is contained in:
parent
f7d64119c2
commit
c52127c2df
1 changed files with 131 additions and 0 deletions
|
|
@ -277,6 +277,7 @@ BOOST_AUTO_TEST_CASE( delete_son )
|
||||||
BOOST_TEST_MESSAGE("SON delete cli wallet tests end");
|
BOOST_TEST_MESSAGE("SON delete cli wallet tests end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
||||||
{
|
{
|
||||||
BOOST_TEST_MESSAGE("SON cli wallet tests begin");
|
BOOST_TEST_MESSAGE("SON cli wallet tests begin");
|
||||||
|
|
@ -1024,6 +1025,136 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
||||||
BOOST_TEST_MESSAGE("SON cli wallet tests end");
|
BOOST_TEST_MESSAGE("SON cli wallet tests end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
|
{
|
||||||
|
BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests begin");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
INVOKE(create_sons);
|
||||||
|
|
||||||
|
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
||||||
|
|
||||||
|
son_object son1_obj;
|
||||||
|
son_object son2_obj;
|
||||||
|
int son1_start_votes, son1_end_votes;
|
||||||
|
int son2_start_votes, son2_end_votes;
|
||||||
|
|
||||||
|
// Get votes at start
|
||||||
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
son1_start_votes = son1_obj.total_votes;
|
||||||
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
son2_start_votes = son2_obj.total_votes;
|
||||||
|
|
||||||
|
std::vector<std::string> accepted;
|
||||||
|
std::vector<std::string> rejected;
|
||||||
|
signed_transaction update_votes_tx;
|
||||||
|
|
||||||
|
// Vote for both SONs
|
||||||
|
accepted.clear();
|
||||||
|
rejected.clear();
|
||||||
|
accepted.push_back("son1account");
|
||||||
|
accepted.push_back("son2account");
|
||||||
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
|
rejected, 15, true);
|
||||||
|
BOOST_CHECK(generate_block());
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
// Verify the votes
|
||||||
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_CHECK(son1_end_votes > son1_start_votes);
|
||||||
|
son1_start_votes = son1_end_votes;
|
||||||
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_CHECK(son2_end_votes > son2_start_votes);
|
||||||
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
|
|
||||||
|
// Withdraw vote for SON 1
|
||||||
|
accepted.clear();
|
||||||
|
rejected.clear();
|
||||||
|
rejected.push_back("son1account");
|
||||||
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
|
rejected, 15, true);
|
||||||
|
BOOST_CHECK(generate_block());
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
// Verify the votes
|
||||||
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_CHECK(son1_end_votes < son1_start_votes);
|
||||||
|
son1_start_votes = son1_end_votes;
|
||||||
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
// voice distribution changed, SON2 now has all voices
|
||||||
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_CHECK(son2_end_votes > son2_start_votes);
|
||||||
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
|
// Try to reject incorrect SON
|
||||||
|
accepted.clear();
|
||||||
|
rejected.clear();
|
||||||
|
rejected.push_back("son1accnt");
|
||||||
|
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
|
rejected, 15, true), fc::exception);
|
||||||
|
BOOST_CHECK(generate_block());
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
// Verify the votes
|
||||||
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_CHECK(son1_end_votes == son1_start_votes);
|
||||||
|
son1_start_votes = son1_end_votes;
|
||||||
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_CHECK(son2_end_votes == son2_start_votes);
|
||||||
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
|
// Reject SON2
|
||||||
|
accepted.clear();
|
||||||
|
rejected.clear();
|
||||||
|
rejected.push_back("son2account");
|
||||||
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
|
rejected, 15, true);
|
||||||
|
BOOST_CHECK(generate_block());
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
// Verify the votes
|
||||||
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_CHECK(son1_end_votes > son1_start_votes);
|
||||||
|
son1_start_votes = son1_end_votes;
|
||||||
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_CHECK(son2_end_votes < son2_start_votes);
|
||||||
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
|
// Try to accept and reject the same SON
|
||||||
|
accepted.clear();
|
||||||
|
rejected.clear();
|
||||||
|
rejected.push_back("son1accnt");
|
||||||
|
accepted.push_back("son1accnt");
|
||||||
|
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
|
rejected, 15, true), fc::exception);
|
||||||
|
BOOST_CHECK(generate_block());
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
// Verify the votes
|
||||||
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_CHECK(son1_end_votes == son1_start_votes);
|
||||||
|
son1_start_votes = son1_end_votes;
|
||||||
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_CHECK(son2_end_votes == son2_start_votes);
|
||||||
|
son2_start_votes = son2_end_votes;
|
||||||
|
} catch( fc::exception& e ) {
|
||||||
|
BOOST_TEST_MESSAGE("SON cli wallet tests exception");
|
||||||
|
edump((e.to_detail_string()));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
BOOST_TEST_MESSAGE("SON Vote cli wallet tests end");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue