From 6be50a4f0a7a96c1b01975c70443e59ea5763158 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 20 Dec 2019 17:03:00 -0800 Subject: [PATCH 1/2] dilate/test_manager: tolerate Mock endpoints This test was incorrectly exercising a member of the endpoint record returned by `Manager.get_endpoints()`. In the test environment, the `.listen` Endpoint is actually a Mock, so calling e.g. `listen()` on `endpoints.listen` returns another Mock instead of a Deferred. Twisted's `assertNoResult` used to tolerate this silently, but as of Twisted-19.10 it throws an error, causing the test to fail. The fix is to assert that the record has attributes with the right names, but not assume they behave like normal Endpoints, and not call `.listen()` on them. closes #366 --- src/wormhole/test/dilate/test_manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wormhole/test/dilate/test_manager.py b/src/wormhole/test/dilate/test_manager.py index d8aa8ab..d2c9d99 100644 --- a/src/wormhole/test/dilate/test_manager.py +++ b/src/wormhole/test/dilate/test_manager.py @@ -237,6 +237,11 @@ class TestManager(unittest.TestCase): ]) clear_mock_calls(h.inbound) + eps = m.get_endpoints() + self.assertTrue(hasattr(eps, "control")) + self.assertTrue(hasattr(eps, "connect")) + self.assertEqual(eps.listen, h.listen_ep) + m.got_wormhole_versions({"can-dilate": ["1"]}) self.assertEqual(h.send.mock_calls, [ mock.call.send("dilate-0", @@ -244,9 +249,6 @@ class TestManager(unittest.TestCase): ]) clear_mock_calls(h.send) - listen_d = m.get_endpoints().listen.listen(None) - self.assertNoResult(listen_d) - # ignore early hints m.rx_HINTS({}) self.assertEqual(h.send.mock_calls, []) @@ -267,8 +269,6 @@ class TestManager(unittest.TestCase): self.assertEqual(c.mock_calls, [mock.call.start()]) clear_mock_calls(connector, c) - self.assertNoResult(listen_d) - # now any inbound hints should get passed to our Connector with mock.patch("wormhole._dilation.manager.parse_hint", side_effect=["p1", None, "p3"]) as ph: From a1420a0a34865dbd0030f51e13d345ec46ba062b Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 20 Dec 2019 17:06:30 -0800 Subject: [PATCH 2/2] manager.py: fix typo in comments --- src/wormhole/_dilation/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wormhole/_dilation/manager.py b/src/wormhole/_dilation/manager.py index 096b459..97c9faf 100644 --- a/src/wormhole/_dilation/manager.py +++ b/src/wormhole/_dilation/manager.py @@ -92,7 +92,7 @@ def make_side(): # can send HINTS, but it must not be given any HINTS that arrive before # RECONNECTING (since they're probably stale) -# * after VERSIONS(KCM) received, we might learn that they other side cannot +# * after VERSIONS(KCM) received, we might learn that the other side cannot # dilate. w.dilate errbacks at this point # * maybe signal warning if we stay in a "want" state for too long