@@ -97,9 +97,7 @@ def test_serve_axon_with_external_ip_set():
9797 assert axon_info .ip == external_ip
9898
9999
100- def test_serve_axon_with_external_port_set ():
101- external_ip : str = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
102-
100+ def test_serve_axon_with_external_port_set (mock_get_external_ip ):
103101 internal_port : int = 1234
104102 external_port : int = 5678
105103
@@ -134,14 +132,10 @@ def test_serve_axon_with_external_port_set():
134132 config = mock_config ,
135133 )
136134
137- with mock .patch (
138- "bittensor.utils.networking.get_external_ip" , return_value = external_ip
139- ):
140- # mock the get_external_ip function to return the external ip
141- mock_subtensor .serve_axon (
142- netuid = - 1 ,
143- axon = mock_axon_with_external_port_set ,
144- )
135+ mock_subtensor .serve_axon (
136+ netuid = - 1 ,
137+ axon = mock_axon_with_external_port_set ,
138+ )
145139
146140 mock_serve_axon .assert_called_once ()
147141 # verify that the axon is served to the network with the external port
@@ -249,19 +243,6 @@ def test_determine_chain_endpoint_and_network(
249243 assert result_endpoint == expected_endpoint
250244
251245
252- @pytest .fixture
253- def subtensor (mocker ):
254- fake_substrate = mocker .MagicMock ()
255- fake_substrate .websocket .sock .getsockopt .return_value = 0
256- mocker .patch .object (
257- subtensor_module , "SubstrateInterface" , return_value = fake_substrate
258- )
259- fake_websocket = mocker .MagicMock ()
260- fake_websocket .client .connect .return_value = 0
261- mocker .patch .object (subtensor_module , "ws_client" , return_value = fake_websocket )
262- return Subtensor ()
263-
264-
265246@pytest .fixture
266247def mock_logger ():
267248 with mock .patch .object (logging , "warning" ) as mock_warning :
@@ -1925,37 +1906,26 @@ def test_reveal_weights_false(subtensor, mocker):
19251906 assert mocked_extrinsic .call_count == 5
19261907
19271908
1928- def test_connect_without_substrate (mocker ):
1929- """Ensure re-connection is called when using an alive substrate."""
1909+ def test_connect_without_substrate (subtensor , websockets_client_connection , mocker ):
1910+ """Ensure re-connection is called when using a disconnected substrate."""
19301911 # Prep
1931- fake_substrate = mocker .MagicMock ()
1932- fake_substrate .websocket .sock .getsockopt .return_value = 1
1933- mocker .patch .object (
1934- subtensor_module , "SubstrateInterface" , return_value = fake_substrate
1935- )
1936- fake_subtensor = Subtensor ()
1912+ websockets_client_connection .socket .getsockopt .return_value = 1
19371913 spy_get_substrate = mocker .spy (Subtensor , "_get_substrate" )
19381914
19391915 # Call
1940- _ = fake_subtensor .block
1916+ _ = subtensor .block
19411917
19421918 # Assertions
19431919 assert spy_get_substrate .call_count == 1
19441920
19451921
1946- def test_connect_with_substrate (mocker ):
1922+ def test_connect_with_substrate (subtensor , mocker ):
19471923 """Ensure re-connection is non called when using an alive substrate."""
19481924 # Prep
1949- fake_substrate = mocker .MagicMock ()
1950- fake_substrate .websocket .socket .getsockopt .return_value = 0
1951- mocker .patch .object (
1952- subtensor_module , "SubstrateInterface" , return_value = fake_substrate
1953- )
1954- fake_subtensor = Subtensor ()
19551925 spy_get_substrate = mocker .spy (Subtensor , "_get_substrate" )
19561926
19571927 # Call
1958- _ = fake_subtensor .block
1928+ _ = subtensor .block
19591929
19601930 # Assertions
19611931 assert spy_get_substrate .call_count == 0
0 commit comments