@@ -1841,7 +1841,10 @@ fn test_get_stake_for_hotkey_on_subnet_single_parent_child() {
1841
1841
register_ok_neuron ( netuid, child, coldkey, 0 ) ;
1842
1842
1843
1843
SubtensorModule :: increase_stake_for_hotkey_and_coldkey_on_subnet (
1844
- & parent, & coldkey, netuid, 1_000_000_000 ,
1844
+ & parent,
1845
+ & coldkey,
1846
+ netuid,
1847
+ 1_000_000_000 ,
1845
1848
) ;
1846
1849
1847
1850
mock_set_children_no_epochs ( netuid, & parent, & [ ( u64:: MAX , child) ] ) ;
@@ -2013,11 +2016,7 @@ fn test_get_stake_for_hotkey_on_subnet_edge_cases() {
2013
2016
) ;
2014
2017
2015
2018
// Test with 0% and 100% stake allocation
2016
- mock_set_children_no_epochs (
2017
- netuid,
2018
- & parent,
2019
- & [ ( 0 , child1) , ( u64:: MAX , child2) ] ,
2020
- ) ;
2019
+ mock_set_children_no_epochs ( netuid, & parent, & [ ( 0 , child1) , ( u64:: MAX , child2) ] ) ;
2021
2020
2022
2021
let parent_stake = SubtensorModule :: get_inherited_for_hotkey_on_subnet ( & parent, netuid) ;
2023
2022
let child1_stake = SubtensorModule :: get_inherited_for_hotkey_on_subnet ( & child1, netuid) ;
@@ -2709,8 +2708,10 @@ fn test_set_children_rate_limit_fail_then_succeed() {
2709
2708
#[ test]
2710
2709
fn test_childkey_set_weights_single_parent ( ) {
2711
2710
new_test_ext ( 1 ) . execute_with ( || {
2712
- let netuid: u16 = 1 ;
2713
- add_network ( netuid, 1 , 0 ) ;
2711
+ let subnet_owner_coldkey = U256 :: from ( 1001 ) ;
2712
+ let subnet_owner_hotkey = U256 :: from ( 1002 ) ;
2713
+ let netuid: u16 = add_dynamic_network ( & subnet_owner_hotkey, & subnet_owner_coldkey) ;
2714
+ Tempo :: < Test > :: insert ( netuid, 1 ) ;
2714
2715
2715
2716
// Define hotkeys
2716
2717
let parent: U256 = U256 :: from ( 1 ) ;
@@ -2750,14 +2751,14 @@ fn test_childkey_set_weights_single_parent() {
2750
2751
SubtensorModule :: set_weights_set_rate_limit ( netuid, 0 ) ;
2751
2752
2752
2753
// Set parent-child relationship
2753
- mock_set_children ( & coldkey_parent , & parent, netuid , & [ ( u64:: MAX , child) ] ) ;
2754
+ mock_set_children_no_epochs ( netuid , & parent, & [ ( u64:: MAX , child) ] ) ;
2754
2755
2755
- step_block ( 7200 + 1 ) ;
2756
2756
// Set weights on the child using the weight_setter account
2757
2757
let origin = RuntimeOrigin :: signed ( weight_setter) ;
2758
2758
let uids: Vec < u16 > = vec ! [ 1 ] ; // Only set weight for the child (UID 1)
2759
2759
let values: Vec < u16 > = vec ! [ u16 :: MAX ] ; // Use maximum value for u16
2760
2760
let version_key = SubtensorModule :: get_weights_version_key ( netuid) ;
2761
+ ValidatorPermit :: < Test > :: insert ( netuid, vec ! [ true , true , true , true ] ) ;
2761
2762
assert_ok ! ( SubtensorModule :: set_weights(
2762
2763
origin,
2763
2764
netuid,
@@ -3191,15 +3192,9 @@ fn test_parent_child_chain_emission() {
3191
3192
log:: info!( "rel_stake_a: {:?}" , rel_stake_a) ; // 0.6666 -> 2/3
3192
3193
log:: info!( "rel_stake_b: {:?}" , rel_stake_b) ; // 0.2222 -> 2/9
3193
3194
log:: info!( "rel_stake_c: {:?}" , rel_stake_c) ; // 0.1111 -> 1/9
3194
- assert ! (
3195
- ( rel_stake_a - I96F32 :: from_num( stake_a) / total_tao) . abs( ) < 0.001
3196
- ) ;
3197
- assert ! (
3198
- ( rel_stake_b - I96F32 :: from_num( stake_b) / total_tao) . abs( ) < 0.001
3199
- ) ;
3200
- assert ! (
3201
- ( rel_stake_c - I96F32 :: from_num( stake_c) / total_tao) . abs( ) < 0.001
3202
- ) ;
3195
+ assert ! ( ( rel_stake_a - I96F32 :: from_num( stake_a) / total_tao) . abs( ) < 0.001 ) ;
3196
+ assert ! ( ( rel_stake_b - I96F32 :: from_num( stake_b) / total_tao) . abs( ) < 0.001 ) ;
3197
+ assert ! ( ( rel_stake_c - I96F32 :: from_num( stake_c) / total_tao) . abs( ) < 0.001 ) ;
3203
3198
3204
3199
// Set parent-child relationships
3205
3200
// A -> B (50% of A's stake)
@@ -3228,13 +3223,13 @@ fn test_parent_child_chain_emission() {
3228
3223
// Set the weight of root TAO to be 0%, so only alpha is effective.
3229
3224
SubtensorModule :: set_tao_weight ( 0 ) ;
3230
3225
3231
- let hardcoded_emission : I96F32 = I96F32 :: from_num ( 1_000_000 ) ; // 1 million (adjust as needed)
3226
+ let emission : I96F32 = I96F32 :: from_num ( SubtensorModule :: get_block_emission ( ) . unwrap_or ( 0 ) ) ;
3232
3227
3233
3228
// Set pending emission to 0
3234
3229
PendingEmission :: < Test > :: insert ( netuid, 0 ) ;
3235
3230
3236
- // Run epoch with a hardcoded emission value
3237
- SubtensorModule :: run_coinbase ( hardcoded_emission ) ;
3231
+ // Run epoch with emission value
3232
+ SubtensorModule :: run_coinbase ( emission ) ;
3238
3233
3239
3234
// Log new stake
3240
3235
let stake_a_new: u64 = SubtensorModule :: get_total_stake_for_hotkey ( & hotkey_a) ;
@@ -3262,7 +3257,7 @@ fn test_parent_child_chain_emission() {
3262
3257
3263
3258
// Verify the final stake distribution
3264
3259
let stake_inc_eps: I96F32 = I96F32 :: from_num ( 1e-4 ) ; // 4 decimal places
3265
-
3260
+
3266
3261
// Each child has chk_take take
3267
3262
let expected_a = I96F32 :: from_num ( 2_f64 / 3_f64 )
3268
3263
* ( I96F32 :: from_num ( 1_f64 ) - ( I96F32 :: from_num ( 1_f64 / 2_f64 ) * chk_take) ) ;
@@ -3315,8 +3310,8 @@ fn test_parent_child_chain_emission() {
3315
3310
3316
3311
assert_abs_diff_eq ! (
3317
3312
total_stake_inc. to_num:: <u64 >( ) ,
3318
- hardcoded_emission . to_num:: <u64 >( ) ,
3319
- epsilon = 10_000 ,
3313
+ emission . to_num:: <u64 >( ) ,
3314
+ epsilon = emission . to_num :: < u64 > ( ) / 1000 ,
3320
3315
) ;
3321
3316
} ) ;
3322
3317
}
0 commit comments