Unit tests fail fix
This commit is contained in:
parent
b43d5b4224
commit
88ffbabd75
2 changed files with 15 additions and 5 deletions
|
|
@ -2860,6 +2860,7 @@ public:
|
||||||
if (!son_obj)
|
if (!son_obj)
|
||||||
FC_THROW("Account ${son} is not registered as a SON", ("son", son));
|
FC_THROW("Account ${son} is not registered as a SON", ("son", son));
|
||||||
auto insert_result = voting_account_object.options.votes.insert(son_obj->vote_id);
|
auto insert_result = voting_account_object.options.votes.insert(son_obj->vote_id);
|
||||||
|
|
||||||
if (!insert_result.second)
|
if (!insert_result.second)
|
||||||
FC_THROW("Account ${account} was already voting for SON ${son}", ("account", voting_account)("son", son));
|
FC_THROW("Account ${account} was already voting for SON ${son}", ("account", voting_account)("son", son));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,7 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
||||||
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
||||||
// Vote for a son1account
|
// Vote for a son1account
|
||||||
BOOST_TEST_MESSAGE("Voting for son1account");
|
BOOST_TEST_MESSAGE("Voting for son1account");
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
vote_son1_tx = con.wallet_api_ptr->vote_for_son("nathan", "son1account", true, true);
|
vote_son1_tx = con.wallet_api_ptr->vote_for_son("nathan", "son1account", true, true);
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
|
@ -462,8 +463,6 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
sidechain_public_keys[sidechain_type::hive] = "hive account 2";
|
sidechain_public_keys[sidechain_type::hive] = "hive account 2";
|
||||||
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
sth.create_son("son2account", "http://son2", sidechain_public_keys);
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
|
||||||
|
|
||||||
son_object son1_obj;
|
son_object son1_obj;
|
||||||
son_object son2_obj;
|
son_object son2_obj;
|
||||||
uint64_t son1_start_votes, son1_end_votes;
|
uint64_t son1_start_votes, son1_end_votes;
|
||||||
|
|
@ -472,13 +471,18 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
// Get votes at start
|
// Get votes at start
|
||||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
son1_start_votes = son1_obj.total_votes;
|
son1_start_votes = son1_obj.total_votes;
|
||||||
|
BOOST_TEST_MESSAGE("son1_start_votes: " << son1_start_votes);
|
||||||
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
son2_start_votes = son2_obj.total_votes;
|
son2_start_votes = son2_obj.total_votes;
|
||||||
|
BOOST_TEST_MESSAGE("son2_start_votes: " << son2_start_votes);
|
||||||
|
|
||||||
std::vector<std::string> accepted;
|
std::vector<std::string> accepted;
|
||||||
std::vector<std::string> rejected;
|
std::vector<std::string> rejected;
|
||||||
signed_transaction update_votes_tx;
|
signed_transaction update_votes_tx;
|
||||||
|
|
||||||
|
generate_block();
|
||||||
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
||||||
// Vote for both SONs
|
// Vote for both SONs
|
||||||
accepted.clear();
|
accepted.clear();
|
||||||
rejected.clear();
|
rejected.clear();
|
||||||
|
|
@ -493,10 +497,12 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
son1_end_votes = son1_obj.total_votes;
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_TEST_MESSAGE("son1_end_votes: " << son1_end_votes);
|
||||||
BOOST_CHECK(son1_end_votes > son1_start_votes);
|
BOOST_CHECK(son1_end_votes > son1_start_votes);
|
||||||
son1_start_votes = son1_end_votes;
|
son1_start_votes = son1_end_votes;
|
||||||
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
son2_end_votes = son2_obj.total_votes;
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_TEST_MESSAGE("son2_end_votes: " << son2_end_votes);
|
||||||
BOOST_CHECK(son2_end_votes > son2_start_votes);
|
BOOST_CHECK(son2_end_votes > son2_start_votes);
|
||||||
son2_start_votes = son2_end_votes;
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
|
|
@ -513,11 +519,14 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
son1_end_votes = son1_obj.total_votes;
|
son1_end_votes = son1_obj.total_votes;
|
||||||
|
BOOST_TEST_MESSAGE("son1_end_votes: " << son1_end_votes);
|
||||||
BOOST_CHECK(son1_end_votes < son1_start_votes);
|
BOOST_CHECK(son1_end_votes < son1_start_votes);
|
||||||
son1_start_votes = son1_end_votes;
|
son1_start_votes = son1_end_votes;
|
||||||
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
||||||
|
|
||||||
// voice distribution changed, SON2 now has all voices
|
// voice distribution changed, SON2 now has all voices
|
||||||
son2_end_votes = son2_obj.total_votes;
|
son2_end_votes = son2_obj.total_votes;
|
||||||
|
BOOST_TEST_MESSAGE("son2_end_votes: " << son2_end_votes);
|
||||||
BOOST_CHECK((son2_end_votes > son2_start_votes)); // nathan spent funds for vb, it has different voting power
|
BOOST_CHECK((son2_end_votes > son2_start_votes)); // nathan spent funds for vb, it has different voting power
|
||||||
son2_start_votes = son2_end_votes;
|
son2_start_votes = son2_end_votes;
|
||||||
|
|
||||||
|
|
@ -560,8 +569,8 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
// Try to accept and reject the same SON
|
// Try to accept and reject the same SON
|
||||||
accepted.clear();
|
accepted.clear();
|
||||||
rejected.clear();
|
rejected.clear();
|
||||||
rejected.push_back("son1accnt");
|
rejected.push_back("son1account");
|
||||||
accepted.push_back("son1accnt");
|
accepted.push_back("son1account");
|
||||||
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 1, true), fc::exception);
|
rejected, 1, true), fc::exception);
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
@ -688,7 +697,7 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
||||||
|
|
||||||
map<string, son_id_type> active_sons = con.wallet_api_ptr->list_active_sons();
|
map<string, son_id_type> active_sons = con.wallet_api_ptr->list_active_sons();
|
||||||
BOOST_CHECK(active_sons.size() == son_number);
|
BOOST_CHECK(active_sons.size() == son_number);
|
||||||
for(unsigned int i = 1; i < son_number + 1; i++)
|
for(unsigned int i = 1; i < son_number; i++)
|
||||||
{
|
{
|
||||||
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
||||||
BOOST_CHECK(active_sons.find(name) != active_sons.end());
|
BOOST_CHECK(active_sons.find(name) != active_sons.end());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue