updated comments to the benefit of reviewer
This commit is contained in:
parent
9f0b23122f
commit
3f8ac21b1e
2 changed files with 8 additions and 7 deletions
|
|
@ -787,7 +787,7 @@ double database::calculate_vesting_factor(const account_object& stake_account)
|
||||||
if(current_subperiod == 1 && this->head_block_time() >= HARDFORK_GPOS_TIME + vesting_period) //Applicable only from 2nd vesting period
|
if(current_subperiod == 1 && this->head_block_time() >= HARDFORK_GPOS_TIME + vesting_period) //Applicable only from 2nd vesting period
|
||||||
{
|
{
|
||||||
if(last_date_voted > period_start - vesting_subperiod)
|
if(last_date_voted > period_start - vesting_subperiod)
|
||||||
return 1; //return vesting factor as 1
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(last_date_voted < period_start) return 0;
|
if(last_date_voted < period_start) return 0;
|
||||||
|
|
|
||||||
|
|
@ -568,7 +568,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
auto witness2 = witness_id_type(2)(db);
|
auto witness2 = witness_id_type(2)(db);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 0);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 0);
|
||||||
|
|
||||||
// vote for witness1
|
// vote for witness1 and witness2 - sub-period 1
|
||||||
vote_for(alice_id, witness1.vote_id, alice_private_key);
|
vote_for(alice_id, witness1.vote_id, alice_private_key);
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
||||||
|
|
@ -583,7 +583,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
|
|
||||||
advance_x_maint(10);
|
advance_x_maint(10);
|
||||||
|
|
||||||
//vote bob tot witness2 in each subperiod and verify votes
|
//Bob votes for witness2 - sub-period 2
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
// go to maint
|
// go to maint
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
|
|
@ -595,6 +595,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(10);
|
advance_x_maint(10);
|
||||||
|
//Bob votes for witness2 - sub-period 3
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
// decay more
|
// decay more
|
||||||
|
|
@ -605,7 +606,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
|
|
||||||
advance_x_maint(10);
|
advance_x_maint(10);
|
||||||
|
|
||||||
// more
|
// Bob votes for witness2 - sub-period 4
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
// decay more
|
// decay more
|
||||||
|
|
@ -616,7 +617,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
|
|
||||||
advance_x_maint(10);
|
advance_x_maint(10);
|
||||||
|
|
||||||
// more
|
// Bob votes for witness2 - sub-period 5
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
// decay more
|
// decay more
|
||||||
|
|
@ -628,7 +629,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
|
|
||||||
advance_x_maint(10);
|
advance_x_maint(10);
|
||||||
|
|
||||||
// more
|
// Bob votes for witness2 - sub-period 6
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
// decay more
|
// decay more
|
||||||
|
|
@ -641,7 +642,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
||||||
|
|
||||||
advance_x_maint(5);
|
advance_x_maint(5);
|
||||||
// a new GPOS period is in but vote from user is before the start. WHo ever votes in 6th sub-period, votes will carry
|
// a new GPOS period is in but vote from user is before the start. Whoever votes in 6th sub-period, votes will carry
|
||||||
now = db.head_block_time();
|
now = db.head_block_time();
|
||||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue