do not allow update votes with both empty lists

This commit is contained in:
gladcow 2019-10-31 21:09:12 +03:00
parent 0bbe7f63c7
commit 2502207561
2 changed files with 18 additions and 0 deletions

View file

@ -2272,6 +2272,7 @@ public:
uint16_t desired_number_of_sons,
bool broadcast /* = false */)
{ try {
FC_ASSERT(sons_to_approve.size() || sons_to_reject.size(), "Both accepted and rejected lists can't be empty simultaneously");
account_object voting_account_object = get_account(voting_account);
for (const std::string& son : sons_to_approve)
{

View file

@ -481,6 +481,23 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
BOOST_CHECK(son2_end_votes == son2_start_votes);
son2_start_votes = son2_end_votes;
// Try to accept and reject empty lists
accepted.clear();
rejected.clear();
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
rejected, 15, true), fc::exception);
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()));