@@ -585,6 +585,7 @@ fn test_sudo_set_kappa() {
585585 let to_be_set: u16 = 10 ;
586586 add_network ( netuid, 10 ) ;
587587 let init_value: u16 = SubtensorModule :: get_kappa ( netuid) ;
588+ let can_set_by_owner: bool = SubtensorModule :: get_kappa_can_set_by_owner ( netuid) ;
588589 assert_eq ! (
589590 AdminUtils :: sudo_set_kappa(
590591 <<Test as Config >:: RuntimeOrigin >:: signed( U256 :: from( 1 ) ) ,
@@ -601,6 +602,8 @@ fn test_sudo_set_kappa() {
601602 ) ,
602603 Err ( Error :: <Test >:: SubnetDoesNotExist . into( ) )
603604 ) ;
605+
606+ assert_eq ! ( can_set_by_owner, true ) ;
604607 assert_eq ! ( SubtensorModule :: get_kappa( netuid) , init_value) ;
605608 assert_ok ! ( AdminUtils :: sudo_set_kappa(
606609 <<Test as Config >:: RuntimeOrigin >:: root( ) ,
@@ -611,6 +614,65 @@ fn test_sudo_set_kappa() {
611614 } ) ;
612615}
613616
617+ #[ test]
618+ fn test_subnet_owner_set_kappa ( ) {
619+ new_test_ext ( ) . execute_with ( || {
620+ let netuid = NetUid :: from ( 1 ) ;
621+ let to_be_set: u16 = 10 ;
622+ add_network ( netuid, 10 ) ;
623+
624+ let owner = pallet_subtensor:: pallet:: SubnetOwner :: < Test > :: get ( netuid) ;
625+ let init_value: u16 = SubtensorModule :: get_kappa ( netuid) ;
626+ let can_set_by_owner: bool = SubtensorModule :: get_kappa_can_set_by_owner ( netuid) ;
627+ assert_eq ! (
628+ AdminUtils :: sudo_set_kappa(
629+ <<Test as Config >:: RuntimeOrigin >:: signed( U256 :: from( 1 ) ) ,
630+ netuid,
631+ to_be_set
632+ ) ,
633+ Err ( DispatchError :: BadOrigin )
634+ ) ;
635+ assert_eq ! (
636+ AdminUtils :: sudo_set_kappa(
637+ <<Test as Config >:: RuntimeOrigin >:: root( ) ,
638+ netuid. next( ) ,
639+ to_be_set
640+ ) ,
641+ Err ( Error :: <Test >:: SubnetDoesNotExist . into( ) )
642+ ) ;
643+
644+ assert_eq ! ( can_set_by_owner, true ) ;
645+ assert_eq ! ( SubtensorModule :: get_kappa( netuid) , init_value) ;
646+ assert_ok ! ( AdminUtils :: sudo_set_kappa(
647+ <<Test as Config >:: RuntimeOrigin >:: signed( owner) ,
648+ netuid,
649+ to_be_set
650+ ) ) ;
651+ assert_eq ! ( SubtensorModule :: get_kappa( netuid) , to_be_set) ;
652+
653+ assert_ok ! ( AdminUtils :: sudo_set_kappa_can_set_by_owner(
654+ <<Test as Config >:: RuntimeOrigin >:: root( ) ,
655+ netuid,
656+ false
657+ ) ) ;
658+ assert_eq ! ( SubtensorModule :: get_kappa_can_set_by_owner( netuid) , false ) ;
659+
660+ assert_eq ! (
661+ AdminUtils :: sudo_set_kappa(
662+ <<Test as Config >:: RuntimeOrigin >:: signed( owner) ,
663+ netuid,
664+ to_be_set
665+ ) ,
666+ Err ( DispatchError :: BadOrigin )
667+ ) ;
668+ assert_ok ! ( AdminUtils :: sudo_set_kappa(
669+ <<Test as Config >:: RuntimeOrigin >:: root( ) ,
670+ netuid,
671+ to_be_set
672+ ) ) ;
673+ } ) ;
674+ }
675+
614676#[ test]
615677fn test_sudo_set_rho ( ) {
616678 new_test_ext ( ) . execute_with ( || {
0 commit comments