#328 - Fix SON tests
This commit is contained in:
parent
9c73357d97
commit
645fb32fc5
1 changed files with 131 additions and 49 deletions
|
|
@ -238,6 +238,9 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|||
flat_map<sidechain_type, uint64_t> son1_start_votes, son1_end_votes;
|
||||
flat_map<sidechain_type, uint64_t> son2_start_votes, son2_end_votes;
|
||||
|
||||
//! Get nathan account
|
||||
const auto nathan_account_object = con.wallet_api_ptr->get_account("nathan");
|
||||
|
||||
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");
|
||||
|
|
@ -268,34 +271,31 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] > son2_start_votes[sidechain_type::bitcoin]);
|
||||
BOOST_CHECK(son2_end_votes[sidechain_type::hive] > son2_start_votes[sidechain_type::hive]);
|
||||
|
||||
//! Get nathan account
|
||||
const auto nathan_account_object = con.wallet_api_ptr->get_account("nathan");
|
||||
|
||||
//! Check son1account voters
|
||||
auto voters_for_son1account = con.wallet_api_ptr->get_voters("son1account");
|
||||
BOOST_REQUIRE(voters_for_son1account.voters_for_son);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account.voters_for_son->at(sidechain_type::bitcoin).voters[0].instance, nathan_account_object.id.instance());
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::hive).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account.voters_for_son->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
|
||||
auto voters_for_son1account = con.wallet_api_ptr->get_voters("son1account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son1account);
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son1account->at(sidechain_type::bitcoin).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account->at(sidechain_type::bitcoin).voters[0].instance, nathan_account_object.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son1account->at(sidechain_type::hive).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
|
||||
|
||||
//! Check son2account voters
|
||||
auto voters_for_son2account = con.wallet_api_ptr->get_voters("son2account");
|
||||
BOOST_REQUIRE(voters_for_son2account.voters_for_son);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account.voters_for_son->at(sidechain_type::bitcoin).voters[0].instance, nathan_account_object.id.instance());
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::hive).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account.voters_for_son->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
|
||||
auto voters_for_son2account = con.wallet_api_ptr->get_voters("son2account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son2account);
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son2account->at(sidechain_type::bitcoin).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account->at(sidechain_type::bitcoin).voters[0].instance, nathan_account_object.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son2account->at(sidechain_type::hive).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
|
||||
|
||||
//! Check votes of nathan
|
||||
auto nathan_votes = con.wallet_api_ptr->get_votes("nathan");
|
||||
BOOST_REQUIRE(nathan_votes.votes_for_sons);
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).size(), 2);
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).at(0).id.instance(), son1_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).at(1).id.instance(), son2_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::hive).size(), 2);
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::hive).at(0).id.instance(), son1_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::hive).at(1).id.instance(), son2_obj.id.instance());
|
||||
auto nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(nathan_votes_for_son);
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).size(), 2);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(0).id.instance(), son1_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(1).id.instance(), son2_obj.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).size(), 2);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(0).id.instance(), son1_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(1).id.instance(), son2_obj.id.instance());
|
||||
|
||||
// Withdraw vote for a son1account
|
||||
BOOST_TEST_MESSAGE("Withdraw vote for a son1account");
|
||||
|
|
@ -310,18 +310,18 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|||
BOOST_CHECK(son1_end_votes[sidechain_type::hive] == son1_start_votes[sidechain_type::hive]);
|
||||
|
||||
//! Check son1account voters
|
||||
voters_for_son1account = con.wallet_api_ptr->get_voters("son1account");
|
||||
BOOST_REQUIRE(voters_for_son1account.voters_for_son);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 0);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::hive).voters.size(), 0);
|
||||
voters_for_son1account = con.wallet_api_ptr->get_voters("son1account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son1account);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account->at(sidechain_type::bitcoin).voters.size(), 0);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account->at(sidechain_type::hive).voters.size(), 0);
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes = con.wallet_api_ptr->get_votes("nathan");
|
||||
BOOST_REQUIRE(nathan_votes.votes_for_sons);
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).at(0).id.instance(), son2_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::hive).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::hive).at(0).id.instance(), son2_obj.id.instance());
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(nathan_votes_for_son);
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(0).id.instance(), son2_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(0).id.instance(), son2_obj.id.instance());
|
||||
|
||||
// Withdraw vote for a son2account
|
||||
BOOST_TEST_MESSAGE("Withdraw vote for a son2account");
|
||||
|
|
@ -336,14 +336,14 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::hive] == son2_start_votes[sidechain_type::hive]);
|
||||
|
||||
//! Check son2account voters
|
||||
voters_for_son2account = con.wallet_api_ptr->get_voters("son2account");
|
||||
BOOST_REQUIRE(voters_for_son2account.voters_for_son);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 0);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::hive).voters.size(), 0);
|
||||
voters_for_son2account = con.wallet_api_ptr->get_voters("son2account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son2account);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account->at(sidechain_type::bitcoin).voters.size(), 0);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account->at(sidechain_type::hive).voters.size(), 0);
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes = con.wallet_api_ptr->get_votes("nathan");
|
||||
BOOST_CHECK(!nathan_votes.votes_for_sons.valid());
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_CHECK(!nathan_votes_for_son);
|
||||
|
||||
} catch( fc::exception& e ) {
|
||||
BOOST_TEST_MESSAGE("SON cli wallet tests exception");
|
||||
|
|
@ -358,7 +358,6 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
|||
BOOST_TEST_MESSAGE("SON cli wallet tests begin");
|
||||
try
|
||||
{
|
||||
const sidechain_type type = sidechain_type::bitcoin;
|
||||
son_test_helper sth(*this);
|
||||
|
||||
graphene::wallet::brain_key_info bki;
|
||||
|
|
@ -396,7 +395,8 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
|||
con.wallet_api_ptr->create_vesting_balance("sonaccount" + fc::to_pretty_string(i), "500", "1.3.0", vesting_balance_type::gpos, true);
|
||||
|
||||
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, type, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, sidechain_type::bitcoin, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, sidechain_type::hive, true, true);
|
||||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
|
|
@ -404,7 +404,8 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
|||
{
|
||||
std::string name1 = "sonaccount" + fc::to_pretty_string(i);
|
||||
std::string name2 = "sonaccount" + fc::to_pretty_string(i + 1);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, type, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::bitcoin, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::hive, true, true);
|
||||
}
|
||||
gpo = con.wallet_api_ptr->get_global_properties();
|
||||
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size());
|
||||
|
|
@ -416,7 +417,8 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
|||
{
|
||||
std::string name1 = "sonaccount" + fc::to_pretty_string(i + 2);
|
||||
std::string name2 = "sonaccount" + fc::to_pretty_string(i);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, type, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::bitcoin, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::hive, true, true);
|
||||
}
|
||||
gpo = con.wallet_api_ptr->get_global_properties();
|
||||
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size());
|
||||
|
|
@ -428,7 +430,8 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
|
|||
{
|
||||
std::string name1 = "sonaccount" + fc::to_pretty_string(i + 3);
|
||||
std::string name2 = "sonaccount" + fc::to_pretty_string(i);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, type, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::bitcoin, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::hive, true, true);
|
||||
}
|
||||
gpo = con.wallet_api_ptr->get_global_properties();
|
||||
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size());
|
||||
|
|
@ -502,6 +505,9 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
flat_map<sidechain_type, uint64_t> son1_start_votes, son1_end_votes;
|
||||
flat_map<sidechain_type, uint64_t> son2_start_votes, son2_end_votes;
|
||||
|
||||
//! Get nathan account
|
||||
const auto nathan_account_object = con.wallet_api_ptr->get_account("nathan");
|
||||
|
||||
// Get votes at start
|
||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||
son1_start_votes = son1_obj.total_votes;
|
||||
|
|
@ -520,6 +526,8 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::bitcoin, 2, true);
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::hive, 2, true);
|
||||
generate_block();
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
|
|
@ -533,6 +541,31 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] > son2_start_votes[sidechain_type::bitcoin]);
|
||||
son2_start_votes = son2_end_votes;
|
||||
|
||||
//! Check son1account voters
|
||||
auto voters_for_son1account = con.wallet_api_ptr->get_voters("son1account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son1account);
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son1account->at(sidechain_type::bitcoin).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account->at(sidechain_type::bitcoin).voters[0].instance, nathan_account_object.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son1account->at(sidechain_type::hive).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
|
||||
|
||||
//! Check son2account voters
|
||||
auto voters_for_son2account = con.wallet_api_ptr->get_voters("son2account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son2account);
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son2account->at(sidechain_type::bitcoin).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account->at(sidechain_type::bitcoin).voters[0].instance, nathan_account_object.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(voters_for_son2account->at(sidechain_type::hive).voters.size(), 1);
|
||||
BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
|
||||
|
||||
//! Check votes of nathan
|
||||
auto nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(nathan_votes_for_son);
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).size(), 2);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(0).id.instance(), son1_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(1).id.instance(), son2_obj.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).size(), 2);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(0).id.instance(), son1_obj.id.instance());
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(1).id.instance(), son2_obj.id.instance());
|
||||
|
||||
// Withdraw vote for SON 1
|
||||
accepted.clear();
|
||||
|
|
@ -541,6 +574,8 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::bitcoin, 1, true);
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::hive, 1, true);
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
// Verify the votes
|
||||
|
|
@ -554,12 +589,28 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] > son2_start_votes[sidechain_type::bitcoin]); // nathan spent funds for vb, it has different voting power
|
||||
son2_start_votes = son2_end_votes;
|
||||
|
||||
//! Check son1account voters
|
||||
voters_for_son1account = con.wallet_api_ptr->get_voters("son1account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son1account);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account->at(sidechain_type::bitcoin).voters.size(), 0);
|
||||
BOOST_CHECK_EQUAL(voters_for_son1account->at(sidechain_type::hive).voters.size(), 0);
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(nathan_votes_for_son);
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(0).id.instance(), son2_obj.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(0).id.instance(), son2_obj.id.instance());
|
||||
|
||||
// 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,
|
||||
sidechain_type::bitcoin, 1, true), fc::exception);
|
||||
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::hive, 1, true), fc::exception);
|
||||
generate_block();
|
||||
|
||||
// Verify the votes
|
||||
|
|
@ -572,12 +623,22 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] == son2_start_votes[sidechain_type::bitcoin]);
|
||||
son2_start_votes = son2_end_votes;
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(nathan_votes_for_son);
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::bitcoin).at(0).id.instance(), son2_obj.id.instance());
|
||||
BOOST_REQUIRE_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).size(), 1);
|
||||
BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(0).id.instance(), son2_obj.id.instance());
|
||||
|
||||
// Reject SON2
|
||||
accepted.clear();
|
||||
rejected.clear();
|
||||
rejected.push_back("son2account");
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::bitcoin, 0, true);
|
||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::hive, 0, true);
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
// Verify the votes
|
||||
|
|
@ -590,6 +651,16 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] < son2_start_votes[sidechain_type::bitcoin]);
|
||||
son2_start_votes = son2_end_votes;
|
||||
|
||||
//! Check son2account voters
|
||||
voters_for_son2account = con.wallet_api_ptr->get_voters("son2account").voters_for_son;
|
||||
BOOST_REQUIRE(voters_for_son2account);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account->at(sidechain_type::bitcoin).voters.size(), 0);
|
||||
BOOST_CHECK_EQUAL(voters_for_son2account->at(sidechain_type::hive).voters.size(), 0);
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(!nathan_votes_for_son);
|
||||
|
||||
// Try to accept and reject the same SON
|
||||
accepted.clear();
|
||||
rejected.clear();
|
||||
|
|
@ -597,6 +668,8 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
accepted.push_back("son1accnt");
|
||||
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::bitcoin, 1, true), fc::exception);
|
||||
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
|
||||
sidechain_type::hive, 1, true), fc::exception);
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
// Verify the votes
|
||||
|
|
@ -609,6 +682,10 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] == son2_start_votes[sidechain_type::bitcoin]);
|
||||
son2_start_votes = son2_end_votes;
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(!nathan_votes_for_son);
|
||||
|
||||
// Try to accept and reject empty lists
|
||||
accepted.clear();
|
||||
rejected.clear();
|
||||
|
|
@ -626,6 +703,10 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|||
BOOST_CHECK(son2_end_votes[sidechain_type::bitcoin] == son2_start_votes[sidechain_type::bitcoin]);
|
||||
son2_start_votes = son2_end_votes;
|
||||
|
||||
//! Check votes of nathan
|
||||
nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
|
||||
BOOST_REQUIRE(!nathan_votes_for_son);
|
||||
|
||||
} catch( fc::exception& e ) {
|
||||
BOOST_TEST_MESSAGE("SON cli wallet tests exception");
|
||||
edump((e.to_detail_string()));
|
||||
|
|
@ -672,7 +753,6 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
BOOST_TEST_MESSAGE("SON cli wallet tests for list_active_sons begin");
|
||||
try
|
||||
{
|
||||
const sidechain_type type = sidechain_type::bitcoin;
|
||||
son_test_helper sth(*this);
|
||||
|
||||
signed_transaction vote_tx;
|
||||
|
|
@ -703,7 +783,8 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
for(unsigned int i = 1; i < son_number + 1; i++)
|
||||
{
|
||||
std::string name = "sonaccount" + fc::to_pretty_string(i);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, type, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, sidechain_type::bitcoin, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name, name, sidechain_type::hive, true, true);
|
||||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
|
|
@ -711,7 +792,8 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
{
|
||||
std::string name1 = "sonaccount" + fc::to_pretty_string(i);
|
||||
std::string name2 = "sonaccount" + fc::to_pretty_string(i + 1);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, type, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::bitcoin, true, true);
|
||||
vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, sidechain_type::hive, true, true);
|
||||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
gpo = con.wallet_api_ptr->get_global_properties();
|
||||
|
|
@ -741,7 +823,6 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
|||
BOOST_TEST_MESSAGE("SON maintenance cli wallet tests begin");
|
||||
try
|
||||
{
|
||||
const sidechain_type type = sidechain_type::bitcoin;
|
||||
son_test_helper sth(*this);
|
||||
|
||||
std::string name("sonaccount1");
|
||||
|
|
@ -771,7 +852,8 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
|||
con.wallet_api_ptr->transfer(
|
||||
"nathan", "sonaccount" + fc::to_pretty_string(i), "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->vote_for_son("sonaccount" + fc::to_pretty_string(i), name, type, true, true);
|
||||
con.wallet_api_ptr->vote_for_son("sonaccount" + fc::to_pretty_string(i), name, sidechain_type::bitcoin, true, true);
|
||||
con.wallet_api_ptr->vote_for_son("sonaccount" + fc::to_pretty_string(i), name, sidechain_type::hive, true, true);
|
||||
}
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue