11use crate :: mock:: * ;
2- use frame_support:: { dispatch :: { DispatchClass , GetDispatchInfo , Pays } , assert_err, assert_ok} ;
2+ use frame_support:: { assert_err, assert_ok} ;
33use frame_system:: Config ;
44use pallet_subtensor:: * ;
55use rand:: { distributions:: Uniform , rngs:: StdRng , seq:: SliceRandom , thread_rng, Rng , SeedableRng } ;
@@ -1510,12 +1510,12 @@ fn test_set_alpha_disabled() {
15101510 // Explicitly set to false
15111511 SubtensorModule :: set_liquid_alpha_enabled ( netuid, false ) ;
15121512 assert_err ! (
1513- SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, 12_u16 , u16 :: MAX ) ,
1513+ SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, 12_u16 , u16 :: MAX ) ,
15141514 Error :: <Test >:: LiquidAlphaDisabled
15151515 ) ;
15161516
15171517 SubtensorModule :: set_liquid_alpha_enabled ( netuid, true ) ;
1518- assert_ok ! ( SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, 12_u16 , u16 :: MAX ) ) ;
1518+ assert_ok ! ( SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, 12_u16 , u16 :: MAX ) ) ;
15191519 } ) ;
15201520}
15211521
@@ -2555,15 +2555,15 @@ fn test_get_set_alpha() {
25552555
25562556 // Should fail as signer does not own the subnet
25572557 assert_err ! (
2558- SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ,
2558+ SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ,
25592559 DispatchError :: BadOrigin
25602560 ) ;
25612561
25622562 assert_ok ! ( SubtensorModule :: register_network(
25632563 signer. clone( )
25642564 ) ) ;
25652565
2566- assert_ok ! ( SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
2566+ assert_ok ! ( SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
25672567 let ( grabbed_alpha_low, grabbed_alpha_high) : ( u16 , u16 ) = SubtensorModule :: get_alpha_values ( netuid) ;
25682568
25692569 log:: info!( "alpha_low: {:?} alpha_high: {:?}" , grabbed_alpha_low, grabbed_alpha_high) ;
@@ -2590,56 +2590,38 @@ fn test_get_set_alpha() {
25902590 // 1. Liquid alpha disabled
25912591 SubtensorModule :: set_liquid_alpha_enabled ( netuid, false ) ;
25922592 assert_err ! (
2593- SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ,
2593+ SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ,
25942594 Error :: <Test >:: LiquidAlphaDisabled
25952595 ) ;
25962596 // Correct scenario after error
25972597 SubtensorModule :: set_liquid_alpha_enabled ( netuid, true ) ; // Re-enable for further tests
2598- assert_ok ! ( SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
2598+ assert_ok ! ( SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
25992599
26002600 // 2. Alpha high too low
26012601 let alpha_high_too_low = ( u16:: MAX as u32 * 4 / 5 ) as u16 - 1 ; // One less than the minimum acceptable value
26022602 assert_err ! (
2603- SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high_too_low) ,
2603+ SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high_too_low) ,
26042604 Error :: <Test >:: AlphaHighTooLow
26052605 ) ;
26062606 // Correct scenario after error
2607- assert_ok ! ( SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
2607+ assert_ok ! ( SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
26082608
26092609 // 3. Alpha low too low or too high
26102610 let alpha_low_too_low = 0_u16 ;
26112611 assert_err ! (
2612- SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low_too_low, alpha_high) ,
2613- Error :: <Test >:: AlphaLowTooLow
2612+ SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low_too_low, alpha_high) ,
2613+ Error :: <Test >:: AlphaLowOutOfRange
26142614 ) ;
26152615 // Correct scenario after error
2616- assert_ok ! ( SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
2616+ assert_ok ! ( SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
26172617
26182618 let alpha_low_too_high = ( u16:: MAX as u32 * 4 / 5 ) as u16 + 1 ; // One more than the maximum acceptable value
26192619 assert_err ! (
2620- SubtensorModule :: set_alpha_values ( signer. clone( ) , netuid, alpha_low_too_high, alpha_high) ,
2621- Error :: <Test >:: AlphaLowTooLow
2620+ SubtensorModule :: do_set_alpha_values ( signer. clone( ) , netuid, alpha_low_too_high, alpha_high) ,
2621+ Error :: <Test >:: AlphaLowOutOfRange
26222622 ) ;
26232623 // Correct scenario after error
2624- assert_ok ! ( SubtensorModule :: set_alpha_values( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
2625- } ) ;
2626- }
2627-
2628- #[ test]
2629- fn test_set_alpha_values_dispatch_info_ok ( ) {
2630- new_test_ext ( 0 ) . execute_with ( || {
2631- let netuid: u16 = 1 ;
2632- let alpha_low: u16 = 12_u16 ;
2633- let alpha_high: u16 = u16:: MAX - 10 ;
2634- let call = RuntimeCall :: SubtensorModule ( SubtensorCall :: set_alpha_values {
2635- netuid,
2636- alpha_low,
2637- alpha_high,
2638- } ) ;
2639- let dispatch_info = call. get_dispatch_info ( ) ;
2640-
2641- assert_eq ! ( dispatch_info. class, DispatchClass :: Operational ) ;
2642- assert_eq ! ( dispatch_info. pays_fee, Pays :: No ) ;
2624+ assert_ok ! ( SubtensorModule :: do_set_alpha_values( signer. clone( ) , netuid, alpha_low, alpha_high) ) ;
26432625 } ) ;
26442626}
26452627
0 commit comments