Ready : Bug 417 fix for Failing Unit test cases #722
1 changed files with 163 additions and 147 deletions
|
|
@ -215,6 +215,8 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
||||||
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_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Voting for SONs");
|
BOOST_TEST_MESSAGE("Voting for SONs");
|
||||||
|
|
||||||
son_object son1_obj;
|
son_object son1_obj;
|
||||||
|
|
@ -462,6 +464,8 @@ 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_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
|
||||||
|
|
||||||
son_object son1_obj;
|
son_object son1_obj;
|
||||||
|
|
@ -516,6 +520,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
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_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
|
||||||
|
|
@ -560,8 +565,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());
|
||||||
|
|
@ -651,7 +656,7 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
||||||
flat_map<sidechain_type, string> sidechain_public_keys;
|
flat_map<sidechain_type, string> sidechain_public_keys;
|
||||||
|
|
||||||
// create son accounts
|
// create son accounts
|
||||||
for(unsigned int i = 0; i < son_number + 1; i++)
|
for(unsigned int i = 0; i < son_number * 2; i++)
|
||||||
{
|
{
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
sidechain_public_keys[sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
|
||||||
|
|
@ -660,37 +665,48 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
||||||
"http://son" + fc::to_pretty_string(i),
|
"http://son" + fc::to_pretty_string(i),
|
||||||
sidechain_public_keys,
|
sidechain_public_keys,
|
||||||
false);
|
false);
|
||||||
con.wallet_api_ptr->transfer(
|
con.wallet_api_ptr->transfer("nathan", "sonaccount" + fc::to_pretty_string(i),
|
||||||
"nathan", "sonaccount" + fc::to_pretty_string(i), "1000", "1.3.0", "Here are some CORE tokens for your new account", true );
|
"1000", "1.3.0", "Here are some CORE tokens for your new account", true );
|
||||||
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
||||||
}
|
}
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
generate_block();
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("Voting for SONs");
|
BOOST_TEST_MESSAGE("Voting for SONs");
|
||||||
for(unsigned int i = 1; i < son_number + 1; i++)
|
for(unsigned int i = 0; i < son_number * 2; i++)
|
||||||
{
|
{
|
||||||
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
||||||
|
BOOST_TEST_MESSAGE("Account " + name + " votes for SON " + name);
|
||||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, true, true);
|
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, true, true);
|
||||||
}
|
}
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
generate_block();
|
||||||
|
|
||||||
for(unsigned int i = 1; i < son_number; i++)
|
for(unsigned int i = 0; i < son_number; i++)
|
||||||
{
|
{
|
||||||
std::string name1 = "sonaccount" + fc::to_pretty_string(i);
|
std::string name1 = "sonaccount" + fc::to_pretty_string(i);
|
||||||
std::string name2 = "sonaccount" + fc::to_pretty_string(i + 1);
|
std::string name2 = "sonaccount" + fc::to_pretty_string(i + 1);
|
||||||
|
BOOST_TEST_MESSAGE("Account " + name1 + " votes for SON " + name2);
|
||||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, true, true);
|
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, true, true);
|
||||||
}
|
}
|
||||||
|
generate_block();
|
||||||
|
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
gpo = con.wallet_api_ptr->get_global_properties();
|
gpo = con.wallet_api_ptr->get_global_properties();
|
||||||
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size());
|
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size());
|
||||||
|
|
||||||
BOOST_CHECK(gpo.active_sons.size() == son_number);
|
BOOST_CHECK(gpo.active_sons.size() == son_number);
|
||||||
|
|
||||||
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_TEST_MESSAGE("Active SONs:");
|
||||||
|
for (auto s : active_sons) {
|
||||||
|
BOOST_TEST_MESSAGE(" " + s.first);
|
||||||
|
}
|
||||||
|
|
||||||
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 + 1; i++)
|
||||||
{
|
{
|
||||||
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
||||||
|
BOOST_TEST_MESSAGE("Looking for SON name: " + name);
|
||||||
BOOST_CHECK(active_sons.find(name) != active_sons.end());
|
BOOST_CHECK(active_sons.find(name) != active_sons.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue