@@ -36,6 +36,7 @@ def test_staking(local_chain, wallet_setup):
36
36
"""
37
37
print ("Testing staking and sudo commands🧪" )
38
38
netuid = 2
39
+ multiple_netuids = [2 , 3 ]
39
40
wallet_path_alice = "//Alice"
40
41
41
42
# Create wallet for Alice
@@ -91,7 +92,42 @@ def test_staking(local_chain, wallet_setup):
91
92
)
92
93
result_output = json .loads (result .stdout )
93
94
assert result_output ["success" ] is True
94
- assert result_output ["netuid" ] == 2
95
+ assert result_output ["netuid" ] == netuid
96
+
97
+ # Register another subnet with sudo as Alice
98
+ result_for_second_repo = exec_command_alice (
99
+ command = "subnets" ,
100
+ sub_command = "create" ,
101
+ extra_args = [
102
+ "--wallet-path" ,
103
+ wallet_path_alice ,
104
+ "--chain" ,
105
+ "ws://127.0.0.1:9945" ,
106
+ "--wallet-name" ,
107
+ wallet_alice .name ,
108
+ "--wallet-hotkey" ,
109
+ wallet_alice .hotkey_str ,
110
+ "--subnet-name" ,
111
+ "Test Subnet" ,
112
+ "--repo" ,
113
+ "https://github.com/username/repo" ,
114
+ "--contact" ,
115
+
116
+ "--url" ,
117
+ "https://testsubnet.com" ,
118
+ "--discord" ,
119
+ "alice#1234" ,
120
+ "--description" ,
121
+ "A test subnet for e2e testing" ,
122
+ "--additional-info" ,
123
+ "Created by Alice" ,
124
+ "--no-prompt" ,
125
+ "--json-output" ,
126
+ ],
127
+ )
128
+ result_output_second = json .loads (result_for_second_repo .stdout )
129
+ assert result_output_second ["success" ] is True
130
+ assert result_output_second ["netuid" ] == multiple_netuids [1 ]
95
131
96
132
# Register Alice in netuid = 1 using her hotkey
97
133
register_subnet = exec_command_alice (
@@ -192,7 +228,7 @@ def test_staking(local_chain, wallet_setup):
192
228
assert get_identity_output ["additional" ] == sn_add_info
193
229
194
230
# Add stake to Alice's hotkey
195
- add_stake = exec_command_alice (
231
+ add_stake_single = exec_command_alice (
196
232
command = "stake" ,
197
233
sub_command = "add" ,
198
234
extra_args = [
@@ -216,10 +252,10 @@ def test_staking(local_chain, wallet_setup):
216
252
"144" ,
217
253
],
218
254
)
219
- assert "✅ Finalized" in add_stake .stdout , add_stake .stderr
255
+ assert "✅ Finalized" in add_stake_single .stdout , add_stake_single .stderr
220
256
221
257
# Execute stake show for Alice's wallet
222
- show_stake = exec_command_alice (
258
+ show_stake_adding_single = exec_command_alice (
223
259
command = "stake" ,
224
260
sub_command = "list" ,
225
261
extra_args = [
@@ -235,7 +271,8 @@ def test_staking(local_chain, wallet_setup):
235
271
236
272
# Assert correct stake is added
237
273
cleaned_stake = [
238
- re .sub (r"\s+" , " " , line ) for line in show_stake .stdout .splitlines ()
274
+ re .sub (r"\s+" , " " , line )
275
+ for line in show_stake_adding_single .stdout .splitlines ()
239
276
]
240
277
stake_added = cleaned_stake [8 ].split ("│" )[3 ].strip ().split ()[0 ]
241
278
assert Balance .from_tao (float (stake_added )) >= Balance .from_tao (90 )
@@ -284,6 +321,36 @@ def test_staking(local_chain, wallet_setup):
284
321
)
285
322
assert "✅ Finalized" in remove_stake .stdout
286
323
324
+ add_stake_multiple = exec_command_alice (
325
+ command = "stake" ,
326
+ sub_command = "add" ,
327
+ extra_args = [
328
+ "--netuids" ,
329
+ "," .join (str (x ) for x in multiple_netuids ),
330
+ "--wallet-path" ,
331
+ wallet_path_alice ,
332
+ "--wallet-name" ,
333
+ wallet_alice .name ,
334
+ "--hotkey" ,
335
+ wallet_alice .hotkey_str ,
336
+ "--chain" ,
337
+ "ws://127.0.0.1:9945" ,
338
+ "--amount" ,
339
+ "100" ,
340
+ "--tolerance" ,
341
+ "0.1" ,
342
+ "--partial" ,
343
+ "--no-prompt" ,
344
+ "--era" ,
345
+ "144" ,
346
+ ],
347
+ )
348
+ assert "✅ Finalized" in add_stake_multiple .stdout , add_stake_multiple .stderr
349
+ for netuid_ in multiple_netuids :
350
+ assert f"Stake added to netuid: { netuid_ } " in add_stake_multiple .stdout , (
351
+ add_stake_multiple .stderr
352
+ )
353
+
287
354
# Fetch the hyperparameters of the subnet
288
355
hyperparams = exec_command_alice (
289
356
command = "sudo" ,
0 commit comments