@@ -21,6 +21,7 @@ class TestMoneroConnectionManager:
2121 """Proxy used to simulate offline servers"""
2222
2323 _cm : MoneroConnectionManager | None = None
24+ """Connection manager test instance."""
2425
2526 #region Fixtures
2627
@@ -122,7 +123,7 @@ def test_connection_manager(self, connection_manager: MoneroConnectionManager, c
122123
123124 # auto connect to the best available connection
124125 connection_manager .start_polling (Utils .SYNC_PERIOD_IN_MS )
125- listener .wait_for_change (Utils .SYNC_PERIOD_IN_MS , "Waiting for auto connect to best available connection" )
126+ listener .wait_for_change (num_expected_changes + 1 , Utils .SYNC_PERIOD_IN_MS , f "Waiting for auto connect to best available connection" )
126127 assert connection_manager .is_connected ()
127128 connection = connection_manager .get_connection ()
128129 assert connection is not None
@@ -166,7 +167,7 @@ def test_connection_manager(self, connection_manager: MoneroConnectionManager, c
166167 continue
167168 conn .proxy_uri = self .OFFLINE_PROXY_URI
168169
169- listener .wait_for_change (Utils .SYNC_PERIOD_IN_MS , "Simulating priotizized servers shut down" )
170+ listener .wait_for_change (num_expected_changes + 1 , Utils .SYNC_PERIOD_IN_MS , "Simulating priotizized servers shut down" )
170171 assert connection_manager .is_connected () is False , f"{ connection_manager .get_connection ().serialize ()} "
171172 connection = connection_manager .get_connection ()
172173
@@ -330,7 +331,7 @@ def test_connection_manager(self, connection_manager: MoneroConnectionManager, c
330331 poll_type = MoneroConnectionPollType .CURRENT
331332 )
332333
333- listener .wait_for_change (Utils .SYNC_PERIOD_IN_MS , "Polling current connection" )
334+ listener .wait_for_change (num_expected_changes + 1 , Utils .SYNC_PERIOD_IN_MS , "Polling current connection" )
334335 assert connection_manager .is_connected () is True
335336 num_expected_changes += 1
336337 assert num_expected_changes == listener .num_changed_connections
@@ -340,7 +341,7 @@ def test_connection_manager(self, connection_manager: MoneroConnectionManager, c
340341 num_expected_changes += 1
341342 assert num_expected_changes == listener .num_changed_connections
342343 connection_manager .start_polling (period_ms = Utils .SYNC_PERIOD_IN_MS , poll_type = MoneroConnectionPollType .ALL )
343- listener .wait_for_change (Utils .SYNC_PERIOD_IN_MS , "Polling all connections" )
344+ listener .wait_for_change (num_expected_changes + 1 , Utils .SYNC_PERIOD_IN_MS , "Polling all connections" )
344345 assert connection_manager .is_connected () is True
345346 num_expected_changes += 1
346347 assert num_expected_changes == listener .num_changed_connections
@@ -351,7 +352,7 @@ def test_connection_manager(self, connection_manager: MoneroConnectionManager, c
351352 for con in ordered_connections :
352353 con .proxy_uri = self .OFFLINE_PROXY_URI
353354
354- listener .wait_for_change (Utils .SYNC_PERIOD_IN_MS , "Simulating total shut down" )
355+ listener .wait_for_change (num_expected_changes + 1 , Utils .SYNC_PERIOD_IN_MS , "Simulating total shut down" )
355356 assert connection .is_online () is False , f"Expected offline connection: { connection .serialize ()} "
356357 num_expected_changes += 1
357358 assert num_expected_changes == listener .num_changed_connections
0 commit comments