11import pytest
2- from bittensor_wallet import Wallet
32
43from bittensor .core import async_subtensor
54from bittensor .core .extrinsics .asyncex import registration as async_registration
65
76
87@pytest .mark .asyncio
9- async def test_do_pow_register_success (subtensor , mocker ):
8+ async def test_do_pow_register_success (subtensor , fake_wallet , mocker ):
109 """Tests successful PoW registration."""
1110 # Preps
12- fake_wallet = mocker .Mock (autospec = Wallet )
1311 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
1412 fake_wallet .coldkeypub .ss58_address = "coldkey_ss58"
1513 fake_pow_result = mocker .Mock (
@@ -66,10 +64,9 @@ async def test_do_pow_register_success(subtensor, mocker):
6664
6765
6866@pytest .mark .asyncio
69- async def test_do_pow_register_failure (subtensor , mocker ):
67+ async def test_do_pow_register_failure (subtensor , fake_wallet , mocker ):
7068 """Tests failed PoW registration."""
7169 # Preps
72- fake_wallet = mocker .Mock (autospec = Wallet )
7370 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
7471 fake_wallet .coldkeypub .ss58_address = "coldkey_ss58"
7572 fake_pow_result = mocker .Mock (
@@ -121,10 +118,9 @@ async def test_do_pow_register_failure(subtensor, mocker):
121118
122119
123120@pytest .mark .asyncio
124- async def test_do_pow_register_no_waiting (subtensor , mocker ):
121+ async def test_do_pow_register_no_waiting (subtensor , fake_wallet , mocker ):
125122 """Tests PoW registration without waiting for inclusion or finalization."""
126123 # Preps
127- fake_wallet = mocker .Mock (autospec = Wallet )
128124 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
129125 fake_wallet .coldkeypub .ss58_address = "coldkey_ss58"
130126 fake_pow_result = mocker .Mock (
@@ -166,10 +162,9 @@ async def test_do_pow_register_no_waiting(subtensor, mocker):
166162
167163
168164@pytest .mark .asyncio
169- async def test_register_extrinsic_success (subtensor , mocker ):
165+ async def test_register_extrinsic_success (subtensor , fake_wallet , mocker ):
170166 """Tests successful registration."""
171167 # Preps
172- fake_wallet = mocker .Mock (autospec = Wallet )
173168 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
174169 fake_wallet .coldkey .ss58_address = "coldkey_ss58"
175170
@@ -221,10 +216,9 @@ async def test_register_extrinsic_success(subtensor, mocker):
221216
222217
223218@pytest .mark .asyncio
224- async def test_register_extrinsic_success_with_cuda (subtensor , mocker ):
219+ async def test_register_extrinsic_success_with_cuda (subtensor , fake_wallet , mocker ):
225220 """Tests successful registration with CUDA enabled."""
226221 # Preps
227- fake_wallet = mocker .Mock (autospec = Wallet )
228222 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
229223 fake_wallet .coldkey .ss58_address = "coldkey_ss58"
230224
@@ -278,10 +272,9 @@ async def test_register_extrinsic_success_with_cuda(subtensor, mocker):
278272
279273
280274@pytest .mark .asyncio
281- async def test_register_extrinsic_failed_with_cuda (subtensor , mocker ):
275+ async def test_register_extrinsic_failed_with_cuda (subtensor , fake_wallet , mocker ):
282276 """Tests failed registration with CUDA enabled."""
283277 # Preps
284- fake_wallet = mocker .Mock (autospec = Wallet )
285278 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
286279 fake_wallet .coldkey .ss58_address = "coldkey_ss58"
287280
@@ -319,11 +312,9 @@ async def test_register_extrinsic_failed_with_cuda(subtensor, mocker):
319312
320313
321314@pytest .mark .asyncio
322- async def test_register_extrinsic_subnet_not_exists (subtensor , mocker ):
315+ async def test_register_extrinsic_subnet_not_exists (subtensor , fake_wallet , mocker ):
323316 """Tests registration when subnet does not exist."""
324317 # Preps
325- fake_wallet = mocker .Mock (autospec = Wallet )
326-
327318 mocked_subnet_exists = mocker .patch .object (
328319 subtensor , "subnet_exists" , return_value = False
329320 )
@@ -344,10 +335,9 @@ async def test_register_extrinsic_subnet_not_exists(subtensor, mocker):
344335
345336
346337@pytest .mark .asyncio
347- async def test_register_extrinsic_already_registered (subtensor , mocker ):
338+ async def test_register_extrinsic_already_registered (subtensor , fake_wallet , mocker ):
348339 """Tests registration when the key is already registered."""
349340 # Preps
350- fake_wallet = mocker .Mock (autospec = Wallet )
351341 mocked_get_neuron = mocker .patch .object (
352342 subtensor ,
353343 "get_neuron_for_pubkey_and_subnet" ,
@@ -371,9 +361,8 @@ async def test_register_extrinsic_already_registered(subtensor, mocker):
371361
372362
373363@pytest .mark .asyncio
374- async def test_register_extrinsic_max_attempts_reached (subtensor , mocker ):
364+ async def test_register_extrinsic_max_attempts_reached (subtensor , fake_wallet , mocker ):
375365 # Preps
376- fake_wallet = mocker .Mock (autospec = Wallet )
377366 fake_wallet .hotkey .ss58_address = "hotkey_ss58"
378367 fake_wallet .coldkey .ss58_address = "coldkey_ss58"
379368
@@ -439,10 +428,9 @@ async def is_stale_side_effect(*_, **__):
439428
440429
441430@pytest .mark .asyncio
442- async def test_set_subnet_identity_extrinsic_is_success (subtensor , mocker ):
431+ async def test_set_subnet_identity_extrinsic_is_success (subtensor , fake_wallet , mocker ):
443432 """Verify that set_subnet_identity_extrinsic calls the correct functions and returns the correct result."""
444433 # Preps
445- wallet = mocker .MagicMock (autospec = Wallet )
446434 netuid = 123
447435 subnet_name = "mock_subnet_name"
448436 github_repo = "mock_github_repo"
@@ -463,7 +451,7 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, mocker):
463451 # Call
464452 result = await async_registration .set_subnet_identity_extrinsic (
465453 subtensor = subtensor ,
466- wallet = wallet ,
454+ wallet = fake_wallet ,
467455 netuid = netuid ,
468456 subnet_name = subnet_name ,
469457 github_repo = github_repo ,
@@ -479,7 +467,7 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, mocker):
479467 call_module = "SubtensorModule" ,
480468 call_function = "set_subnet_identity" ,
481469 call_params = {
482- "hotkey" : wallet .hotkey .ss58_address ,
470+ "hotkey" : fake_wallet .hotkey .ss58_address ,
483471 "netuid" : netuid ,
484472 "subnet_name" : subnet_name ,
485473 "github_repo" : github_repo ,
@@ -492,7 +480,7 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, mocker):
492480 )
493481 mocked_submit_extrinsic .assert_awaited_once_with (
494482 call = mocked_compose_call .return_value ,
495- wallet = wallet ,
483+ wallet = fake_wallet ,
496484 wait_for_inclusion = False ,
497485 wait_for_finalization = True ,
498486 )
@@ -501,10 +489,9 @@ async def test_set_subnet_identity_extrinsic_is_success(subtensor, mocker):
501489
502490
503491@pytest .mark .asyncio
504- async def test_set_subnet_identity_extrinsic_is_failed (subtensor , mocker ):
492+ async def test_set_subnet_identity_extrinsic_is_failed (subtensor , fake_wallet , mocker ):
505493 """Verify that set_subnet_identity_extrinsic calls the correct functions and returns False with bad result."""
506494 # Preps
507- wallet = mocker .MagicMock (autospec = Wallet )
508495 netuid = 123
509496 subnet_name = "mock_subnet_name"
510497 github_repo = "mock_github_repo"
@@ -527,7 +514,7 @@ async def test_set_subnet_identity_extrinsic_is_failed(subtensor, mocker):
527514 # Call
528515 result = await async_registration .set_subnet_identity_extrinsic (
529516 subtensor = subtensor ,
530- wallet = wallet ,
517+ wallet = fake_wallet ,
531518 netuid = netuid ,
532519 subnet_name = subnet_name ,
533520 github_repo = github_repo ,
@@ -545,7 +532,7 @@ async def test_set_subnet_identity_extrinsic_is_failed(subtensor, mocker):
545532 call_module = "SubtensorModule" ,
546533 call_function = "set_subnet_identity" ,
547534 call_params = {
548- "hotkey" : wallet .hotkey .ss58_address ,
535+ "hotkey" : fake_wallet .hotkey .ss58_address ,
549536 "netuid" : netuid ,
550537 "subnet_name" : subnet_name ,
551538 "github_repo" : github_repo ,
@@ -558,7 +545,7 @@ async def test_set_subnet_identity_extrinsic_is_failed(subtensor, mocker):
558545 )
559546 mocked_submit_extrinsic .assert_awaited_once_with (
560547 call = mocked_compose_call .return_value ,
561- wallet = wallet ,
548+ wallet = fake_wallet ,
562549 wait_for_inclusion = True ,
563550 wait_for_finalization = True ,
564551 )
0 commit comments