check number of sons against votes number in account_object
This commit is contained in:
parent
ff09c75734
commit
c1208b36f6
2 changed files with 15 additions and 8 deletions
|
|
@ -171,15 +171,22 @@ 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 = 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 && needed_sons )
|
||||||
|
--needed_sons;
|
||||||
|
|
||||||
FC_ASSERT( needed_witnesses == 0 && needed_committee == 0,
|
FC_ASSERT( needed_witnesses == 0,
|
||||||
"May not specify fewer witnesses or committee members than the number voted for.");
|
"May not specify fewer witnesses than the number voted for.");
|
||||||
|
FC_ASSERT( needed_committee == 0,
|
||||||
|
"May not specify committee members than the number voted for.");
|
||||||
|
FC_ASSERT( needed_sons == 0,
|
||||||
|
"May not specify fewer SONs than the number voted for.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void affiliate_reward_distribution::validate() const
|
void affiliate_reward_distribution::validate() const
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
accepted.push_back("son1account");
|
accepted.push_back("son1account");
|
||||||
accepted.push_back("son2account");
|
accepted.push_back("son2account");
|
||||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 15, true);
|
rejected, 2, true);
|
||||||
BOOST_CHECK(generate_block());
|
BOOST_CHECK(generate_block());
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
|
@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
rejected.clear();
|
rejected.clear();
|
||||||
rejected.push_back("son1account");
|
rejected.push_back("son1account");
|
||||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 15, true);
|
rejected, 1, true);
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
|
|
@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
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,
|
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 15, true), fc::exception);
|
rejected, 1, true), fc::exception);
|
||||||
BOOST_CHECK(generate_block());
|
BOOST_CHECK(generate_block());
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
|
|
@ -449,7 +449,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
rejected.clear();
|
rejected.clear();
|
||||||
rejected.push_back("son2account");
|
rejected.push_back("son2account");
|
||||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 15, true);
|
rejected, 0, true);
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
|
|
@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
rejected.push_back("son1accnt");
|
rejected.push_back("son1accnt");
|
||||||
accepted.push_back("son1accnt");
|
accepted.push_back("son1accnt");
|
||||||
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 15, true), fc::exception);
|
rejected, 1, true), fc::exception);
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
|
|
@ -485,7 +485,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
accepted.clear();
|
accepted.clear();
|
||||||
rejected.clear();
|
rejected.clear();
|
||||||
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 15, true), fc::exception);
|
rejected, 1, true), fc::exception);
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue