@@ -3920,6 +3920,67 @@ fn test_pending_emission_start_call_not_done() {
39203920 } ) ;
39213921}
39223922
3923+ #[ test]
3924+ fn test_root_prop_filled_on_block_step ( ) {
3925+ new_test_ext ( 1 ) . execute_with ( || {
3926+ let hotkey = U256 :: from ( 10 ) ;
3927+ let coldkey = U256 :: from ( 11 ) ;
3928+ let netuid1 = add_dynamic_network ( & hotkey, & coldkey) ;
3929+ let netuid2 = add_dynamic_network ( & hotkey, & coldkey) ;
3930+
3931+ SubnetTAO :: < Test > :: insert ( NetUid :: ROOT , TaoCurrency :: from ( 1_000_000_000_000u64 ) ) ;
3932+ SubtensorModule :: set_tao_weight ( u64:: MAX ) ; // Set TAO weight to 1.0
3933+
3934+ let tao_reserve = TaoCurrency :: from ( 50_000_000_000 ) ;
3935+ let alpha_in = AlphaCurrency :: from ( 100_000_000_000 ) ;
3936+ SubnetTAO :: < Test > :: insert ( netuid1, tao_reserve) ;
3937+ SubnetAlphaIn :: < Test > :: insert ( netuid1, alpha_in) ;
3938+ SubnetTAO :: < Test > :: insert ( netuid2, tao_reserve) ;
3939+ SubnetAlphaIn :: < Test > :: insert ( netuid2, alpha_in) ;
3940+
3941+ assert ! ( !RootProp :: <Test >:: contains_key( netuid1) ) ;
3942+ assert ! ( !RootProp :: <Test >:: contains_key( netuid2) ) ;
3943+
3944+ run_to_block ( 2 ) ;
3945+
3946+ assert ! ( RootProp :: <Test >:: get( netuid1) > U96F32 :: from_num( 0 ) ) ;
3947+ assert ! ( RootProp :: <Test >:: get( netuid2) > U96F32 :: from_num( 0 ) ) ;
3948+ } ) ;
3949+ }
3950+
3951+ #[ test]
3952+ fn test_root_proportion ( ) {
3953+ new_test_ext ( 1 ) . execute_with ( || {
3954+ let hotkey = U256 :: from ( 10 ) ;
3955+ let coldkey = U256 :: from ( 11 ) ;
3956+ let netuid = add_dynamic_network ( & hotkey, & coldkey) ;
3957+
3958+ let root_tao_reserve = 1_000_000_000_000u64 ;
3959+ SubnetTAO :: < Test > :: insert ( NetUid :: ROOT , TaoCurrency :: from ( root_tao_reserve) ) ;
3960+
3961+ let tao_weight = 3_320_413_933_267_719_290u64 ;
3962+ SubtensorModule :: set_tao_weight ( tao_weight) ;
3963+
3964+ let alpha_in = 100_000_000_000u64 ;
3965+ SubnetAlphaIn :: < Test > :: insert ( netuid, AlphaCurrency :: from ( alpha_in) ) ;
3966+
3967+ let actual_root_proportion = SubtensorModule :: root_proportion ( netuid) ;
3968+ let expected_root_prop = {
3969+ let tao_weight = SubtensorModule :: get_tao_weight ( ) ;
3970+ let root_tao = U96F32 :: from_num ( root_tao_reserve) ;
3971+ let alpha_in = {
3972+ let alpha: u64 = SubtensorModule :: get_alpha_issuance ( netuid) . into ( ) ;
3973+
3974+ U96F32 :: from_num ( alpha)
3975+ } ;
3976+
3977+ tao_weight * root_tao / ( tao_weight * root_tao + alpha_in)
3978+ } ;
3979+
3980+ assert_eq ! ( actual_root_proportion, expected_root_prop) ;
3981+ } ) ;
3982+ }
3983+
39233984#[ test]
39243985fn test_get_subnet_terms_alpha_emissions_cap ( ) {
39253986 new_test_ext ( 1 ) . execute_with ( || {
0 commit comments