@@ -3919,3 +3919,39 @@ fn test_pending_emission_start_call_not_done() {
39193919 ) ;
39203920 } ) ;
39213921}
3922+
3923+ #[ test]
3924+ fn test_get_subnet_terms_alpha_emissions_cap ( ) {
3925+ new_test_ext ( 1 ) . execute_with ( || {
3926+ let owner_hotkey = U256 :: from ( 10 ) ;
3927+ let owner_coldkey = U256 :: from ( 11 ) ;
3928+ let netuid = add_dynamic_network ( & owner_hotkey, & owner_coldkey) ;
3929+ let tao_block_emission: U96F32 = U96F32 :: saturating_from_num (
3930+ SubtensorModule :: get_block_emission ( )
3931+ . unwrap_or ( TaoCurrency :: ZERO )
3932+ . to_u64 ( ) ,
3933+ ) ;
3934+
3935+ // price = 1.0
3936+ // tao_block_emission = 1000000000
3937+ // tao_block_emission == alpha_emission_i
3938+ // alpha_in_i <= alpha_injection_cap
3939+ let emissions1 = U96F32 :: from_num ( 100_000_000 ) ;
3940+
3941+ let subnet_emissions1 = BTreeMap :: from ( [ ( netuid, emissions1) ] ) ;
3942+ let ( _, alpha_in, _, _) = SubtensorModule :: get_subnet_terms ( & subnet_emissions1) ;
3943+
3944+ assert_eq ! ( alpha_in. get( & netuid) . copied( ) . unwrap( ) , emissions1) ;
3945+
3946+ // price = 1.0
3947+ // tao_block_emission = 1000000000
3948+ // tao_block_emission == alpha_emission_i
3949+ // alpha_in_i > alpha_injection_cap
3950+ let emissions2 = U96F32 :: from_num ( 10_000_000_000u64 ) ;
3951+
3952+ let subnet_emissions2 = BTreeMap :: from ( [ ( netuid, emissions2) ] ) ;
3953+ let ( _, alpha_in, _, _) = SubtensorModule :: get_subnet_terms ( & subnet_emissions2) ;
3954+
3955+ assert_eq ! ( alpha_in. get( & netuid) . copied( ) . unwrap( ) , tao_block_emission) ;
3956+ } ) ;
3957+ }
0 commit comments