From 733e356e55d33dbc37ef6f7e3d77b00389483f3e Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Sat, 4 Nov 2017 15:12:59 -0400 Subject: [PATCH] Fix failing ConnectionManager unit test --- CHANGELOG.md | 1 + .../core/client/test_ConnectionManager.py | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa8c2cb74..4fc543be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ at anytime. ### Fixed * Fixed amount of close nodes to add to list in case of extension to neighbouring k-buckets * Fixed external IP detection via jsonip.com (avoid detecting IPv6) + * Fixed failing ConnectionManager unit test for parallel connections * ### Deprecated diff --git a/lbrynet/tests/unit/core/client/test_ConnectionManager.py b/lbrynet/tests/unit/core/client/test_ConnectionManager.py index 2ff55ae32..107afa997 100644 --- a/lbrynet/tests/unit/core/client/test_ConnectionManager.py +++ b/lbrynet/tests/unit/core/client/test_ConnectionManager.py @@ -184,7 +184,6 @@ class TestIntegrationConnectionManager(unittest.TestCase): self.assertEqual(0, self.TEST_PEER.success_count) self.assertEqual(1, self.TEST_PEER.down_count) - @unittest.SkipTest @defer.inlineCallbacks def test_parallel_connections(self): # Test to see that we make two new connections at a manage call, @@ -197,16 +196,21 @@ class TestIntegrationConnectionManager(unittest.TestCase): self.assertEqual(2, self.connection_manager.num_peer_connections()) self.assertIn(self.TEST_PEER, self.connection_manager._peer_connections) self.assertIn(test_peer2, self.connection_manager._peer_connections) - connection_made = yield self.connection_manager._peer_connections[self.TEST_PEER].\ + + deferred_conn_made_peer1 = self.connection_manager._peer_connections[self.TEST_PEER].\ factory.connection_was_made_deferred - self.assertFalse(connection_made) - self.assertEqual(1, self.connection_manager.num_peer_connections()) + deferred_conn_made_peer1.addCallback(lambda conn_made: self.assertFalse(conn_made)) + + deferred_conn_made_peer2 = self.connection_manager._peer_connections[test_peer2].\ + factory.connection_was_made_deferred + deferred_conn_made_peer2.addCallback(lambda conn_made: self.assertFalse(conn_made)) + + yield deferred_conn_made_peer1 + yield deferred_conn_made_peer2 + + self.assertEqual(0, self.connection_manager.num_peer_connections()) self.assertEqual(0, self.TEST_PEER.success_count) self.assertEqual(1, self.TEST_PEER.down_count) - connection_made = yield self.connection_manager._peer_connections[test_peer2].\ - factory.connection_was_made_deferred - self.assertFalse(connection_made) - self.assertEqual(0, self.connection_manager.num_peer_connections()) self.assertEqual(0, test_peer2.success_count) self.assertEqual(1, test_peer2.down_count)