11#![ allow( clippy:: unwrap_used) ]
22
3+ use approx:: assert_abs_diff_eq;
34use frame_support:: traits:: Currency ;
45
56use super :: mock:: * ;
@@ -535,11 +536,11 @@ fn test_burn_adjustment() {
535536 new_test_ext ( 1 ) . execute_with ( || {
536537 let netuid: u16 = 1 ;
537538 let tempo: u16 = 13 ;
538- let burn_cost : u64 = 1000 ;
539+ let init_burn_cost : u64 = InitialMinBurn :: get ( ) + 10_000 ;
539540 let adjustment_interval = 1 ;
540541 let target_registrations_per_interval = 1 ;
541542 add_network ( netuid, tempo, 0 ) ;
542- SubtensorModule :: set_burn ( netuid, burn_cost ) ;
543+ SubtensorModule :: set_burn ( netuid, init_burn_cost ) ;
543544 SubtensorModule :: set_adjustment_interval ( netuid, adjustment_interval) ;
544545 SubtensorModule :: set_adjustment_alpha ( netuid, 58000 ) ; // Set to old value.
545546 SubtensorModule :: set_target_registrations_per_interval (
@@ -550,7 +551,7 @@ fn test_burn_adjustment() {
550551 // Register key 1.
551552 let hotkey_account_id_1 = U256 :: from ( 1 ) ;
552553 let coldkey_account_id_1 = U256 :: from ( 1 ) ;
553- SubtensorModule :: add_balance_to_coldkey_account ( & coldkey_account_id_1, 10000 ) ;
554+ SubtensorModule :: add_balance_to_coldkey_account ( & coldkey_account_id_1, init_burn_cost ) ;
554555 assert_ok ! ( SubtensorModule :: burned_register(
555556 <<Test as Config >:: RuntimeOrigin >:: signed( hotkey_account_id_1) ,
556557 netuid,
@@ -560,7 +561,7 @@ fn test_burn_adjustment() {
560561 // Register key 2.
561562 let hotkey_account_id_2 = U256 :: from ( 2 ) ;
562563 let coldkey_account_id_2 = U256 :: from ( 2 ) ;
563- SubtensorModule :: add_balance_to_coldkey_account ( & coldkey_account_id_2, 10000 ) ;
564+ SubtensorModule :: add_balance_to_coldkey_account ( & coldkey_account_id_2, init_burn_cost ) ;
564565 assert_ok ! ( SubtensorModule :: burned_register(
565566 <<Test as Config >:: RuntimeOrigin >:: signed( hotkey_account_id_2) ,
566567 netuid,
@@ -571,8 +572,13 @@ fn test_burn_adjustment() {
571572 // Step the block and trigger the adjustment.
572573 step_block ( 1 ) ;
573574
574- // Check the adjusted burn.
575- assert_eq ! ( SubtensorModule :: get_burn_as_u64( netuid) , 1500 ) ;
575+ // Check the adjusted burn is above the initial min burn.
576+ assert ! ( SubtensorModule :: get_burn_as_u64( netuid) > init_burn_cost) ;
577+ assert_abs_diff_eq ! (
578+ SubtensorModule :: get_burn_as_u64( netuid) ,
579+ init_burn_cost. saturating_mul( 3 ) . saturating_div( 2 ) , // 1.5x
580+ epsilon = 1000
581+ ) ;
576582 } ) ;
577583}
578584
0 commit comments