1
+ import json
1
2
import re
2
3
3
4
from bittensor_cli .src .bittensor .balances import Balance
@@ -129,8 +130,10 @@ def test_staking(local_chain, wallet_setup):
129
130
wallet_alice .name ,
130
131
"--chain" ,
131
132
"ws://127.0.0.1:9945" ,
133
+ "--verbose" ,
132
134
],
133
135
)
136
+
134
137
# Assert correct stake is added
135
138
cleaned_stake = [
136
139
re .sub (r"\s+" , " " , line ) for line in show_stake .stdout .splitlines ()
@@ -151,6 +154,9 @@ def test_staking(local_chain, wallet_setup):
151
154
"--json-output" ,
152
155
],
153
156
)
157
+ show_stake_json_output = json .loads (show_stake_json .stdout )
158
+ alice_stake = show_stake_json_output ["stake_info" ][keypair_alice .ss58_address ][0 ]
159
+ assert Balance .from_tao (alice_stake ["stake_value" ]) > Balance .from_tao (90.0 )
154
160
155
161
# Execute remove_stake command and remove all alpha stakes from Alice
156
162
remove_stake = exec_command_alice (
@@ -196,7 +202,24 @@ def test_staking(local_chain, wallet_setup):
196
202
max_burn_tao = all_hyperparams [22 ].split ()[3 ]
197
203
198
204
# Assert max_burn is 100 TAO from default
199
- assert Balance .from_tao (float (max_burn_tao )) == Balance .from_tao (100 )
205
+ assert Balance .from_tao (float (max_burn_tao )) == Balance .from_tao (100.0 )
206
+
207
+ hyperparams_json = exec_command_alice (
208
+ command = "sudo" ,
209
+ sub_command = "get" ,
210
+ extra_args = [
211
+ "--chain" ,
212
+ "ws://127.0.0.1:9945" ,
213
+ "--netuid" ,
214
+ netuid ,
215
+ "--json-output" ,
216
+ ],
217
+ )
218
+ hyperparams_json_output = json .loads (hyperparams_json .stdout )
219
+ max_burn_tao_from_json = next (
220
+ filter (lambda x : x ["hyperparameter" ] == "max_burn" , hyperparams_json_output )
221
+ )["value" ]
222
+ assert Balance .from_rao (max_burn_tao_from_json ) == Balance .from_tao (100.0 )
200
223
201
224
# Change max_burn hyperparameter to 10 TAO
202
225
change_hyperparams = exec_command_alice (
@@ -241,4 +264,24 @@ def test_staking(local_chain, wallet_setup):
241
264
242
265
# Assert max_burn is now 10 TAO
243
266
assert Balance .from_tao (float (updated_max_burn_tao )) == Balance .from_tao (10 )
267
+
268
+ updated_hyperparams_json = exec_command_alice (
269
+ command = "sudo" ,
270
+ sub_command = "get" ,
271
+ extra_args = [
272
+ "--chain" ,
273
+ "ws://127.0.0.1:9945" ,
274
+ "--netuid" ,
275
+ netuid ,
276
+ "--json-output" ,
277
+ ],
278
+ )
279
+ updated_hyperparams_json_output = json .loads (updated_hyperparams_json .stdout )
280
+ max_burn_tao_from_json = next (
281
+ filter (
282
+ lambda x : x ["hyperparameter" ] == "max_burn" , updated_hyperparams_json_output
283
+ )
284
+ )["value" ]
285
+ assert Balance .from_rao (max_burn_tao_from_json ) == Balance .from_tao (10.0 )
286
+
244
287
print ("✅ Passed staking and sudo commands" )
0 commit comments