Skip to content

Commit

Permalink
[electrum] better handle timeouts in test_interface
Browse files Browse the repository at this point in the history
Summary:
Tests are failing on CI because we don't catch the correct error for python < 3.10

badssl.com  seems to be unresponsive, lately. If this keeps happening, this test should be removed to not slow down the test suite unnecessarily.

Test Plan: `python -m electrumabc.tests.test_interface`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14619
  • Loading branch information
PiRK authored and abc-bot committed Oct 11, 2023
1 parent 3ef75be commit 00f88ad
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion electrumabc/tests/test_interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import socket
import ssl
import unittest

Expand All @@ -18,8 +19,14 @@ def has_ca_signed_valid_cert(self, server: str) -> bool:
else:
self.skipTest("This test requires an internet connection.")
return bool(s)
except TimeoutError:
except (TimeoutError, socket.timeout):
# In Python >= 3.10, socket.timeout is an alias for TimeoutError.
# For lower versions of python we need to catch both.
# socket.timeout is deprecated, so when support for Python 3.9 is
# dropped it should be removed.
retries += 1
# if we are here, it means the request keeps timing out
self.skipTest(f"Skipping test after 5 timeouts. {server} must be down.")

def test_verify_good_ca_cert(self):
# These are also a wildcard certificate
Expand Down

0 comments on commit 00f88ad

Please sign in to comment.