Skip to content

Commit 4b0ff32

Browse files
author
Roman
committed
add unit tests subtensor calls
1 parent 9e30620 commit 4b0ff32

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/unit_tests/test_async_subtensor.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,3 +3013,25 @@ async def test_get_owned_hotkeys_return_empty(subtensor, mocker):
30133013
reuse_block_hash=False,
30143014
)
30153015
assert result == []
3016+
3017+
3018+
@pytest.mark.asyncio
3019+
async def test_start_call(subtensor, mocker):
3020+
"""Test start_call extrinsic calls properly."""
3021+
# preps
3022+
wallet_name = mocker.Mock(spec=Wallet)
3023+
netuid = 123
3024+
mocked_extrinsic = mocker.patch.object(async_subtensor, "start_call_extrinsic")
3025+
3026+
# Call
3027+
result = await subtensor.start_call(wallet_name, netuid)
3028+
3029+
# Asserts
3030+
mocked_extrinsic.assert_awaited_once_with(
3031+
subtensor=subtensor,
3032+
wallet=wallet_name,
3033+
netuid=netuid,
3034+
wait_for_inclusion=True,
3035+
wait_for_finalization=False,
3036+
)
3037+
assert result == mocked_extrinsic.return_value

tests/unit_tests/test_subtensor.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,3 +3388,24 @@ def test_get_owned_hotkeys_return_empty(subtensor, mocker):
33883388
reuse_block_hash=False,
33893389
)
33903390
assert result == []
3391+
3392+
3393+
def test_start_call(subtensor, mocker):
3394+
"""Test start_call extrinsic calls properly."""
3395+
# preps
3396+
wallet_name = mocker.Mock(spec=Wallet)
3397+
netuid = 123
3398+
mocked_extrinsic = mocker.patch.object(subtensor_module, "start_call_extrinsic")
3399+
3400+
# Call
3401+
result = subtensor.start_call(wallet_name, netuid)
3402+
3403+
# Asserts
3404+
mocked_extrinsic.assert_called_once_with(
3405+
subtensor=subtensor,
3406+
wallet=wallet_name,
3407+
netuid=netuid,
3408+
wait_for_inclusion=True,
3409+
wait_for_finalization=False,
3410+
)
3411+
assert result == mocked_extrinsic.return_value

0 commit comments

Comments
 (0)