8
8
from async_substrate_interface import sync_substrate
9
9
from async_substrate_interface .types import ScaleObj
10
10
import websockets
11
+ from substrateinterface .exceptions import SubstrateRequestException
11
12
12
13
from bittensor import StakeInfo
13
14
from bittensor .core import settings
@@ -3786,7 +3787,7 @@ def test_get_parents_success(subtensor, mocker):
3786
3787
mocked_decode_account_id .assert_has_calls (
3787
3788
[mocker .call ("parent_key_1" ), mocker .call ("parent_key_2" )]
3788
3789
)
3789
- assert result == ( True , expected_formatted_parents , "" )
3790
+ assert result == expected_formatted_parents
3790
3791
3791
3792
3792
3793
def test_get_parents_no_parents (subtensor , mocker ):
@@ -3809,33 +3810,19 @@ def test_get_parents_no_parents(subtensor, mocker):
3809
3810
storage_function = "ParentKeys" ,
3810
3811
params = [fake_hotkey , fake_netuid ],
3811
3812
)
3812
- assert result == ( True , [], "" )
3813
+ assert result == []
3813
3814
3814
3815
3815
3816
def test_get_parents_substrate_request_exception (subtensor , mocker ):
3816
3817
"""Tests get_parents when SubstrateRequestException is raised."""
3817
3818
# Preps
3818
3819
fake_hotkey = "valid_hotkey"
3819
3820
fake_netuid = 1
3820
- fake_exception = subtensor_module . SubstrateRequestException ("Test Exception" )
3821
+ fake_exception = SubstrateRequestException ("Test Exception" )
3821
3822
3822
3823
mocked_query = mocker .MagicMock (side_effect = fake_exception )
3823
3824
subtensor .substrate .query = mocked_query
3824
3825
3825
- mocked_format_error_message = mocker .Mock (return_value = "Formatted error message" )
3826
- mocker .patch .object (
3827
- subtensor_module , "format_error_message" , mocked_format_error_message
3828
- )
3829
-
3830
3826
# Call
3831
- result = subtensor .get_parents (hotkey = fake_hotkey , netuid = fake_netuid )
3832
-
3833
- # Asserts
3834
- mocked_query .assert_called_once_with (
3835
- block_hash = None ,
3836
- module = "SubtensorModule" ,
3837
- storage_function = "ParentKeys" ,
3838
- params = [fake_hotkey , fake_netuid ],
3839
- )
3840
- mocked_format_error_message .assert_called_once_with (fake_exception )
3841
- assert result == (False , [], "Formatted error message" )
3827
+ with pytest .raises (SubstrateRequestException ):
3828
+ subtensor .get_parents (hotkey = fake_hotkey , netuid = fake_netuid )
0 commit comments