@@ -3160,7 +3160,6 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_success() {
31603160
31613161 assert_ok ! ( SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
31623162 current_coldkey,
3163- hotkey,
31643163 new_coldkey
31653164 ) ) ;
31663165
@@ -3175,59 +3174,21 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_success() {
31753174 Event :: AllBalanceUnstakedAndTransferredToNewColdkey {
31763175 current_coldkey,
31773176 new_coldkey,
3178- hotkey,
3179- current_stake : 500 ,
31803177 total_balance : 1000 ,
31813178 }
31823179 . into ( ) ,
31833180 ) ;
31843181 } ) ;
31853182}
31863183
3187- #[ test]
3188- fn test_do_unstake_all_and_transfer_to_new_coldkey_hotkey_not_exists ( ) {
3189- new_test_ext ( 1 ) . execute_with ( || {
3190- let current_coldkey = U256 :: from ( 1 ) ;
3191- let hotkey = U256 :: from ( 2 ) ;
3192- let new_coldkey = U256 :: from ( 3 ) ;
3193-
3194- assert_err ! (
3195- SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
3196- current_coldkey,
3197- hotkey,
3198- new_coldkey
3199- ) ,
3200- Error :: <Test >:: HotKeyAccountNotExists
3201- ) ;
3202- } ) ;
3203- }
3204-
3205- #[ test]
3206- fn test_do_unstake_all_and_transfer_to_new_coldkey_non_associated_coldkey ( ) {
3207- new_test_ext ( 1 ) . execute_with ( || {
3208- let ( _, hotkey, new_coldkey) = setup_test_environment ( ) ;
3209- let wrong_coldkey = U256 :: from ( 4 ) ;
3210-
3211- assert_noop ! (
3212- SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
3213- wrong_coldkey,
3214- hotkey,
3215- new_coldkey
3216- ) ,
3217- Error :: <Test >:: NonAssociatedColdKey
3218- ) ;
3219- } ) ;
3220- }
3221-
32223184#[ test]
32233185fn test_do_unstake_all_and_transfer_to_new_coldkey_same_coldkey ( ) {
32243186 new_test_ext ( 1 ) . execute_with ( || {
3225- let ( current_coldkey, hotkey , _) = setup_test_environment ( ) ;
3187+ let ( current_coldkey, _hotkey , _) = setup_test_environment ( ) ;
32263188
32273189 assert_noop ! (
32283190 SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
32293191 current_coldkey,
3230- hotkey,
32313192 current_coldkey
32323193 ) ,
32333194 Error :: <Test >:: SameColdkey
@@ -3270,7 +3231,6 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_no_balance() {
32703231 // Try to unstake and transfer
32713232 let result = SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey (
32723233 current_coldkey,
3273- hotkey,
32743234 new_coldkey,
32753235 ) ;
32763236
@@ -3343,7 +3303,6 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_with_no_stake() {
33433303 // Perform unstake and transfer
33443304 assert_ok ! ( SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
33453305 current_coldkey,
3346- hotkey,
33473306 new_coldkey
33483307 ) ) ;
33493308
@@ -3370,8 +3329,6 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_with_no_stake() {
33703329 Event :: AllBalanceUnstakedAndTransferredToNewColdkey {
33713330 current_coldkey,
33723331 new_coldkey,
3373- hotkey,
3374- current_stake : 0 ,
33753332 total_balance : initial_balance,
33763333 }
33773334 . into ( ) ,
@@ -3394,7 +3351,6 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_with_multiple_stakes() {
33943351
33953352 assert_ok ! ( SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
33963353 current_coldkey,
3397- hotkey,
33983354 new_coldkey
33993355 ) ) ;
34003356
@@ -3409,8 +3365,48 @@ fn test_do_unstake_all_and_transfer_to_new_coldkey_with_multiple_stakes() {
34093365 Event :: AllBalanceUnstakedAndTransferredToNewColdkey {
34103366 current_coldkey,
34113367 new_coldkey,
3412- hotkey,
3413- current_stake : 800 ,
3368+ total_balance : 1000 ,
3369+ }
3370+ . into ( ) ,
3371+ ) ;
3372+ } ) ;
3373+ }
3374+
3375+ #[ test]
3376+ fn test_do_unstake_all_and_transfer_to_new_coldkey_with_multiple_stakes_multiple ( ) {
3377+ new_test_ext ( 1 ) . execute_with ( || {
3378+ // Register the neuron to a new network
3379+ let netuid = 1 ;
3380+ let hotkey0 = U256 :: from ( 1 ) ;
3381+ let hotkey2 = U256 :: from ( 2 ) ;
3382+ let current_coldkey = U256 :: from ( 3 ) ;
3383+ let new_coldkey = U256 :: from ( 4 ) ;
3384+ add_network ( netuid, 0 , 0 ) ;
3385+ register_ok_neuron ( 1 , hotkey0, current_coldkey, 0 ) ;
3386+ register_ok_neuron ( 1 , hotkey2, current_coldkey, 0 ) ;
3387+ SubtensorModule :: set_target_stakes_per_interval ( 10 ) ;
3388+ SubtensorModule :: add_balance_to_coldkey_account ( & current_coldkey, 1000 ) ;
3389+ assert_ok ! ( SubtensorModule :: add_stake(
3390+ RuntimeOrigin :: signed( current_coldkey) ,
3391+ hotkey0,
3392+ 500
3393+ ) ) ;
3394+ assert_ok ! ( SubtensorModule :: add_stake(
3395+ RuntimeOrigin :: signed( current_coldkey) ,
3396+ hotkey2,
3397+ 300
3398+ ) ) ;
3399+ assert_ok ! ( SubtensorModule :: do_unstake_all_and_transfer_to_new_coldkey(
3400+ current_coldkey,
3401+ new_coldkey
3402+ ) ) ;
3403+ assert_eq ! ( SubtensorModule :: get_total_stake_for_hotkey( & hotkey0) , 0 ) ;
3404+ assert_eq ! ( SubtensorModule :: get_total_stake_for_hotkey( & hotkey2) , 0 ) ;
3405+ assert_eq ! ( SubtensorModule :: get_coldkey_balance( & new_coldkey) , 1000 ) ;
3406+ System :: assert_last_event (
3407+ Event :: AllBalanceUnstakedAndTransferredToNewColdkey {
3408+ current_coldkey,
3409+ new_coldkey,
34143410 total_balance : 1000 ,
34153411 }
34163412 . into ( ) ,
0 commit comments