@@ -2737,83 +2737,82 @@ fn test_childkey_set_weights_single_parent() {
2737
2737
fn test_set_weights_no_parent ( ) {
2738
2738
// Verify that a regular key without a parent delegation is effected by the minimum stake requirements
2739
2739
new_test_ext ( 1 ) . execute_with ( || {
2740
- assert ! ( false ) ;
2740
+ let netuid: u16 = 1 ;
2741
+ add_network ( netuid, 1 , 0 ) ;
2741
2742
2742
- // let netuid: u16 = 1 ;
2743
- // add_network(netuid, 1, 0 );
2743
+ let hotkey : U256 = U256 :: from ( 2 ) ;
2744
+ let spare_hk : U256 = U256 :: from ( 3 ) ;
2744
2745
2745
- // let hotkey : U256 = U256::from(2 );
2746
- // let spare_hk: U256 = U256::from(3 );
2746
+ let coldkey : U256 = U256 :: from ( 101 ) ;
2747
+ let spare_ck = U256 :: from ( 102 ) ;
2747
2748
2748
- // let coldkey: U256 = U256::from(101);
2749
- // let spare_ck = U256::from(102);
2749
+ let stake_to_give_child = 109_999 ;
2750
2750
2751
- // let stake_to_give_child = 109_999 ;
2751
+ SubtensorModule :: add_balance_to_coldkey_account ( & coldkey , stake_to_give_child + 10 ) ;
2752
2752
2753
- // SubtensorModule::add_balance_to_coldkey_account(&coldkey, stake_to_give_child + 10);
2753
+ // Is registered
2754
+ register_ok_neuron ( netuid, hotkey, coldkey, 1 ) ;
2755
+ // Register a spare key
2756
+ register_ok_neuron ( netuid, spare_hk, spare_ck, 1 ) ;
2754
2757
2755
- // // Is registered
2756
- // register_ok_neuron(netuid, hotkey, coldkey, 1);
2757
- // // Register a spare key
2758
- // register_ok_neuron(netuid, spare_hk, spare_ck, 1);
2758
+ SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
2759
+ & hotkey,
2760
+ & coldkey,
2761
+ netuid,
2762
+ stake_to_give_child,
2763
+ ) ;
2759
2764
2760
- // SubtensorModule::increase_stake_on_coldkey_hotkey_account(
2761
- // &coldkey,
2762
- // &hotkey,
2763
- // stake_to_give_child,
2764
- // );
2765
+ SubtensorModule :: set_weights_set_rate_limit ( netuid, 0 ) ;
2765
2766
2766
- // SubtensorModule::set_weights_set_rate_limit(netuid, 0);
2767
+ // Has stake and no parent
2768
+ step_block ( 7200 + 1 ) ;
2767
2769
2768
- // // Has stake and no parent
2769
- // step_block(7200 + 1);
2770
+ let uids: Vec < u16 > = vec ! [ 1 ] ; // Set weights on the other hotkey
2771
+ let values: Vec < u16 > = vec ! [ u16 :: MAX ] ; // Use maximum value for u16
2772
+ let version_key = SubtensorModule :: get_weights_version_key ( netuid) ;
2770
2773
2771
- // let uids: Vec<u16> = vec![1]; // Set weights on the other hotkey
2772
- // let values: Vec<u16> = vec![u16::MAX]; // Use maximum value for u16
2773
- // let version_key = SubtensorModule::get_weights_version_key(netuid);
2774
+ // Set the min stake very high
2775
+ SubtensorModule :: set_stake_threshold ( stake_to_give_child * 5 ) ;
2774
2776
2775
- // // Set the min stake very high
2776
- // SubtensorModule::set_stake_threshold(stake_to_give_child * 5);
2777
-
2778
- // // Check the key has less stake than required
2779
- // assert!(
2780
- // SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid)
2781
- // < SubtensorModule::get_stake_threshold()
2782
- // );
2777
+ // Check the key has less stake than required
2778
+ assert ! (
2779
+ SubtensorModule :: get_stake_for_hotkey_on_subnet( & hotkey, netuid)
2780
+ < SubtensorModule :: get_stake_threshold( )
2781
+ ) ;
2783
2782
2784
- // // Check the hotkey cannot set weights
2785
- // assert_noop!(
2786
- // SubtensorModule::set_weights(
2787
- // RuntimeOrigin::signed(hotkey),
2788
- // netuid,
2789
- // uids.clone(),
2790
- // values.clone(),
2791
- // version_key
2792
- // ),
2793
- // Error::<Test>::NotEnoughStakeToSetWeights
2794
- // );
2783
+ // Check the hotkey cannot set weights
2784
+ assert_noop ! (
2785
+ SubtensorModule :: set_weights(
2786
+ RuntimeOrigin :: signed( hotkey) ,
2787
+ netuid,
2788
+ uids. clone( ) ,
2789
+ values. clone( ) ,
2790
+ version_key
2791
+ ) ,
2792
+ Error :: <Test >:: NotEnoughStakeToSetWeights
2793
+ ) ;
2795
2794
2796
- // assert!(!SubtensorModule::check_weights_min_stake(&hotkey, netuid));
2795
+ assert ! ( !SubtensorModule :: check_weights_min_stake( & hotkey, netuid) ) ;
2797
2796
2798
- // // Set a minimum stake to set weights
2799
- // SubtensorModule::set_stake_threshold(stake_to_give_child - 5);
2797
+ // Set a minimum stake to set weights
2798
+ SubtensorModule :: set_stake_threshold ( stake_to_give_child - 5 ) ;
2800
2799
2801
- // // Check if the stake for the hotkey is above
2802
- // assert!(
2803
- // SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid)
2804
- // >= SubtensorModule::get_stake_threshold()
2805
- // );
2800
+ // Check if the stake for the hotkey is above
2801
+ assert ! (
2802
+ SubtensorModule :: get_stake_for_hotkey_on_subnet( & hotkey, netuid)
2803
+ >= SubtensorModule :: get_stake_threshold( )
2804
+ ) ;
2806
2805
2807
- // // Check the hotkey can set weights
2808
- // assert_ok!(SubtensorModule::set_weights(
2809
- // RuntimeOrigin::signed(hotkey),
2810
- // netuid,
2811
- // uids,
2812
- // values,
2813
- // version_key
2814
- // ));
2806
+ // Check the hotkey can set weights
2807
+ assert_ok ! ( SubtensorModule :: set_weights(
2808
+ RuntimeOrigin :: signed( hotkey) ,
2809
+ netuid,
2810
+ uids,
2811
+ values,
2812
+ version_key
2813
+ ) ) ;
2815
2814
2816
- // assert!(SubtensorModule::check_weights_min_stake(&hotkey, netuid));
2815
+ assert ! ( SubtensorModule :: check_weights_min_stake( & hotkey, netuid) ) ;
2817
2816
} ) ;
2818
2817
}
2819
2818
0 commit comments