@@ -2773,6 +2773,61 @@ fn test_blocks_since_last_step() {
2773
2773
} ) ;
2774
2774
}
2775
2775
2776
+ #[ test]
2777
+ fn test_can_set_self_weight_as_subnet_owner ( ) {
2778
+ new_test_ext ( 1 ) . execute_with ( || {
2779
+ let subnet_owner_coldkey: U256 = U256 :: from ( 1 ) ;
2780
+ let subnet_owner_hotkey: U256 = U256 :: from ( 1 + 456 ) ;
2781
+
2782
+ let other_hotkey: U256 = U256 :: from ( 2 ) ;
2783
+
2784
+ let stake = 5_000_000_000_000 ; // 5k TAO
2785
+ let to_emit: u64 = 1_000_000_000 ; // 1 TAO
2786
+
2787
+ // Create subnet
2788
+ let netuid = add_dynamic_network ( & subnet_owner_hotkey, & subnet_owner_coldkey) ;
2789
+
2790
+ // Register the other hotkey
2791
+ register_ok_neuron ( netuid, other_hotkey, subnet_owner_coldkey, 0 ) ;
2792
+
2793
+ // Add stake to owner hotkey.
2794
+ SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
2795
+ & subnet_owner_hotkey,
2796
+ & subnet_owner_coldkey,
2797
+ netuid,
2798
+ stake,
2799
+ ) ;
2800
+
2801
+ // Give vpermits to owner hotkey ONLY
2802
+ ValidatorPermit :: < Test > :: insert ( netuid, vec ! [ true , false ] ) ;
2803
+
2804
+ // Set weight of 50% to each hotkey.
2805
+ // This includes a self-weight
2806
+ let fifty_percent: u16 = u16:: MAX / 2 ;
2807
+ Weights :: < Test > :: insert ( netuid, 0 , vec ! [ ( 0 , fifty_percent) , ( 1 , fifty_percent) ] ) ;
2808
+
2809
+ step_block ( 1 ) ;
2810
+ // Set updated so weights are valid
2811
+ LastUpdate :: < Test > :: insert ( netuid, vec ! [ 2 , 0 ] ) ;
2812
+
2813
+ // Run epoch
2814
+ let hotkey_emission: Vec < ( U256 , u64 , u64 ) > = SubtensorModule :: epoch ( netuid, to_emit) ;
2815
+
2816
+ // hotkey_emission is [(hotkey, incentive, dividend)]
2817
+ assert_eq ! ( hotkey_emission. len( ) , 2 ) ;
2818
+ assert_eq ! ( hotkey_emission[ 0 ] . 0 , subnet_owner_hotkey) ;
2819
+ assert_eq ! ( hotkey_emission[ 1 ] . 0 , other_hotkey) ;
2820
+
2821
+ log:: debug!( "hotkey_emission: {:?}" , hotkey_emission) ;
2822
+ // Both should have received incentive emission
2823
+ assert ! ( hotkey_emission[ 0 ] . 1 > 0 ) ;
2824
+ assert ! ( hotkey_emission[ 1 ] . 1 > 0 ) ;
2825
+
2826
+ // Their incentive should be equal
2827
+ assert_eq ! ( hotkey_emission[ 0 ] . 1 , hotkey_emission[ 1 ] . 1 ) ;
2828
+ } ) ;
2829
+ }
2830
+
2776
2831
// Map the retention graph for consensus guarantees with an single epoch on a graph with 512 nodes,
2777
2832
// of which the first 64 are validators, the graph is split into a major and minor set, each setting
2778
2833
// specific weight on itself and the complement on the other.
0 commit comments