1
1
import pytest
2
2
3
- import bittensor
3
+ from bittensor .core .errors import (
4
+ NotEnoughStakeToSetChildkeys ,
5
+ RegistrationNotPermittedOnRootSubnet ,
6
+ SubNetworkDoesNotExist ,
7
+ InvalidChild ,
8
+ TooManyChildren ,
9
+ ProportionOverflow ,
10
+ DuplicateChild ,
11
+ TxRateLimitExceeded ,
12
+ NonAssociatedColdKey ,
13
+ )
14
+ from bittensor .utils .btlogging import logging
4
15
from tests .e2e_tests .utils .chain_interactions import (
5
16
sudo_set_admin_utils ,
6
17
wait_epoch ,
@@ -63,6 +74,7 @@ def test_hotkeys(subtensor, alice_wallet, dave_wallet):
63
74
)
64
75
is True
65
76
)
77
+ logging .console .success ("Hotkey tests passed." )
66
78
67
79
68
80
@pytest .mark .asyncio
@@ -97,7 +109,17 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
97
109
is True
98
110
)
99
111
100
- with pytest .raises (bittensor .RegistrationNotPermittedOnRootSubnet ):
112
+ # assert (
113
+ # sudo_set_admin_utils(
114
+ # local_chain,
115
+ # alice_wallet,
116
+ # call_function="sudo_set_tx_rate_limit",
117
+ # call_params={"tx_rate_limit": 100},
118
+ # )[0]
119
+ # is True
120
+ # )
121
+
122
+ with pytest .raises (RegistrationNotPermittedOnRootSubnet ):
101
123
subtensor .set_children (
102
124
alice_wallet ,
103
125
alice_wallet .hotkey .ss58_address ,
@@ -106,7 +128,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
106
128
raise_error = True ,
107
129
)
108
130
109
- with pytest .raises (bittensor . NonAssociatedColdKey ):
131
+ with pytest .raises (NonAssociatedColdKey ):
110
132
subtensor .set_children (
111
133
alice_wallet ,
112
134
alice_wallet .hotkey .ss58_address ,
@@ -115,7 +137,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
115
137
raise_error = True ,
116
138
)
117
139
118
- with pytest .raises (bittensor . SubNetworkDoesNotExist ):
140
+ with pytest .raises (SubNetworkDoesNotExist ):
119
141
subtensor .set_children (
120
142
alice_wallet ,
121
143
alice_wallet .hotkey .ss58_address ,
@@ -128,10 +150,12 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
128
150
alice_wallet ,
129
151
netuid = dave_subnet_netuid ,
130
152
)
153
+ logging .console .success (f"Alice registered on subnet { dave_subnet_netuid } " )
131
154
subtensor .burned_register (
132
155
bob_wallet ,
133
156
netuid = dave_subnet_netuid ,
134
157
)
158
+ logging .console .success (f"Bob registered on subnet { dave_subnet_netuid } " )
135
159
136
160
success , children , error = subtensor .get_children (
137
161
alice_wallet .hotkey .ss58_address ,
@@ -142,7 +166,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
142
166
assert success is True
143
167
assert children == []
144
168
145
- with pytest .raises (bittensor . InvalidChild ):
169
+ with pytest .raises (InvalidChild ):
146
170
subtensor .set_children (
147
171
alice_wallet ,
148
172
alice_wallet .hotkey .ss58_address ,
@@ -156,7 +180,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
156
180
raise_error = True ,
157
181
)
158
182
159
- with pytest .raises (bittensor . TooManyChildren ):
183
+ with pytest .raises (TooManyChildren ):
160
184
subtensor .set_children (
161
185
alice_wallet ,
162
186
alice_wallet .hotkey .ss58_address ,
@@ -171,7 +195,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
171
195
raise_error = True ,
172
196
)
173
197
174
- with pytest .raises (bittensor . ProportionOverflow ):
198
+ with pytest .raises (ProportionOverflow ):
175
199
subtensor .set_children (
176
200
alice_wallet ,
177
201
alice_wallet .hotkey .ss58_address ,
@@ -189,7 +213,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
189
213
raise_error = True ,
190
214
)
191
215
192
- with pytest .raises (bittensor . DuplicateChild ):
216
+ with pytest .raises (DuplicateChild ):
193
217
subtensor .set_children (
194
218
alice_wallet ,
195
219
alice_wallet .hotkey .ss58_address ,
@@ -242,13 +266,8 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
242
266
netuid = dave_subnet_netuid ,
243
267
)
244
268
245
- assert pending == [
246
- (
247
- 1.0 ,
248
- "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty" ,
249
- ),
250
- ]
251
- bittensor .logging .console .info (f"cooldown: { cooldown } " )
269
+ assert pending == [(1.0 , bob_wallet .hotkey .ss58_address )]
270
+ logging .console .info (f"Cooldown 1 is: { cooldown } " )
252
271
253
272
subtensor .wait_for_block (cooldown )
254
273
@@ -276,7 +295,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
276
295
277
296
assert pending == []
278
297
279
- with pytest .raises (bittensor . TxRateLimitExceeded ):
298
+ with pytest .raises (TxRateLimitExceeded ):
280
299
subtensor .set_children (
281
300
alice_wallet ,
282
301
alice_wallet .hotkey .ss58_address ,
@@ -301,6 +320,8 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
301
320
netuid = dave_subnet_netuid ,
302
321
)
303
322
323
+ logging .console .info (f"Cooldown 2 is: { cooldown } " )
324
+
304
325
assert pending == []
305
326
306
327
subtensor .wait_for_block (cooldown )
@@ -325,7 +346,7 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
325
346
},
326
347
)
327
348
328
- with pytest .raises (bittensor . NotEnoughStakeToSetChildkeys ):
349
+ with pytest .raises (NotEnoughStakeToSetChildkeys ):
329
350
subtensor .set_children (
330
351
alice_wallet ,
331
352
alice_wallet .hotkey .ss58_address ,
@@ -338,3 +359,4 @@ async def test_children(local_chain, subtensor, alice_wallet, bob_wallet, dave_w
338
359
],
339
360
raise_error = True ,
340
361
)
362
+ logging .console .success ("[green]test_children[/green] passed." )
0 commit comments