@@ -3019,6 +3019,93 @@ def test_unstake_with_safe_staking(mocker, subtensor, fake_wallet):
3019
3019
assert result == mock_unstake_extrinsic .return_value
3020
3020
3021
3021
3022
+ def test_swap_stake_success (mocker , subtensor , fake_wallet ):
3023
+ """Test swap_stake operation is successful."""
3024
+ # Preps
3025
+ fake_hotkey_ss58 = "hotkey_1"
3026
+ fake_origin_netuid = 1
3027
+ fake_destination_netuid = 2
3028
+ fake_amount = 10.0
3029
+
3030
+ mock_swap_stake_extrinsic = mocker .patch .object (
3031
+ subtensor_module , "swap_stake_extrinsic"
3032
+ )
3033
+
3034
+ # Call
3035
+ result = subtensor .swap_stake (
3036
+ wallet = fake_wallet ,
3037
+ hotkey_ss58 = fake_hotkey_ss58 ,
3038
+ origin_netuid = fake_origin_netuid ,
3039
+ destination_netuid = fake_destination_netuid ,
3040
+ amount = fake_amount ,
3041
+ wait_for_inclusion = True ,
3042
+ wait_for_finalization = False ,
3043
+ safe_staking = False ,
3044
+ allow_partial_stake = False ,
3045
+ rate_threshold = 0.005 ,
3046
+ )
3047
+
3048
+ # Assertions
3049
+ mock_swap_stake_extrinsic .assert_called_once_with (
3050
+ subtensor = subtensor ,
3051
+ wallet = fake_wallet ,
3052
+ hotkey_ss58 = fake_hotkey_ss58 ,
3053
+ origin_netuid = fake_origin_netuid ,
3054
+ destination_netuid = fake_destination_netuid ,
3055
+ amount = Balance .from_rao (fake_amount ),
3056
+ wait_for_inclusion = True ,
3057
+ wait_for_finalization = False ,
3058
+ safe_staking = False ,
3059
+ allow_partial_stake = False ,
3060
+ rate_threshold = 0.005 ,
3061
+ )
3062
+ assert result == mock_swap_stake_extrinsic .return_value
3063
+
3064
+
3065
+ def test_swap_stake_with_safe_staking (mocker , subtensor , fake_wallet ):
3066
+ """Test swap_stake with safe staking parameters enabled."""
3067
+ # Preps
3068
+ fake_hotkey_ss58 = "hotkey_1"
3069
+ fake_origin_netuid = 1
3070
+ fake_destination_netuid = 2
3071
+ fake_amount = 10.0
3072
+ fake_rate_threshold = 0.01 # 1% threshold
3073
+
3074
+ mock_swap_stake_extrinsic = mocker .patch .object (
3075
+ subtensor_module , "swap_stake_extrinsic"
3076
+ )
3077
+
3078
+ # Call
3079
+ result = subtensor .swap_stake (
3080
+ wallet = fake_wallet ,
3081
+ hotkey_ss58 = fake_hotkey_ss58 ,
3082
+ origin_netuid = fake_origin_netuid ,
3083
+ destination_netuid = fake_destination_netuid ,
3084
+ amount = fake_amount ,
3085
+ wait_for_inclusion = True ,
3086
+ wait_for_finalization = False ,
3087
+ safe_staking = True ,
3088
+ allow_partial_stake = True ,
3089
+ rate_threshold = fake_rate_threshold ,
3090
+ )
3091
+
3092
+ # Assertions
3093
+ mock_swap_stake_extrinsic .assert_called_once_with (
3094
+ subtensor = subtensor ,
3095
+ wallet = fake_wallet ,
3096
+ hotkey_ss58 = fake_hotkey_ss58 ,
3097
+ origin_netuid = fake_origin_netuid ,
3098
+ destination_netuid = fake_destination_netuid ,
3099
+ amount = Balance .from_rao (fake_amount ),
3100
+ wait_for_inclusion = True ,
3101
+ wait_for_finalization = False ,
3102
+ safe_staking = True ,
3103
+ allow_partial_stake = True ,
3104
+ rate_threshold = fake_rate_threshold ,
3105
+ )
3106
+ assert result == mock_swap_stake_extrinsic .return_value
3107
+
3108
+
3022
3109
def test_unstake_multiple_success (mocker , subtensor , fake_wallet ):
3023
3110
"""Test unstake_multiple succeeds for all hotkeys."""
3024
3111
# Preps
0 commit comments