From 7b7c1cfa4b7cc522f62f90919c35382952c2c395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBy=C5=BAniewski?= Date: Wed, 26 Feb 2025 18:18:54 +0100 Subject: [PATCH] fix: async get_delegated --- bittensor/core/async_subtensor.py | 3 ++- tests/unit_tests/test_async_subtensor.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index 84f57a9602..4b157948db 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -27,6 +27,7 @@ decode_account_id, DynamicInfo, ) +from bittensor.core.chain_data.delegate_info import DelegatedInfo from bittensor.core.chain_data.utils import decode_metadata from bittensor.core.config import Config from bittensor.core.errors import SubstrateRequestException @@ -1219,7 +1220,7 @@ async def get_delegated( if not result: return [] - return DelegateInfo.delegated_list_from_dicts(result) + return DelegatedInfo.list_from_dicts(result) async def get_delegates( self, diff --git a/tests/unit_tests/test_async_subtensor.py b/tests/unit_tests/test_async_subtensor.py index 5123ce7607..352b4274a7 100644 --- a/tests/unit_tests/test_async_subtensor.py +++ b/tests/unit_tests/test_async_subtensor.py @@ -1217,9 +1217,9 @@ async def test_get_delegated_no_block_hash_no_reuse(subtensor, mocker): # Preps fake_coldkey_ss58 = "fake_ss58_address" - mocked_delegated_list_from_dicts = mocker.Mock() - async_subtensor.DelegateInfo.delegated_list_from_dicts = ( - mocked_delegated_list_from_dicts + mocked_delegated_list_from_dicts = mocker.patch.object( + async_subtensor.DelegatedInfo, + "list_from_dicts", ) # Call @@ -1245,9 +1245,9 @@ async def test_get_delegated_with_block_hash(subtensor, mocker): fake_coldkey_ss58 = "fake_ss58_address" fake_block_hash = "fake_block_hash" - mocked_delegated_list_from_dicts = mocker.Mock() - async_subtensor.DelegateInfo.delegated_list_from_dicts = ( - mocked_delegated_list_from_dicts + mocked_delegated_list_from_dicts = mocker.patch.object( + async_subtensor.DelegatedInfo, + "list_from_dicts", ) # Call @@ -1275,9 +1275,9 @@ async def test_get_delegated_with_reuse_block(subtensor, mocker): fake_coldkey_ss58 = "fake_ss58_address" reuse_block = True - mocked_delegated_list_from_dicts = mocker.Mock() - async_subtensor.DelegateInfo.delegated_list_from_dicts = ( - mocked_delegated_list_from_dicts + mocked_delegated_list_from_dicts = mocker.patch.object( + async_subtensor.DelegatedInfo, + "list_from_dicts", ) # Call