@@ -11,7 +11,7 @@ use pallet_subtensor::Event;
1111use sp_consensus_grandpa:: AuthorityId as GrandpaId ;
1212use sp_core:: { Get , Pair , U256 , ed25519} ;
1313use substrate_fixed:: types:: I96F32 ;
14- use subtensor_runtime_common:: { Currency , NetUid , TaoCurrency } ;
14+ use subtensor_runtime_common:: { Currency , NetUid , SubId , TaoCurrency } ;
1515
1616use crate :: Error ;
1717use crate :: pallet:: PrecompileEnable ;
@@ -827,7 +827,7 @@ fn test_sudo_set_bonds_moving_average() {
827827 let netuid = NetUid :: from ( 1 ) ;
828828 let to_be_set: u64 = 10 ;
829829 add_network ( netuid, 10 ) ;
830- let init_value: u64 = SubtensorModule :: get_bonds_moving_average ( netuid) ;
830+ let init_value: u64 = SubtensorModule :: get_bonds_moving_average ( netuid. into ( ) ) ;
831831 assert_eq ! (
832832 AdminUtils :: sudo_set_bonds_moving_average(
833833 <<Test as Config >:: RuntimeOrigin >:: signed( U256 :: from( 1 ) ) ,
@@ -845,15 +845,18 @@ fn test_sudo_set_bonds_moving_average() {
845845 Err ( Error :: <Test >:: SubnetDoesNotExist . into( ) )
846846 ) ;
847847 assert_eq ! (
848- SubtensorModule :: get_bonds_moving_average( netuid) ,
848+ SubtensorModule :: get_bonds_moving_average( netuid. into ( ) ) ,
849849 init_value
850850 ) ;
851851 assert_ok ! ( AdminUtils :: sudo_set_bonds_moving_average(
852852 <<Test as Config >:: RuntimeOrigin >:: root( ) ,
853853 netuid,
854854 to_be_set
855855 ) ) ;
856- assert_eq ! ( SubtensorModule :: get_bonds_moving_average( netuid) , to_be_set) ;
856+ assert_eq ! (
857+ SubtensorModule :: get_bonds_moving_average( netuid. into( ) ) ,
858+ to_be_set
859+ ) ;
857860 } ) ;
858861}
859862
@@ -2227,3 +2230,42 @@ fn test_sudo_set_max_burn() {
22272230 ) ;
22282231 } ) ;
22292232}
2233+
2234+ #[ test]
2235+ fn test_sudo_set_subsubnet_count ( ) {
2236+ new_test_ext ( ) . execute_with ( || {
2237+ let netuid = NetUid :: from ( 1 ) ;
2238+ let ss_count_ok = SubId :: from ( 8 ) ;
2239+ let ss_count_bad = SubId :: from ( 9 ) ;
2240+
2241+ let sn_owner = U256 :: from ( 1324 ) ;
2242+ add_network ( netuid, 10 ) ;
2243+ // Set the Subnet Owner
2244+ SubnetOwner :: < Test > :: insert ( netuid, sn_owner) ;
2245+
2246+ assert_eq ! (
2247+ AdminUtils :: sudo_set_subsubnet_count(
2248+ <<Test as Config >:: RuntimeOrigin >:: signed( U256 :: from( 1 ) ) ,
2249+ netuid,
2250+ ss_count_ok
2251+ ) ,
2252+ Err ( DispatchError :: BadOrigin )
2253+ ) ;
2254+ assert_noop ! (
2255+ AdminUtils :: sudo_set_subsubnet_count( RuntimeOrigin :: root( ) , netuid, ss_count_bad) ,
2256+ pallet_subtensor:: Error :: <Test >:: InvalidValue
2257+ ) ;
2258+
2259+ assert_ok ! ( AdminUtils :: sudo_set_subsubnet_count(
2260+ <<Test as Config >:: RuntimeOrigin >:: root( ) ,
2261+ netuid,
2262+ ss_count_ok
2263+ ) ) ;
2264+
2265+ assert_ok ! ( AdminUtils :: sudo_set_subsubnet_count(
2266+ <<Test as Config >:: RuntimeOrigin >:: signed( sn_owner) ,
2267+ netuid,
2268+ ss_count_ok
2269+ ) ) ;
2270+ } ) ;
2271+ }
0 commit comments