Skip to content

Commit 5b0e9db

Browse files
author
Roman
committed
move async extrinsics tests to proper directory
1 parent 1ea40e1 commit 5b0e9db

File tree

7 files changed

+21
-24
lines changed

7 files changed

+21
-24
lines changed

tests/unit_tests/extrinsics/__init__.py

Whitespace-only changes.

tests/unit_tests/extrinsics/asyncex/__init__.py

Whitespace-only changes.

tests/unit_tests/extrinsics/test_async_commit_reveal.py renamed to tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from bittensor.core import async_subtensor as subtensor_module
22
from bittensor.core.chain_data import SubnetHyperparameters
33
from bittensor.core.async_subtensor import AsyncSubtensor
4-
from bittensor.core.extrinsics import async_commit_reveal
4+
from bittensor.core.extrinsics.asyncex import commit_reveal as async_commit_reveal
55
import pytest
66
import torch
77
import numpy as np
8+
from bittensor_wallet import Wallet
89

910

1011
@pytest.fixture
@@ -54,7 +55,7 @@ def hyperparams():
5455
async def test_do_commit_reveal_v3_success(mocker, subtensor):
5556
"""Test successful commit-reveal with wait for finalization."""
5657
# Preps
57-
fake_wallet = mocker.Mock(autospec=subtensor_module.Wallet)
58+
fake_wallet = mocker.Mock(autospec=Wallet)
5859
fake_netuid = 1
5960
fake_commit = b"fake_commit"
6061
fake_reveal_round = 1
@@ -90,7 +91,6 @@ async def test_do_commit_reveal_v3_success(mocker, subtensor):
9091
call=mocked_compose_call.return_value, keypair=fake_wallet.hotkey
9192
)
9293
mocked_submit_extrinsic.assert_awaited_once_with(
93-
subtensor=subtensor,
9494
extrinsic=mocked_create_signed_extrinsic.return_value,
9595
wait_for_inclusion=False,
9696
wait_for_finalization=False,
@@ -102,7 +102,7 @@ async def test_do_commit_reveal_v3_success(mocker, subtensor):
102102
async def test_do_commit_reveal_v3_failure_due_to_error(mocker, subtensor):
103103
"""Test commit-reveal fails due to an error in submission."""
104104
# Preps
105-
fake_wallet = mocker.Mock(autospec=subtensor_module.Wallet)
105+
fake_wallet = mocker.Mock(autospec=Wallet)
106106
fake_netuid = 1
107107
fake_commit = b"fake_commit"
108108
fake_reveal_round = 1
@@ -149,7 +149,6 @@ async def test_do_commit_reveal_v3_failure_due_to_error(mocker, subtensor):
149149
call=mocked_compose_call.return_value, keypair=fake_wallet.hotkey
150150
)
151151
mocked_submit_extrinsic.assert_awaited_once_with(
152-
subtensor=subtensor,
153152
extrinsic=mocked_create_signed_extrinsic.return_value,
154153
wait_for_inclusion=True,
155154
wait_for_finalization=True,
@@ -164,7 +163,7 @@ async def test_commit_reveal_v3_extrinsic_success_with_torch(
164163
):
165164
"""Test successful commit-reveal with torch tensors."""
166165
# Preps
167-
fake_wallet = mocker.Mock(autospec=subtensor_module.Wallet)
166+
fake_wallet = mocker.Mock(autospec=Wallet)
168167
fake_netuid = 1
169168
fake_uids = torch.tensor([1, 2, 3], dtype=torch.int64)
170169
fake_weights = torch.tensor([0.1, 0.2, 0.7], dtype=torch.float32)
@@ -243,7 +242,7 @@ async def test_commit_reveal_v3_extrinsic_success_with_numpy(
243242
):
244243
"""Test successful commit-reveal with numpy arrays."""
245244
# Preps
246-
fake_wallet = mocker.Mock(autospec=subtensor_module.Wallet)
245+
fake_wallet = mocker.Mock(autospec=Wallet)
247246
fake_netuid = 1
248247
fake_uids = np.array([1, 2, 3], dtype=np.int64)
249248
fake_weights = np.array([0.1, 0.2, 0.7], dtype=np.float32)
@@ -291,7 +290,7 @@ async def test_commit_reveal_v3_extrinsic_response_false(
291290
):
292291
"""Test unsuccessful commit-reveal with torch."""
293292
# Preps
294-
fake_wallet = mocker.Mock(autospec=subtensor_module.Wallet)
293+
fake_wallet = mocker.Mock(autospec=Wallet)
295294
fake_netuid = 1
296295
fake_uids = torch.tensor([1, 2, 3], dtype=torch.int64)
297296
fake_weights = torch.tensor([0.1, 0.2, 0.7], dtype=torch.float32)
@@ -348,7 +347,7 @@ async def test_commit_reveal_v3_extrinsic_response_false(
348347
async def test_commit_reveal_v3_extrinsic_exception(mocker, subtensor):
349348
"""Test exception handling in commit-reveal."""
350349
# Preps
351-
fake_wallet = mocker.Mock(autospec=subtensor_module.Wallet)
350+
fake_wallet = mocker.Mock(autospec=Wallet)
352351
fake_netuid = 1
353352
fake_uids = [1, 2, 3]
354353
fake_weights = [0.1, 0.2, 0.7]

tests/unit_tests/extrinsics/test_async_registration.py renamed to tests/unit_tests/extrinsics/asyncex/test_registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from bittensor_wallet import Wallet
33

44
from bittensor.core import async_subtensor
5-
from bittensor.core.extrinsics import async_registration
5+
from bittensor.core.extrinsics.asyncex import registration as async_registration
66

77

88
@pytest.fixture(autouse=True)

tests/unit_tests/extrinsics/test_async_root.py renamed to tests/unit_tests/extrinsics/asyncex/test_root.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from substrateinterface.exceptions import SubstrateRequestException
33

44
from bittensor.core import async_subtensor
5-
from bittensor.core.extrinsics import async_root
5+
from bittensor.core.extrinsics.asyncex import root as async_root
66
from bittensor_wallet import Wallet
77

88

@@ -311,7 +311,7 @@ async def test_do_set_root_weights_success(subtensor, mocker):
311311
era={"period": 5},
312312
)
313313
subtensor.substrate.submit_extrinsic.assert_called_once_with(
314-
fake_extrinsic, wait_for_inclusion=True, wait_for_finalization=True
314+
extrinsic=fake_extrinsic, wait_for_inclusion=True, wait_for_finalization=True
315315
)
316316
fake_response.process_events.assert_called_once()
317317
assert result is True
@@ -405,7 +405,7 @@ async def test_do_set_root_weights_no_waiting(subtensor, mocker):
405405
subtensor.substrate.compose_call.assert_called_once()
406406
subtensor.substrate.create_signed_extrinsic.assert_called_once()
407407
subtensor.substrate.submit_extrinsic.assert_called_once_with(
408-
fake_extrinsic, wait_for_inclusion=False, wait_for_finalization=False
408+
extrinsic=fake_extrinsic, wait_for_inclusion=False, wait_for_finalization=False
409409
)
410410
assert result is True
411411
assert message == "Not waiting for finalization or inclusion."

tests/unit_tests/extrinsics/test_async_transfer.py renamed to tests/unit_tests/extrinsics/asyncex/test_transfer.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from bittensor.core import async_subtensor
33
from bittensor_wallet import Wallet
4-
from bittensor.core.extrinsics import async_transfer
4+
from bittensor.core.extrinsics.asyncex import transfer as async_transfer
55
from bittensor.utils.balance import Balance
66

77

@@ -60,7 +60,7 @@ async def test_do_transfer_success(subtensor, mocker):
6060
call=subtensor.substrate.compose_call.return_value, keypair=fake_wallet.coldkey
6161
)
6262
subtensor.substrate.submit_extrinsic.assert_called_once_with(
63-
subtensor.substrate.create_signed_extrinsic.return_value,
63+
extrinsic=subtensor.substrate.create_signed_extrinsic.return_value,
6464
wait_for_inclusion=True,
6565
wait_for_finalization=True,
6666
)
@@ -119,7 +119,7 @@ async def test_do_transfer_failure(subtensor, mocker):
119119
call=subtensor.substrate.compose_call.return_value, keypair=fake_wallet.coldkey
120120
)
121121
subtensor.substrate.submit_extrinsic.assert_called_once_with(
122-
subtensor.substrate.create_signed_extrinsic.return_value,
122+
extrinsic=subtensor.substrate.create_signed_extrinsic.return_value,
123123
wait_for_inclusion=True,
124124
wait_for_finalization=True,
125125
)
@@ -170,7 +170,7 @@ async def test_do_transfer_no_waiting(subtensor, mocker):
170170
call=subtensor.substrate.compose_call.return_value, keypair=fake_wallet.coldkey
171171
)
172172
subtensor.substrate.submit_extrinsic.assert_called_once_with(
173-
subtensor.substrate.create_signed_extrinsic.return_value,
173+
extrinsic=subtensor.substrate.create_signed_extrinsic.return_value,
174174
wait_for_inclusion=False,
175175
wait_for_finalization=False,
176176
)
@@ -204,7 +204,7 @@ async def test_transfer_extrinsic_success(subtensor, mocker):
204204
mocked_get_balance = mocker.patch.object(
205205
subtensor,
206206
"get_balance",
207-
return_value={fake_wallet.coldkeypub.ss58_address: 10000},
207+
return_value=10000,
208208
)
209209
mocked_get_existential_deposit = mocker.patch.object(
210210
subtensor, "get_existential_deposit", return_value=1
@@ -269,7 +269,7 @@ async def test_transfer_extrinsic_call_successful_with_failed_response(
269269
mocked_get_balance = mocker.patch.object(
270270
subtensor,
271271
"get_balance",
272-
return_value={fake_wallet.coldkeypub.ss58_address: 10000},
272+
return_value=10000,
273273
)
274274
mocked_get_existential_deposit = mocker.patch.object(
275275
subtensor, "get_existential_deposit", return_value=1
@@ -333,9 +333,7 @@ async def test_transfer_extrinsic_insufficient_balance(subtensor, mocker):
333333
mocked_get_balance = mocker.patch.object(
334334
subtensor,
335335
"get_balance",
336-
return_value={
337-
fake_wallet.coldkeypub.ss58_address: 1000
338-
}, # Insufficient balance
336+
return_value=1000, # Insufficient balance
339337
)
340338
mocked_get_existential_deposit = mocker.patch.object(
341339
subtensor, "get_existential_deposit", return_value=1
@@ -465,7 +463,7 @@ async def test_transfer_extrinsic_keep_alive_false_and_transfer_all_true(
465463
mocked_get_balance = mocker.patch.object(
466464
subtensor,
467465
"get_balance",
468-
return_value={fake_wallet.coldkeypub.ss58_address: 1},
466+
return_value=1,
469467
)
470468
mocked_get_existential_deposit = mocker.patch.object(
471469
subtensor, "get_existential_deposit", return_value=1

tests/unit_tests/extrinsics/test_async_set_weights.py renamed to tests/unit_tests/extrinsics/asyncex/test_weights.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from bittensor.core import async_subtensor
33
from bittensor_wallet import Wallet
4-
from bittensor.core.extrinsics import async_weights
4+
from bittensor.core.extrinsics.asyncex import weights as async_weights
55

66

77
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)