@@ -74,7 +74,6 @@ fn test_remove_stake_fees_tao() {
7474
7575// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_fees_alpha --exact --show-output
7676#[ test]
77- #[ ignore]
7877fn test_remove_stake_fees_alpha ( ) {
7978 new_test_ext ( ) . execute_with ( || {
8079 let stake_amount = TAO ;
@@ -143,7 +142,6 @@ fn test_remove_stake_fees_alpha() {
143142//
144143// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_root --exact --show-output
145144#[ test]
146- #[ ignore]
147145fn test_remove_stake_root ( ) {
148146 new_test_ext ( ) . execute_with ( || {
149147 let stake_amount = TAO ;
@@ -202,7 +200,6 @@ fn test_remove_stake_root() {
202200//
203201// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_completely_root --exact --show-output
204202#[ test]
205- #[ ignore]
206203fn test_remove_stake_completely_root ( ) {
207204 new_test_ext ( ) . execute_with ( || {
208205 let stake_amount = TAO ;
@@ -254,7 +251,6 @@ fn test_remove_stake_completely_root() {
254251
255252// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_completely_fees_alpha --exact --show-output
256253#[ test]
257- #[ ignore]
258254fn test_remove_stake_completely_fees_alpha ( ) {
259255 new_test_ext ( ) . execute_with ( || {
260256 let stake_amount = TAO ;
@@ -385,7 +381,6 @@ fn test_remove_stake_not_enough_balance_for_fees() {
385381//
386382// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_edge_alpha --exact --show-output
387383#[ test]
388- #[ ignore]
389384fn test_remove_stake_edge_alpha ( ) {
390385 new_test_ext ( ) . execute_with ( || {
391386 let stake_amount = TAO ;
@@ -524,7 +519,6 @@ fn test_remove_stake_failing_transaction_tao_fees() {
524519//
525520// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_failing_transaction_alpha_fees --exact --show-output
526521#[ test]
527- #[ ignore]
528522fn test_remove_stake_failing_transaction_alpha_fees ( ) {
529523 new_test_ext ( ) . execute_with ( || {
530524 let stake_amount = TAO ;
@@ -590,7 +584,6 @@ fn test_remove_stake_failing_transaction_alpha_fees() {
590584
591585// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_limit_fees_alpha --exact --show-output
592586#[ test]
593- #[ ignore]
594587fn test_remove_stake_limit_fees_alpha ( ) {
595588 new_test_ext ( ) . execute_with ( || {
596589 let stake_amount = TAO ;
@@ -658,7 +651,6 @@ fn test_remove_stake_limit_fees_alpha() {
658651
659652// cargo test --package subtensor-transaction-fee --lib -- tests::test_unstake_all_fees_alpha --exact --show-output
660653#[ test]
661- #[ ignore]
662654fn test_unstake_all_fees_alpha ( ) {
663655 new_test_ext ( ) . execute_with ( || {
664656 let stake_amount = TAO ;
@@ -731,7 +723,6 @@ fn test_unstake_all_fees_alpha() {
731723
732724// cargo test --package subtensor-transaction-fee --lib -- tests::test_unstake_all_alpha_fees_alpha --exact --show-output
733725#[ test]
734- #[ ignore]
735726fn test_unstake_all_alpha_fees_alpha ( ) {
736727 new_test_ext ( ) . execute_with ( || {
737728 let stake_amount = TAO ;
@@ -799,7 +790,6 @@ fn test_unstake_all_alpha_fees_alpha() {
799790
800791// cargo test --package subtensor-transaction-fee --lib -- tests::test_move_stake_fees_alpha --exact --show-output
801792#[ test]
802- #[ ignore]
803793fn test_move_stake_fees_alpha ( ) {
804794 new_test_ext ( ) . execute_with ( || {
805795 let stake_amount = TAO ;
@@ -871,7 +861,6 @@ fn test_move_stake_fees_alpha() {
871861
872862// cargo test --package subtensor-transaction-fee --lib -- tests::test_transfer_stake_fees_alpha --exact --show-output
873863#[ test]
874- #[ ignore]
875864fn test_transfer_stake_fees_alpha ( ) {
876865 new_test_ext ( ) . execute_with ( || {
877866 let destination_coldkey = U256 :: from ( 100000 ) ;
@@ -944,7 +933,6 @@ fn test_transfer_stake_fees_alpha() {
944933
945934// cargo test --package subtensor-transaction-fee --lib -- tests::test_swap_stake_fees_alpha --exact --show-output
946935#[ test]
947- #[ ignore]
948936fn test_swap_stake_fees_alpha ( ) {
949937 new_test_ext ( ) . execute_with ( || {
950938 let stake_amount = TAO ;
@@ -1015,7 +1003,6 @@ fn test_swap_stake_fees_alpha() {
10151003
10161004// cargo test --package subtensor-transaction-fee --lib -- tests::test_swap_stake_limit_fees_alpha --exact --show-output
10171005#[ test]
1018- #[ ignore]
10191006fn test_swap_stake_limit_fees_alpha ( ) {
10201007 new_test_ext ( ) . execute_with ( || {
10211008 let stake_amount = TAO ;
@@ -1088,7 +1075,6 @@ fn test_swap_stake_limit_fees_alpha() {
10881075
10891076// cargo test --package subtensor-transaction-fee --lib -- tests::test_burn_alpha_fees_alpha --exact --show-output
10901077#[ test]
1091- #[ ignore]
10921078fn test_burn_alpha_fees_alpha ( ) {
10931079 new_test_ext ( ) . execute_with ( || {
10941080 let stake_amount = TAO ;
@@ -1150,7 +1136,6 @@ fn test_burn_alpha_fees_alpha() {
11501136
11511137// cargo test --package subtensor-transaction-fee --lib -- tests::test_recycle_alpha_fees_alpha --exact --show-output
11521138#[ test]
1153- #[ ignore]
11541139fn test_recycle_alpha_fees_alpha ( ) {
11551140 new_test_ext ( ) . execute_with ( || {
11561141 let stake_amount = TAO ;
@@ -1209,3 +1194,77 @@ fn test_recycle_alpha_fees_alpha() {
12091194 assert ! ( actual_alpha_fee > 0 . into( ) ) ;
12101195 } ) ;
12111196}
1197+
1198+ #[ test]
1199+ fn test_remove_stake_alpha_clears_stake_pool_entry ( ) {
1200+ new_test_ext ( ) . execute_with ( || {
1201+ let stake_amount = TAO ;
1202+ let unstake_amount = AlphaCurrency :: from ( TAO / 50 ) ;
1203+ let sn = setup_subnets ( 1 , 1 ) ;
1204+ setup_stake (
1205+ sn. subnets [ 0 ] . netuid ,
1206+ & sn. coldkey ,
1207+ & sn. hotkeys [ 0 ] ,
1208+ stake_amount,
1209+ ) ;
1210+
1211+ // Force-set signer balance to ED
1212+ let current_balance = Balances :: free_balance ( sn. coldkey ) ;
1213+ let _ = SubtensorModule :: remove_balance_from_coldkey_account (
1214+ & sn. coldkey ,
1215+ current_balance - ExistentialDeposit :: get ( ) ,
1216+ ) ;
1217+
1218+ // Modify the alpha pool denominator so it's low-precision, coldkey still have 100% of the stake
1219+ let denominator = U64F64 :: from_num ( 0.0000001 ) ;
1220+ TotalHotkeyShares :: < Test > :: insert ( sn. hotkeys [ 0 ] , sn. subnets [ 0 ] . netuid , denominator) ;
1221+ Alpha :: < Test > :: insert (
1222+ ( & sn. hotkeys [ 0 ] , & sn. coldkey , sn. subnets [ 0 ] . netuid ) ,
1223+ denominator,
1224+ ) ;
1225+
1226+ // Remove stake limit
1227+ let balance_before = Balances :: free_balance ( sn. coldkey ) ;
1228+ let alpha_before = SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet (
1229+ & sn. hotkeys [ 0 ] ,
1230+ & sn. coldkey ,
1231+ sn. subnets [ 0 ] . netuid ,
1232+ ) ;
1233+ let call = RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: remove_stake_limit {
1234+ hotkey : sn. hotkeys [ 0 ] ,
1235+ netuid : sn. subnets [ 0 ] . netuid ,
1236+ amount_unstaked : unstake_amount,
1237+ limit_price : 1_000 . into ( ) ,
1238+ allow_partial : false ,
1239+ } ) ;
1240+
1241+ // Dispatch the extrinsic with ChargeTransactionPayment extension
1242+ let info = call. get_dispatch_info ( ) ;
1243+ let ext = pallet_transaction_payment:: ChargeTransactionPayment :: < Test > :: from ( 0 ) ;
1244+ let result = ext. validate (
1245+ RuntimeOrigin :: signed ( sn. coldkey ) . into ( ) ,
1246+ & call. clone ( ) ,
1247+ & info,
1248+ 10 ,
1249+ ( ) ,
1250+ & TxBaseImplication ( ( ) ) ,
1251+ TransactionSource :: External ,
1252+ ) ;
1253+
1254+ assert_eq ! (
1255+ result. unwrap_err( ) ,
1256+ TransactionValidityError :: Invalid ( InvalidTransaction :: Payment )
1257+ ) ;
1258+
1259+ // Nothing changes, because it fails validation
1260+ let final_balance = Balances :: free_balance ( sn. coldkey ) ;
1261+ let alpha_after = SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet (
1262+ & sn. hotkeys [ 0 ] ,
1263+ & sn. coldkey ,
1264+ sn. subnets [ 0 ] . netuid ,
1265+ ) ;
1266+
1267+ assert_eq ! ( alpha_after, alpha_before) ;
1268+ assert_eq ! ( final_balance, balance_before) ;
1269+ } ) ;
1270+ }
0 commit comments