|
|
|
|
@ -138,10 +138,18 @@ BOOST_AUTO_TEST_CASE( create_sons )
|
|
|
|
|
auto son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
BOOST_CHECK(son1_obj.son_account == con.wallet_api_ptr->get_account_id("son1account"));
|
|
|
|
|
BOOST_CHECK_EQUAL(son1_obj.url, "http://son1");
|
|
|
|
|
BOOST_CHECK_EQUAL(son1_obj.sidechain_public_keys[sidechain_type::bitcoin], "bitcoin_address 1");
|
|
|
|
|
BOOST_CHECK_EQUAL(son1_obj.sidechain_public_keys[sidechain_type::hive], "hive account 1");
|
|
|
|
|
BOOST_CHECK_EQUAL(son1_obj.get_sidechain_vote_id(sidechain_type::bitcoin).instance(), 22);
|
|
|
|
|
BOOST_CHECK_EQUAL(son1_obj.get_sidechain_vote_id(sidechain_type::hive).instance(), 23);
|
|
|
|
|
|
|
|
|
|
auto son2_obj = con.wallet_api_ptr->get_son("son2account");
|
|
|
|
|
BOOST_CHECK(son2_obj.son_account == con.wallet_api_ptr->get_account_id("son2account"));
|
|
|
|
|
BOOST_CHECK_EQUAL(son2_obj.url, "http://son2");
|
|
|
|
|
BOOST_CHECK_EQUAL(son2_obj.sidechain_public_keys[sidechain_type::bitcoin], "bitcoin_address 2");
|
|
|
|
|
BOOST_CHECK_EQUAL(son2_obj.sidechain_public_keys[sidechain_type::hive], "hive account 2");
|
|
|
|
|
BOOST_CHECK_EQUAL(son2_obj.get_sidechain_vote_id(sidechain_type::bitcoin).instance(), 24);
|
|
|
|
|
BOOST_CHECK_EQUAL(son2_obj.get_sidechain_vote_id(sidechain_type::hive).instance(), 25);
|
|
|
|
|
|
|
|
|
|
} catch( fc::exception& e ) {
|
|
|
|
|
BOOST_TEST_MESSAGE("SON cli wallet tests exception");
|
|
|
|
|
@ -172,6 +180,10 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
|
|
|
|
|
auto son_data = con.wallet_api_ptr->get_son("sonmember");
|
|
|
|
|
BOOST_CHECK(son_data.url == "http://sonmember");
|
|
|
|
|
BOOST_CHECK(son_data.son_account == sonmember_acct.get_id());
|
|
|
|
|
BOOST_CHECK_EQUAL(son_data.sidechain_public_keys[sidechain_type::bitcoin], "bitcoin_address 1");
|
|
|
|
|
BOOST_CHECK_EQUAL(son_data.sidechain_public_keys[sidechain_type::hive], "hive account 1");
|
|
|
|
|
BOOST_CHECK_EQUAL(son_data.get_sidechain_vote_id(sidechain_type::bitcoin).instance(), 22);
|
|
|
|
|
BOOST_CHECK_EQUAL(son_data.get_sidechain_vote_id(sidechain_type::hive).instance(), 23);
|
|
|
|
|
|
|
|
|
|
// update SON
|
|
|
|
|
sidechain_public_keys.clear();
|
|
|
|
|
@ -181,6 +193,8 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
|
|
|
|
|
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", sidechain_public_keys, true);
|
|
|
|
|
son_data = con.wallet_api_ptr->get_son("sonmember");
|
|
|
|
|
BOOST_CHECK(son_data.url == "http://sonmember_updated");
|
|
|
|
|
BOOST_CHECK_EQUAL(son_data.sidechain_public_keys[sidechain_type::bitcoin], "bitcoin_address 2");
|
|
|
|
|
BOOST_CHECK_EQUAL(son_data.sidechain_public_keys[sidechain_type::hive], "hive account 2");
|
|
|
|
|
|
|
|
|
|
// update SON signing key
|
|
|
|
|
sidechain_public_keys.clear();
|
|
|
|
|
@ -221,8 +235,11 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|
|
|
|
son_object son2_obj;
|
|
|
|
|
signed_transaction vote_son1_tx;
|
|
|
|
|
signed_transaction vote_son2_tx;
|
|
|
|
|
uint64_t son1_start_votes, son1_end_votes;
|
|
|
|
|
uint64_t son2_start_votes, son2_end_votes;
|
|
|
|
|
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;
|
|
|
|
|
@ -239,7 +256,8 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|
|
|
|
// Verify that the vote is there
|
|
|
|
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
son1_end_votes = son1_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son1_end_votes > son1_start_votes);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] > son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::hive] > son1_start_votes[sidechain_type::hive]);
|
|
|
|
|
|
|
|
|
|
// Vote for a son2account
|
|
|
|
|
BOOST_TEST_MESSAGE("Voting for son2account");
|
|
|
|
|
@ -250,36 +268,34 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|
|
|
|
// Verify that the vote is there
|
|
|
|
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
|
|
|
|
son2_end_votes = son2_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son2_end_votes > son2_start_votes);
|
|
|
|
|
|
|
|
|
|
//! Get nathan account
|
|
|
|
|
const auto nathan_account_object = con.wallet_api_ptr->get_account("nathan");
|
|
|
|
|
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]);
|
|
|
|
|
|
|
|
|
|
//! 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");
|
|
|
|
|
@ -290,21 +306,22 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|
|
|
|
// Verify that the vote is removed
|
|
|
|
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
son1_end_votes = son1_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son1_end_votes == son1_start_votes);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] == son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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");
|
|
|
|
|
@ -315,17 +332,18 @@ BOOST_AUTO_TEST_CASE( son_voting )
|
|
|
|
|
// Verify that the vote is removed
|
|
|
|
|
son2_obj = con.wallet_api_ptr->get_son("son2account");
|
|
|
|
|
son2_end_votes = son2_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son2_end_votes == son2_start_votes);
|
|
|
|
|
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]);
|
|
|
|
|
|
|
|
|
|
//! 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");
|
|
|
|
|
@ -340,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;
|
|
|
|
|
@ -378,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());
|
|
|
|
|
|
|
|
|
|
@ -386,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());
|
|
|
|
|
@ -398,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());
|
|
|
|
|
@ -410,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());
|
|
|
|
|
@ -481,8 +502,11 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|
|
|
|
|
|
|
|
|
son_object son1_obj;
|
|
|
|
|
son_object son2_obj;
|
|
|
|
|
uint64_t son1_start_votes, son1_end_votes;
|
|
|
|
|
uint64_t son2_start_votes, son2_end_votes;
|
|
|
|
|
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");
|
|
|
|
|
@ -502,19 +526,46 @@ 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());
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] > son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
@ -523,55 +574,93 @@ 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
|
|
|
|
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
son1_end_votes = son1_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son1_end_votes < son1_start_votes);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] < son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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)); // nathan spent funds for vb, it has different voting power
|
|
|
|
|
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
|
|
|
|
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
son1_end_votes = son1_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son1_end_votes == son1_start_votes);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] == son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
son1_end_votes = son1_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son1_end_votes == son1_start_votes);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] == son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
@ -579,18 +668,24 @@ 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
|
|
|
|
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
|
|
|
|
son1_end_votes = son1_obj.total_votes;
|
|
|
|
|
BOOST_CHECK(son1_end_votes == son1_start_votes);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] == son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
@ -601,13 +696,17 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
|
|
|
|
// 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);
|
|
|
|
|
BOOST_CHECK(son1_end_votes[sidechain_type::bitcoin] == son1_start_votes[sidechain_type::bitcoin]);
|
|
|
|
|
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);
|
|
|
|
|
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()));
|
|
|
|
|
@ -654,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;
|
|
|
|
|
@ -685,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());
|
|
|
|
|
|
|
|
|
|
@ -693,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();
|
|
|
|
|
@ -723,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");
|
|
|
|
|
@ -753,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());
|
|
|
|
|
|
|
|
|
|
@ -805,7 +905,6 @@ BOOST_AUTO_TEST_CASE( sidechain_deposit_transaction_test )
|
|
|
|
|
BOOST_TEST_MESSAGE("SON sidechain_deposit_transaction_test cli wallet tests begin");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const sidechain_type type = sidechain_type::bitcoin;
|
|
|
|
|
son_test_helper sth(*this);
|
|
|
|
|
|
|
|
|
|
std::string son_name("sonaccount1");
|
|
|
|
|
@ -836,7 +935,8 @@ BOOST_AUTO_TEST_CASE( sidechain_deposit_transaction_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), son_name, type, true, true);
|
|
|
|
|
con.wallet_api_ptr->vote_for_son("sonaccount" + fc::to_pretty_string(i), son_name, sidechain_type::bitcoin, true, true);
|
|
|
|
|
con.wallet_api_ptr->vote_for_son("sonaccount" + fc::to_pretty_string(i), son_name, sidechain_type::hive, true, true);
|
|
|
|
|
}
|
|
|
|
|
BOOST_CHECK(generate_maintenance_block());
|
|
|
|
|
|
|
|
|
|
@ -900,7 +1000,8 @@ BOOST_AUTO_TEST_CASE( sidechain_withdraw_transaction_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, 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());
|
|
|
|
|
|
|
|
|
|
|