@@ -2196,45 +2196,78 @@ def test_networks_during_connection(mocker):
2196
2196
sub .chain_endpoint = settings .NETWORK_MAP .get (network )
2197
2197
2198
2198
2199
- @pytest .mark .parametrize (
2200
- "fake_value_result" ,
2201
- [1 , None ],
2202
- ids = ["result has value attr" , "result has not value attr" ],
2203
- )
2204
- def test_get_stake_for_coldkey_and_hotkey (subtensor , mocker , fake_value_result ):
2205
- """Test get_stake_for_coldkey_and_hotkey calls right method with correct arguments."""
2199
+ def test_get_stake_for_coldkey_and_hotkey_with_single_result (subtensor , mocker ):
2200
+ """Test `get_stake_for_coldkey_and_hotkey` calls right method with correct arguments and get 1 stake info."""
2206
2201
# Preps
2207
2202
fake_hotkey_ss58 = "FAKE_H_SS58"
2208
2203
fake_coldkey_ss58 = "FAKE_C_SS58"
2204
+ fake_netuid = 255
2209
2205
fake_block = 123
2210
2206
2211
- return_value = (
2212
- mocker .Mock (value = fake_value_result )
2213
- if fake_value_result is not None
2214
- else fake_value_result
2207
+ fake_stake_info_1 = mocker .Mock (hotkey_ss58 = "some" )
2208
+ fake_stake_info_2 = mocker .Mock (
2209
+ hotkey_ss58 = fake_hotkey_ss58 , netuid = fake_netuid , stake = 100
2215
2210
)
2216
2211
2217
- subtensor .query_subtensor = mocker .patch .object (
2218
- subtensor , "query_subtensor" , return_value = return_value
2212
+ return_value = [
2213
+ fake_stake_info_1 ,
2214
+ fake_stake_info_2 ,
2215
+ ]
2216
+
2217
+ subtensor .get_stake_for_coldkey = mocker .patch .object (
2218
+ subtensor , "get_stake_for_coldkey" , return_value = return_value
2219
2219
)
2220
- spy_balance_from_rao = mocker .spy (subtensor_module .Balance , "from_rao" )
2221
2220
2222
2221
# Call
2223
2222
result = subtensor .get_stake_for_coldkey_and_hotkey (
2224
2223
hotkey_ss58 = fake_hotkey_ss58 ,
2225
2224
coldkey_ss58 = fake_coldkey_ss58 ,
2225
+ netuid = fake_netuid ,
2226
2226
block = fake_block ,
2227
2227
)
2228
2228
2229
2229
# Asserts
2230
- subtensor .query_subtensor .assert_called_once_with (
2231
- "Stake" , fake_block , [fake_hotkey_ss58 , fake_coldkey_ss58 ]
2230
+ subtensor .get_stake_for_coldkey .assert_called_once_with (
2231
+ fake_coldkey_ss58 , fake_block
2232
+ )
2233
+ assert result == fake_stake_info_2
2234
+
2235
+
2236
+ def test_get_stake_for_coldkey_and_hotkey_with_multiple_result (subtensor , mocker ):
2237
+ """Test `get_stake_for_coldkey_and_hotkey` calls right method with correct arguments and get multiple stake info."""
2238
+ # Preps
2239
+ fake_hotkey_ss58 = "FAKE_H_SS58"
2240
+ fake_coldkey_ss58 = "FAKE_C_SS58"
2241
+ fake_netuid = 255
2242
+ fake_block = 123
2243
+
2244
+ fake_stake_info_1 = mocker .Mock (hotkey_ss58 = "some" )
2245
+ fake_stake_info_2 = mocker .Mock (
2246
+ hotkey_ss58 = fake_hotkey_ss58 , netuid = fake_netuid , stake = 100
2247
+ )
2248
+ fake_stake_info_3 = mocker .Mock (
2249
+ hotkey_ss58 = fake_hotkey_ss58 , netuid = fake_netuid , stake = 200
2250
+ )
2251
+
2252
+ return_value = [fake_stake_info_1 , fake_stake_info_2 , fake_stake_info_3 ]
2253
+
2254
+ subtensor .get_stake_for_coldkey = mocker .patch .object (
2255
+ subtensor , "get_stake_for_coldkey" , return_value = return_value
2256
+ )
2257
+
2258
+ # Call
2259
+ result = subtensor .get_stake_for_coldkey_and_hotkey (
2260
+ hotkey_ss58 = fake_hotkey_ss58 ,
2261
+ coldkey_ss58 = fake_coldkey_ss58 ,
2262
+ netuid = fake_netuid ,
2263
+ block = fake_block ,
2232
2264
)
2233
- if fake_value_result is not None :
2234
- spy_balance_from_rao .assert_called_once_with (fake_value_result )
2235
- else :
2236
- spy_balance_from_rao .assert_not_called ()
2237
- assert result == fake_value_result
2265
+
2266
+ # Asserts
2267
+ subtensor .get_stake_for_coldkey .assert_called_once_with (
2268
+ fake_coldkey_ss58 , fake_block
2269
+ )
2270
+ assert result == [fake_stake_info_2 , fake_stake_info_3 ]
2238
2271
2239
2272
2240
2273
def test_does_hotkey_exist_true (mocker , subtensor ):
@@ -2714,6 +2747,7 @@ def test_add_stake_success(mocker, subtensor):
2714
2747
fake_wallet = mocker .Mock ()
2715
2748
fake_hotkey_ss58 = "fake_hotkey"
2716
2749
fake_amount = 10.0
2750
+ fake_netuid = 123
2717
2751
2718
2752
mock_add_stake_extrinsic = mocker .patch .object (
2719
2753
subtensor_module , "add_stake_extrinsic"
@@ -2723,6 +2757,7 @@ def test_add_stake_success(mocker, subtensor):
2723
2757
result = subtensor .add_stake (
2724
2758
wallet = fake_wallet ,
2725
2759
hotkey_ss58 = fake_hotkey_ss58 ,
2760
+ netuid = fake_netuid ,
2726
2761
amount = fake_amount ,
2727
2762
wait_for_inclusion = True ,
2728
2763
wait_for_finalization = False ,
@@ -2733,6 +2768,7 @@ def test_add_stake_success(mocker, subtensor):
2733
2768
subtensor = subtensor ,
2734
2769
wallet = fake_wallet ,
2735
2770
hotkey_ss58 = fake_hotkey_ss58 ,
2771
+ netuid = fake_netuid ,
2736
2772
amount = fake_amount ,
2737
2773
wait_for_inclusion = True ,
2738
2774
wait_for_finalization = False ,
@@ -2746,6 +2782,7 @@ def test_add_stake_multiple_success(mocker, subtensor):
2746
2782
fake_wallet = mocker .Mock ()
2747
2783
fake_hotkey_ss58 = ["fake_hotkey" ]
2748
2784
fake_amount = [10.0 ]
2785
+ fake_netuids = [1 ]
2749
2786
2750
2787
mock_add_stake_multiple_extrinsic = mocker .patch .object (
2751
2788
subtensor_module , "add_stake_multiple_extrinsic"
@@ -2755,6 +2792,7 @@ def test_add_stake_multiple_success(mocker, subtensor):
2755
2792
result = subtensor .add_stake_multiple (
2756
2793
wallet = fake_wallet ,
2757
2794
hotkey_ss58s = fake_hotkey_ss58 ,
2795
+ netuids = fake_netuids ,
2758
2796
amounts = fake_amount ,
2759
2797
wait_for_inclusion = True ,
2760
2798
wait_for_finalization = False ,
@@ -2765,6 +2803,7 @@ def test_add_stake_multiple_success(mocker, subtensor):
2765
2803
subtensor = subtensor ,
2766
2804
wallet = fake_wallet ,
2767
2805
hotkey_ss58s = fake_hotkey_ss58 ,
2806
+ netuids = fake_netuids ,
2768
2807
amounts = fake_amount ,
2769
2808
wait_for_inclusion = True ,
2770
2809
wait_for_finalization = False ,
@@ -2778,13 +2817,15 @@ def test_unstake_success(mocker, subtensor):
2778
2817
fake_wallet = mocker .Mock ()
2779
2818
fake_hotkey_ss58 = "hotkey_1"
2780
2819
fake_amount = 10.0
2820
+ fake_netuid = 123
2781
2821
2782
2822
mock_unstake_extrinsic = mocker .patch .object (subtensor_module , "unstake_extrinsic" )
2783
2823
2784
2824
# Call
2785
2825
result = subtensor .unstake (
2786
2826
wallet = fake_wallet ,
2787
2827
hotkey_ss58 = fake_hotkey_ss58 ,
2828
+ netuid = fake_netuid ,
2788
2829
amount = fake_amount ,
2789
2830
wait_for_inclusion = True ,
2790
2831
wait_for_finalization = False ,
@@ -2795,6 +2836,7 @@ def test_unstake_success(mocker, subtensor):
2795
2836
subtensor = subtensor ,
2796
2837
wallet = fake_wallet ,
2797
2838
hotkey_ss58 = fake_hotkey_ss58 ,
2839
+ netuid = fake_netuid ,
2798
2840
amount = fake_amount ,
2799
2841
wait_for_inclusion = True ,
2800
2842
wait_for_finalization = False ,
@@ -2808,6 +2850,7 @@ def test_unstake_multiple_success(mocker, subtensor):
2808
2850
fake_wallet = mocker .Mock ()
2809
2851
fake_hotkeys = ["hotkey_1" , "hotkey_2" ]
2810
2852
fake_amounts = [10.0 , 20.0 ]
2853
+ fake_netuids = [1 , 2 ]
2811
2854
2812
2855
mock_unstake_multiple_extrinsic = mocker .patch (
2813
2856
"bittensor.core.subtensor.unstake_multiple_extrinsic" , return_value = True
@@ -2817,6 +2860,7 @@ def test_unstake_multiple_success(mocker, subtensor):
2817
2860
result = subtensor .unstake_multiple (
2818
2861
wallet = fake_wallet ,
2819
2862
hotkey_ss58s = fake_hotkeys ,
2863
+ netuids = fake_netuids ,
2820
2864
amounts = fake_amounts ,
2821
2865
wait_for_inclusion = True ,
2822
2866
wait_for_finalization = False ,
@@ -2827,6 +2871,7 @@ def test_unstake_multiple_success(mocker, subtensor):
2827
2871
subtensor = subtensor ,
2828
2872
wallet = fake_wallet ,
2829
2873
hotkey_ss58s = fake_hotkeys ,
2874
+ netuids = fake_netuids ,
2830
2875
amounts = fake_amounts ,
2831
2876
wait_for_inclusion = True ,
2832
2877
wait_for_finalization = False ,
0 commit comments