Skip to content

Commit 3aa0d78

Browse files
author
Roman
committed
add async subtensor extrinsic unit test
1 parent 2b4714a commit 3aa0d78

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/unit_tests/test_async_subtensor.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,3 +2637,38 @@ async def test_get_all_subnets_info_success(mocker, subtensor):
26372637
async_subtensor.SubnetInfo.list_from_dicts.assert_called_once_with(
26382638
subtensor.query_runtime_api.return_value,
26392639
)
2640+
2641+
2642+
@pytest.mark.asyncio
2643+
async def test_set_subnet_identity(mocker, subtensor):
2644+
"""Verify that subtensor method `set_subnet_identity` calls proper function with proper arguments."""
2645+
# Preps
2646+
fake_wallet = mocker.Mock()
2647+
fake_netuid = 123
2648+
fake_subnet_identity = mocker.MagicMock()
2649+
2650+
mocked_extrinsic = mocker.patch.object(
2651+
async_subtensor, "set_subnet_identity_extrinsic"
2652+
)
2653+
2654+
# Call
2655+
result = await subtensor.set_subnet_identity(
2656+
wallet=fake_wallet, netuid=fake_netuid, subnet_identity=fake_subnet_identity
2657+
)
2658+
2659+
# Asserts
2660+
mocked_extrinsic.assert_awaited_once_with(
2661+
subtensor=subtensor,
2662+
wallet=fake_wallet,
2663+
netuid=fake_netuid,
2664+
subnet_name=fake_subnet_identity.subnet_name,
2665+
github_repo=fake_subnet_identity.github_repo,
2666+
subnet_contact=fake_subnet_identity.subnet_contact,
2667+
subnet_url=fake_subnet_identity.subnet_url,
2668+
discord=fake_subnet_identity.discord,
2669+
description=fake_subnet_identity.description,
2670+
additional=fake_subnet_identity.additional,
2671+
wait_for_finalization=True,
2672+
wait_for_inclusion=False,
2673+
)
2674+
assert result == mocked_extrinsic.return_value

0 commit comments

Comments
 (0)