@@ -2311,7 +2311,10 @@ fn test_remove_stake_fee_realistic_values() {
23112311 ) ;
23122312
23132313 // Estimate fees
2314- let expected_fee: f64 = current_price * alpha_divs as f64 ;
2314+ let mut expected_fee: f64 = current_price * alpha_divs as f64 ;
2315+ if expected_fee < alpha_to_unstake as f64 * 0.00005 {
2316+ expected_fee = alpha_to_unstake as f64 * 0.00005 ;
2317+ }
23152318
23162319 // Remove stake to measure fee
23172320 let balance_before = SubtensorModule :: get_coldkey_balance ( & coldkey) ;
@@ -3903,7 +3906,7 @@ fn test_remove_99_9991_per_cent_stake_removes_all() {
39033906 let coldkey_account_id = U256 :: from ( 81337 ) ;
39043907 let amount = 10_000_000_000 ;
39053908 let netuid: u16 = add_dynamic_network ( & subnet_owner_hotkey, & subnet_owner_coldkey) ;
3906- let fee = DefaultStakingFee :: < Test > :: get ( ) ;
3909+ let mut fee = DefaultStakingFee :: < Test > :: get ( ) ;
39073910 register_ok_neuron ( netuid, hotkey_account_id, coldkey_account_id, 192213123 ) ;
39083911
39093912 // Give it some $$$ in his coldkey balance
@@ -3923,17 +3926,19 @@ fn test_remove_99_9991_per_cent_stake_removes_all() {
39233926 & coldkey_account_id,
39243927 netuid,
39253928 ) ;
3929+ let remove_amount = ( U64F64 :: from_num ( alpha) * U64F64 :: from_num ( 0.999991 ) ) . to_num :: < u64 > ( ) ;
39263930 assert_ok ! ( SubtensorModule :: remove_stake(
39273931 RuntimeOrigin :: signed( coldkey_account_id) ,
39283932 hotkey_account_id,
39293933 netuid,
3930- ( U64F64 :: from_num ( alpha ) * U64F64 :: from_num ( 0.999991 ) ) . to_num :: < u64 > ( )
3934+ remove_amount ,
39313935 ) ) ;
39323936
39333937 // Check that all alpha was unstaked and all TAO balance was returned (less fees)
3938+ fee = fee + fee. max ( ( remove_amount as f64 * 0.00005 ) as u64 ) ;
39343939 assert_abs_diff_eq ! (
39353940 SubtensorModule :: get_coldkey_balance( & coldkey_account_id) ,
3936- amount - fee * 2 ,
3941+ amount - fee,
39373942 epsilon = 10000 ,
39383943 ) ;
39393944 assert_eq ! (
0 commit comments