@@ -541,7 +541,7 @@ fn test_do_move_wrong_origin() {
541541 netuid,
542542 alpha,
543543 ) ,
544- Error :: <Test >:: NonAssociatedColdKey
544+ Error :: <Test >:: NotEnoughStakeToWithdraw
545545 ) ;
546546
547547 // Check that no stake was moved
@@ -981,7 +981,7 @@ fn test_do_transfer_wrong_origin() {
981981 netuid,
982982 stake_amount
983983 ) ,
984- Error :: <Test >:: NonAssociatedColdKey
984+ Error :: <Test >:: NotEnoughStakeToWithdraw
985985 ) ;
986986 } ) ;
987987}
@@ -1245,7 +1245,7 @@ fn test_do_swap_wrong_origin() {
12451245 netuid2,
12461246 stake_amount
12471247 ) ,
1248- Error :: <Test >:: NonAssociatedColdKey
1248+ Error :: <Test >:: NotEnoughStakeToWithdraw
12491249 ) ;
12501250 } ) ;
12511251}
@@ -1486,6 +1486,38 @@ fn test_do_swap_multiple_times() {
14861486 } ) ;
14871487}
14881488
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+
14891521// cargo test --package pallet-subtensor --lib -- tests::move_stake::test_swap_stake_limit_validate --exact --show-output
14901522#[ test]
14911523fn test_swap_stake_limit_validate ( ) {
0 commit comments