Merge branch 'feature/328-son-voting-test' into 'feature/son-for-hive-voting'

#328 son voting test

See merge request PBSA/peerplays!91
This commit is contained in:
serkixenos 2022-03-28 14:29:26 +00:00
commit 94a3998d7a
6 changed files with 203 additions and 99 deletions

View file

@ -716,11 +716,12 @@ void database::update_active_sons()
}); });
} }
modify( son, [local_vote_buffer_ref]( son_object& obj ){ modify( son, [local_vote_buffer_ref]( son_object& obj ){
//! FIXME - only bitcoin_vote_id ??? for(const auto& sidechain_vote_id : obj.sidechain_vote_ids ){
obj.total_votes = local_vote_buffer_ref[obj.get_bitcoin_vote_id()]; obj.total_votes[sidechain_vote_id.first] = local_vote_buffer_ref[sidechain_vote_id.second];
if(obj.status == son_status::request_maintenance) }
obj.status = son_status::in_maintenance; if(obj.status == son_status::request_maintenance)
}); obj.status = son_status::in_maintenance;
});
} }
// Update SON authority // Update SON authority
@ -2235,17 +2236,19 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
// same rationale as for witnesses // same rationale as for witnesses
d._committee_count_histogram_buffer[offset] += voting_stake; d._committee_count_histogram_buffer[offset] += voting_stake;
} }
if( opinion_account.options.num_son <= props.parameters.maximum_son_count() ) for(const auto& num_sidechain_son : opinion_account.options.num_son) {
{ const auto& num_son = num_sidechain_son.second;
uint16_t offset = std::min(size_t(opinion_account.options.num_son/2), if (num_son <= props.parameters.maximum_son_count()) {
d._son_count_histogram_buffer.size() - 1); uint16_t offset = std::min(size_t(num_son / 2),
// votes for a number greater than maximum_son_count d._son_count_histogram_buffer.size() - 1);
// are turned into votes for maximum_son_count. // votes for a number greater than maximum_son_count
// // are turned into votes for maximum_son_count.
// in particular, this takes care of the case where a //
// member was voting for a high number, then the // in particular, this takes care of the case where a
// parameter was lowered. // member was voting for a high number, then the
d._son_count_histogram_buffer[offset] += voting_stake; // parameter was lowered.
d._son_count_histogram_buffer[offset] += voting_stake;
}
} }
d._total_voting_stake += voting_stake; d._total_voting_stake += voting_stake;

View file

@ -28,6 +28,7 @@
#include <graphene/chain/protocol/special_authority.hpp> #include <graphene/chain/protocol/special_authority.hpp>
#include <graphene/chain/protocol/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/protocol/vote.hpp> #include <graphene/chain/protocol/vote.hpp>
#include <graphene/chain/sidechain_defs.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -54,7 +55,7 @@ namespace graphene { namespace chain {
uint16_t num_committee = 0; uint16_t num_committee = 0;
/// The number of active son members this account votes the blockchain should appoint /// The number of active son members this account votes the blockchain should appoint
/// Must not exceed the actual number of son members voted for in @ref votes /// Must not exceed the actual number of son members voted for in @ref votes
uint16_t num_son = 0; flat_map<sidechain_type, uint16_t> num_son;
/// This is the list of vote IDs this account votes for. The weight of these votes is determined by this /// This is the list of vote IDs this account votes for. The weight of these votes is determined by this
/// account's balance of core asset. /// account's balance of core asset.
flat_set<vote_id_type> votes; flat_set<vote_id_type> votes;

View file

@ -65,7 +65,7 @@ namespace graphene { namespace chain {
account_id_type son_account; account_id_type son_account;
flat_map<sidechain_type, vote_id_type> sidechain_vote_ids; flat_map<sidechain_type, vote_id_type> sidechain_vote_ids;
uint64_t total_votes = 0; flat_map<sidechain_type, uint64_t> total_votes;
string url; string url;
vesting_balance_id_type deposit; vesting_balance_id_type deposit;
public_key_type signing_key; public_key_type signing_key;

View file

@ -174,26 +174,25 @@ void account_options::validate() const
{ {
auto needed_witnesses = num_witness; auto needed_witnesses = num_witness;
auto needed_committee = num_committee; auto needed_committee = num_committee;
auto needed_sons_bitcoin = num_son; auto needed_sons = num_son;
auto needed_sons_hive = num_son;
for( vote_id_type id : votes ) for( vote_id_type id : votes )
if( id.type() == vote_id_type::witness && needed_witnesses ) if( id.type() == vote_id_type::witness && needed_witnesses )
--needed_witnesses; --needed_witnesses;
else if ( id.type() == vote_id_type::committee && needed_committee ) else if ( id.type() == vote_id_type::committee && needed_committee )
--needed_committee; --needed_committee;
else if ( id.type() == vote_id_type::son_bitcoin && needed_sons_bitcoin ) else if ( id.type() == vote_id_type::son_bitcoin && needed_sons[sidechain_type::bitcoin] )
--needed_sons_bitcoin; --needed_sons[sidechain_type::bitcoin];
else if ( id.type() == vote_id_type::son_hive && needed_sons_hive ) else if ( id.type() == vote_id_type::son_hive && needed_sons[sidechain_type::hive] )
--needed_sons_hive; --needed_sons[sidechain_type::hive];
FC_ASSERT( needed_witnesses == 0, FC_ASSERT( needed_witnesses == 0,
"May not specify fewer witnesses than the number voted for."); "May not specify fewer witnesses than the number voted for.");
FC_ASSERT( needed_committee == 0, FC_ASSERT( needed_committee == 0,
"May not specify fewer committee members than the number voted for."); "May not specify fewer committee members than the number voted for.");
FC_ASSERT( needed_sons_bitcoin == 0, FC_ASSERT( needed_sons[sidechain_type::bitcoin] == 0,
"May not specify fewer Bitcoin SONs than the number voted for."); "May not specify fewer Bitcoin SONs than the number voted for.");
FC_ASSERT( needed_sons_hive == 0, FC_ASSERT( needed_sons[sidechain_type::hive] == 0,
"May not specify fewer Hive SONs than the number voted for."); "May not specify fewer Hive SONs than the number voted for.");
} }

View file

@ -2878,7 +2878,7 @@ public:
if (!votes_removed) if (!votes_removed)
FC_THROW("Account ${account} is already not voting for SON ${son}", ("account", voting_account)("son", son)); FC_THROW("Account ${account} is already not voting for SON ${son}", ("account", voting_account)("son", son));
} }
voting_account_object.options.num_son = desired_number_of_sons; voting_account_object.options.num_son[sidechain] = desired_number_of_sons;
account_update_operation account_update_op; account_update_operation account_update_op;
account_update_op.account = voting_account_object.id; account_update_op.account = voting_account_object.id;

View file

@ -138,10 +138,18 @@ BOOST_AUTO_TEST_CASE( create_sons )
auto son1_obj = con.wallet_api_ptr->get_son("son1account"); 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(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.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"); 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(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.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 ) { } catch( fc::exception& e ) {
BOOST_TEST_MESSAGE("SON cli wallet tests exception"); 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"); auto son_data = con.wallet_api_ptr->get_son("sonmember");
BOOST_CHECK(son_data.url == "http://sonmember"); BOOST_CHECK(son_data.url == "http://sonmember");
BOOST_CHECK(son_data.son_account == sonmember_acct.get_id()); 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 // update SON
sidechain_public_keys.clear(); 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); con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", sidechain_public_keys, true);
son_data = con.wallet_api_ptr->get_son("sonmember"); son_data = con.wallet_api_ptr->get_son("sonmember");
BOOST_CHECK(son_data.url == "http://sonmember_updated"); 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 // update SON signing key
sidechain_public_keys.clear(); sidechain_public_keys.clear();
@ -221,8 +235,11 @@ BOOST_AUTO_TEST_CASE( son_voting )
son_object son2_obj; son_object son2_obj;
signed_transaction vote_son1_tx; signed_transaction vote_son1_tx;
signed_transaction vote_son2_tx; signed_transaction vote_son2_tx;
uint64_t son1_start_votes, son1_end_votes; flat_map<sidechain_type, uint64_t> son1_start_votes, son1_end_votes;
uint64_t son2_start_votes, son2_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_obj = con.wallet_api_ptr->get_son("son1account");
son1_start_votes = son1_obj.total_votes; son1_start_votes = son1_obj.total_votes;
@ -239,7 +256,8 @@ BOOST_AUTO_TEST_CASE( son_voting )
// Verify that the vote is there // Verify that the vote is there
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_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 // Vote for a son2account
BOOST_TEST_MESSAGE("Voting for son2account"); BOOST_TEST_MESSAGE("Voting for son2account");
@ -250,36 +268,34 @@ BOOST_AUTO_TEST_CASE( son_voting )
// Verify that the vote is there // Verify that the vote is there
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_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]);
//! Get nathan account
const auto nathan_account_object = con.wallet_api_ptr->get_account("nathan");
//! Check son1account voters //! Check son1account voters
auto voters_for_son1account = con.wallet_api_ptr->get_voters("son1account"); auto voters_for_son1account = con.wallet_api_ptr->get_voters("son1account").voters_for_son;
BOOST_REQUIRE(voters_for_son1account.voters_for_son); BOOST_REQUIRE(voters_for_son1account);
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 1); BOOST_REQUIRE_EQUAL(voters_for_son1account->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((uint32_t)voters_for_son1account->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_REQUIRE_EQUAL(voters_for_son1account->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()); BOOST_CHECK_EQUAL((uint32_t)voters_for_son1account->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
//! Check son2account voters //! Check son2account voters
auto voters_for_son2account = con.wallet_api_ptr->get_voters("son2account"); auto voters_for_son2account = con.wallet_api_ptr->get_voters("son2account").voters_for_son;
BOOST_REQUIRE(voters_for_son2account.voters_for_son); BOOST_REQUIRE(voters_for_son2account);
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 1); BOOST_REQUIRE_EQUAL(voters_for_son2account->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((uint32_t)voters_for_son2account->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_REQUIRE_EQUAL(voters_for_son2account->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()); BOOST_CHECK_EQUAL((uint32_t)voters_for_son2account->at(sidechain_type::hive).voters[0].instance, nathan_account_object.id.instance());
//! Check votes of nathan //! Check votes of nathan
auto nathan_votes = con.wallet_api_ptr->get_votes("nathan"); auto nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
BOOST_REQUIRE(nathan_votes.votes_for_sons); BOOST_REQUIRE(nathan_votes_for_son);
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).size(), 2); BOOST_REQUIRE_EQUAL(nathan_votes_for_son->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_for_son->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_for_son->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_REQUIRE_EQUAL(nathan_votes_for_son->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_for_son->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()); BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(1).id.instance(), son2_obj.id.instance());
// Withdraw vote for a son1account // Withdraw vote for a son1account
BOOST_TEST_MESSAGE("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 // Verify that the vote is removed
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_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 //! Check son1account voters
voters_for_son1account = con.wallet_api_ptr->get_voters("son1account"); voters_for_son1account = con.wallet_api_ptr->get_voters("son1account").voters_for_son;
BOOST_REQUIRE(voters_for_son1account.voters_for_son); BOOST_REQUIRE(voters_for_son1account);
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 0); BOOST_CHECK_EQUAL(voters_for_son1account->at(sidechain_type::bitcoin).voters.size(), 0);
BOOST_CHECK_EQUAL(voters_for_son1account.voters_for_son->at(sidechain_type::hive).voters.size(), 0); BOOST_CHECK_EQUAL(voters_for_son1account->at(sidechain_type::hive).voters.size(), 0);
//! Check votes of nathan //! Check votes of nathan
nathan_votes = con.wallet_api_ptr->get_votes("nathan"); nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
BOOST_REQUIRE(nathan_votes.votes_for_sons); BOOST_REQUIRE(nathan_votes_for_son);
BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(sidechain_type::bitcoin).size(), 1); BOOST_REQUIRE_EQUAL(nathan_votes_for_son->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_for_son->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_for_son->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()); BOOST_CHECK_EQUAL(nathan_votes_for_son->at(sidechain_type::hive).at(0).id.instance(), son2_obj.id.instance());
// Withdraw vote for a son2account // Withdraw vote for a son2account
BOOST_TEST_MESSAGE("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 // Verify that the vote is removed
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_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 //! Check son2account voters
voters_for_son2account = con.wallet_api_ptr->get_voters("son2account"); voters_for_son2account = con.wallet_api_ptr->get_voters("son2account").voters_for_son;
BOOST_REQUIRE(voters_for_son2account.voters_for_son); BOOST_REQUIRE(voters_for_son2account);
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::bitcoin).voters.size(), 0); BOOST_CHECK_EQUAL(voters_for_son2account->at(sidechain_type::bitcoin).voters.size(), 0);
BOOST_CHECK_EQUAL(voters_for_son2account.voters_for_son->at(sidechain_type::hive).voters.size(), 0); BOOST_CHECK_EQUAL(voters_for_son2account->at(sidechain_type::hive).voters.size(), 0);
//! Check votes of nathan //! Check votes of nathan
nathan_votes = con.wallet_api_ptr->get_votes("nathan"); nathan_votes_for_son = con.wallet_api_ptr->get_votes("nathan").votes_for_sons;
BOOST_CHECK(!nathan_votes.votes_for_sons.valid()); BOOST_CHECK(!nathan_votes_for_son);
} catch( fc::exception& e ) { } catch( fc::exception& e ) {
BOOST_TEST_MESSAGE("SON cli wallet tests exception"); 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"); BOOST_TEST_MESSAGE("SON cli wallet tests begin");
try try
{ {
const sidechain_type type = sidechain_type::bitcoin;
son_test_helper sth(*this); son_test_helper sth(*this);
graphene::wallet::brain_key_info bki; 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); 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); 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()); 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 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);
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(); gpo = con.wallet_api_ptr->get_global_properties();
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); 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 name1 = "sonaccount" + fc::to_pretty_string(i + 2);
std::string name2 = "sonaccount" + fc::to_pretty_string(i); 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(); gpo = con.wallet_api_ptr->get_global_properties();
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); 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 name1 = "sonaccount" + fc::to_pretty_string(i + 3);
std::string name2 = "sonaccount" + fc::to_pretty_string(i); 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(); gpo = con.wallet_api_ptr->get_global_properties();
BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); 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 son1_obj;
son_object son2_obj; son_object son2_obj;
uint64_t son1_start_votes, son1_end_votes; flat_map<sidechain_type, uint64_t> son1_start_votes, son1_end_votes;
uint64_t son2_start_votes, son2_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 // Get votes at start
son1_obj = con.wallet_api_ptr->get_son("son1account"); 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); 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, update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
sidechain_type::bitcoin, 2, true); 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(); generate_block();
BOOST_CHECK(generate_maintenance_block()); BOOST_CHECK(generate_maintenance_block());
// 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_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; 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_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; 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 // Withdraw vote for SON 1
accepted.clear(); 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); 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, update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
sidechain_type::bitcoin, 1, true); 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()); BOOST_CHECK(generate_maintenance_block());
// 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_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; 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[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; 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 // Try to reject incorrect SON
accepted.clear(); accepted.clear();
rejected.clear(); rejected.clear();
rejected.push_back("son1accnt"); rejected.push_back("son1accnt");
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected, BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
sidechain_type::bitcoin, 1, true), fc::exception); 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(); generate_block();
// 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_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; 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_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; 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 // Reject SON2
accepted.clear(); accepted.clear();
rejected.clear(); rejected.clear();
rejected.push_back("son2account"); rejected.push_back("son2account");
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected, update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
sidechain_type::bitcoin, 0, true); 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()); BOOST_CHECK(generate_maintenance_block());
// 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_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; 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_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; 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 // Try to accept and reject the same SON
accepted.clear(); accepted.clear();
rejected.clear(); rejected.clear();
@ -579,18 +668,24 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
accepted.push_back("son1accnt"); accepted.push_back("son1accnt");
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected, BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, rejected,
sidechain_type::bitcoin, 1, true), fc::exception); 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()); BOOST_CHECK(generate_maintenance_block());
// 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_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; 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_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; 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 // Try to accept and reject empty lists
accepted.clear(); accepted.clear();
rejected.clear(); rejected.clear();
@ -601,13 +696,17 @@ 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_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; 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_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; 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 ) { } catch( fc::exception& e ) {
BOOST_TEST_MESSAGE("SON cli wallet tests exception"); BOOST_TEST_MESSAGE("SON cli wallet tests exception");
edump((e.to_detail_string())); 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"); BOOST_TEST_MESSAGE("SON cli wallet tests for list_active_sons begin");
try try
{ {
const sidechain_type type = sidechain_type::bitcoin;
son_test_helper sth(*this); son_test_helper sth(*this);
signed_transaction vote_tx; 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++) 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);
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()); 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 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);
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()); BOOST_CHECK(generate_maintenance_block());
gpo = con.wallet_api_ptr->get_global_properties(); 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"); BOOST_TEST_MESSAGE("SON maintenance cli wallet tests begin");
try try
{ {
const sidechain_type type = sidechain_type::bitcoin;
son_test_helper sth(*this); son_test_helper sth(*this);
std::string name("sonaccount1"); std::string name("sonaccount1");
@ -753,7 +852,8 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
con.wallet_api_ptr->transfer( 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 ); "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->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()); 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"); BOOST_TEST_MESSAGE("SON sidechain_deposit_transaction_test cli wallet tests begin");
try try
{ {
const sidechain_type type = sidechain_type::bitcoin;
son_test_helper sth(*this); son_test_helper sth(*this);
std::string son_name("sonaccount1"); std::string son_name("sonaccount1");
@ -836,7 +935,8 @@ BOOST_AUTO_TEST_CASE( sidechain_deposit_transaction_test )
con.wallet_api_ptr->transfer( 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 ); "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->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()); BOOST_CHECK(generate_maintenance_block());
@ -900,7 +1000,8 @@ BOOST_AUTO_TEST_CASE( sidechain_withdraw_transaction_test )
con.wallet_api_ptr->transfer( 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 ); "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->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()); BOOST_CHECK(generate_maintenance_block());