@@ -541,7 +541,7 @@ fn test_do_move_wrong_origin() {
541
541
netuid,
542
542
alpha,
543
543
) ,
544
- Error :: <Test >:: NonAssociatedColdKey
544
+ Error :: <Test >:: NotEnoughStakeToWithdraw
545
545
) ;
546
546
547
547
// Check that no stake was moved
@@ -981,7 +981,7 @@ fn test_do_transfer_wrong_origin() {
981
981
netuid,
982
982
stake_amount
983
983
) ,
984
- Error :: <Test >:: NonAssociatedColdKey
984
+ Error :: <Test >:: NotEnoughStakeToWithdraw
985
985
) ;
986
986
} ) ;
987
987
}
@@ -1245,7 +1245,7 @@ fn test_do_swap_wrong_origin() {
1245
1245
netuid2,
1246
1246
stake_amount
1247
1247
) ,
1248
- Error :: <Test >:: NonAssociatedColdKey
1248
+ Error :: <Test >:: NotEnoughStakeToWithdraw
1249
1249
) ;
1250
1250
} ) ;
1251
1251
}
@@ -1486,6 +1486,38 @@ fn test_do_swap_multiple_times() {
1486
1486
} ) ;
1487
1487
}
1488
1488
1489
+ // cargo test --package pallet-subtensor --lib -- tests::move_stake::test_do_swap_allows_non_owned_hotkey --exact --show-output
1490
+ #[ test]
1491
+ fn test_do_swap_allows_non_owned_hotkey ( ) {
1492
+ new_test_ext ( 1 ) . execute_with ( || {
1493
+ let subnet_owner_coldkey = U256 :: from ( 1001 ) ;
1494
+ let subnet_owner_hotkey = U256 :: from ( 1002 ) ;
1495
+ let origin_netuid = add_dynamic_network ( & subnet_owner_hotkey, & subnet_owner_coldkey) ;
1496
+ let destination_netuid = add_dynamic_network ( & subnet_owner_hotkey, & subnet_owner_coldkey) ;
1497
+
1498
+ let coldkey = U256 :: from ( 1 ) ;
1499
+ let hotkey = U256 :: from ( 2 ) ;
1500
+ let foreign_coldkey = U256 :: from ( 3 ) ;
1501
+ let stake_amount = DefaultMinStake :: < Test > :: get ( ) * 10 ;
1502
+
1503
+ SubtensorModule :: create_account_if_non_existent ( & foreign_coldkey, & hotkey) ;
1504
+ SubtensorModule :: stake_into_subnet ( & hotkey, & coldkey, origin_netuid, stake_amount, 0 ) ;
1505
+ let alpha_before = SubtensorModule :: get_stake_for_hotkey_and_coldkey_on_subnet (
1506
+ & hotkey,
1507
+ & coldkey,
1508
+ origin_netuid,
1509
+ ) ;
1510
+
1511
+ assert_ok ! ( SubtensorModule :: do_swap_stake(
1512
+ RuntimeOrigin :: signed( coldkey) ,
1513
+ hotkey,
1514
+ origin_netuid,
1515
+ destination_netuid,
1516
+ alpha_before,
1517
+ ) ) ;
1518
+ } ) ;
1519
+ }
1520
+
1489
1521
// cargo test --package pallet-subtensor --lib -- tests::move_stake::test_swap_stake_limit_validate --exact --show-output
1490
1522
#[ test]
1491
1523
fn test_swap_stake_limit_validate ( ) {
0 commit comments