@@ -398,32 +398,7 @@ fn distribute_rewards(amount_bonded_each_miner: u128) {
398398 // assert_eq!(MiningRewardsAllowanceTestModule::rewards_aggregated_dhx_for_all_miners_for_date(1630281600000), Some(0u128));
399399 // assert_eq!(MiningRewardsAllowanceTestModule::rewards_accumulated_dhx_for_miner_for_date((1630281600000, 1)), Some(0u128));
400400
401- // 31th August 2021 @ ~7am is 1630393200000
402- // 31th August 2021 @ 12am is 1630368000000 (start of day)
403- Timestamp :: set_timestamp ( 1630393200000u64 ) ;
404- MiningRewardsAllowanceTestModule :: on_initialize ( 6 ) ;
405- // cooling off period doesn't change again unless they unbond
406- assert_eq ! ( MiningRewardsAllowanceTestModule :: cooling_off_period_days_remaining( 1 ) , Some ( ( 1630368000000 , 0 , 1 ) ) ) ;
407- assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_period_days_remaining( ) , Some ( ( 1630281600000 , 1630368000000 , 2u32 , 1u32 ) ) ) ;
408- assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_change( ) , Some ( 10u32 ) ) ;
409-
410- // 1st Sept 2021 @ ~7am is 1630479600000
411- // 1st Sept 2021 @ 12am is 1630454400000 (start of day)
412- Timestamp :: set_timestamp ( 1630479600000u64 ) ;
413- MiningRewardsAllowanceTestModule :: on_initialize ( 7 ) ;
414- assert_eq ! ( MiningRewardsAllowanceTestModule :: cooling_off_period_days_remaining( 1 ) , Some ( ( 1630454400000 , 0 , 1 ) ) ) ;
415- assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_period_days_remaining( ) , Some ( ( 1630281600000 , 1630454400000 , 2u32 , 0u32 ) ) ) ;
416- assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_change( ) , Some ( 10u32 ) ) ;
417-
418- // 2nd Sept 2021 @ ~7am is 1630566000000
419- // 2nd Sept 2021 @ 12am is 1630540800000 (start of day)
420- Timestamp :: set_timestamp ( 1630566000000u64 ) ;
421- MiningRewardsAllowanceTestModule :: on_initialize ( 7 ) ;
422- assert_eq ! ( MiningRewardsAllowanceTestModule :: cooling_off_period_days_remaining( 1 ) , Some ( ( 1630540800000 , 0 , 1 ) ) ) ;
423- // start of new multiplier period
424- assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_period_days_remaining( ) , Some ( ( 1630540800000 , 1630540800000 , 2u32 , 2u32 ) ) ) ;
425- // check that the min_bonded_dhx_daily doubled after 3 months (we're only doing it after 2 days in the tests though) from 20 DHX to 30 DHX
426- assert_eq ! ( MiningRewardsAllowanceTestModule :: min_bonded_dhx_daily( ) , Some ( THIRTY_DHX ) ) ;
401+ check_rewards_double_each_multiplier_period ( ) ;
427402}
428403
429404fn setup_bonding ( amount_bonded_each_miner : u128 , min_bonding_dhx_daily : u128 ) {
@@ -502,3 +477,32 @@ fn setup_treasury_balance() {
502477 Balances :: set_balance ( Origin :: root ( ) , Treasury :: account_id ( ) , INIT_DAO_BALANCE_DHX , 0 ) ;
503478 assert_eq ! ( Balances :: usable_balance( & Treasury :: account_id( ) ) , INIT_DAO_BALANCE_DHX ) ;
504479}
480+
481+ fn check_rewards_double_each_multiplier_period ( ) {
482+ // 31th August 2021 @ ~7am is 1630393200000
483+ // 31th August 2021 @ 12am is 1630368000000 (start of day)
484+ Timestamp :: set_timestamp ( 1630393200000u64 ) ;
485+ MiningRewardsAllowanceTestModule :: on_initialize ( 6 ) ;
486+ // cooling off period doesn't change again unless they unbond
487+ assert_eq ! ( MiningRewardsAllowanceTestModule :: cooling_off_period_days_remaining( 1 ) , Some ( ( 1630368000000 , 0 , 1 ) ) ) ;
488+ assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_period_days_remaining( ) , Some ( ( 1630281600000 , 1630368000000 , 2u32 , 1u32 ) ) ) ;
489+ assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_change( ) , Some ( 10u32 ) ) ;
490+
491+ // 1st Sept 2021 @ ~7am is 1630479600000
492+ // 1st Sept 2021 @ 12am is 1630454400000 (start of day)
493+ Timestamp :: set_timestamp ( 1630479600000u64 ) ;
494+ MiningRewardsAllowanceTestModule :: on_initialize ( 7 ) ;
495+ assert_eq ! ( MiningRewardsAllowanceTestModule :: cooling_off_period_days_remaining( 1 ) , Some ( ( 1630454400000 , 0 , 1 ) ) ) ;
496+ assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_period_days_remaining( ) , Some ( ( 1630281600000 , 1630454400000 , 2u32 , 0u32 ) ) ) ;
497+ assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_change( ) , Some ( 10u32 ) ) ;
498+
499+ // 2nd Sept 2021 @ ~7am is 1630566000000
500+ // 2nd Sept 2021 @ 12am is 1630540800000 (start of day)
501+ Timestamp :: set_timestamp ( 1630566000000u64 ) ;
502+ MiningRewardsAllowanceTestModule :: on_initialize ( 7 ) ;
503+ assert_eq ! ( MiningRewardsAllowanceTestModule :: cooling_off_period_days_remaining( 1 ) , Some ( ( 1630540800000 , 0 , 1 ) ) ) ;
504+ // start of new multiplier period
505+ assert_eq ! ( MiningRewardsAllowanceTestModule :: rewards_multiplier_current_period_days_remaining( ) , Some ( ( 1630540800000 , 1630540800000 , 2u32 , 2u32 ) ) ) ;
506+ // check that the min_bonded_dhx_daily doubled after 3 months (we're only doing it after 2 days in the tests though) from 20 DHX to 30 DHX
507+ assert_eq ! ( MiningRewardsAllowanceTestModule :: min_bonded_dhx_daily( ) , Some ( THIRTY_DHX ) ) ;
508+ }
0 commit comments