From 6254f53716e29a27536ae157ab661d7fca731d16 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 8 Jul 2021 03:41:51 -0300 Subject: [PATCH 1/3] propagate external ip changes from upnp component to dht node protocol --- lbry/extras/daemon/components.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lbry/extras/daemon/components.py b/lbry/extras/daemon/components.py index e55ec342d..822022f32 100644 --- a/lbry/extras/daemon/components.py +++ b/lbry/extras/daemon/components.py @@ -481,6 +481,10 @@ class UPnPComponent(Component): log.info("external ip changed from %s to %s", self.external_ip, external_ip) if external_ip: self.external_ip = external_ip + dht_component = self.component_manager.get_component(DHT_COMPONENT) + if dht_component: + dht_node = dht_component.component + dht_node.protocol.external_ip = external_ip # assert self.external_ip is not None # TODO: handle going/starting offline if not self.upnp_redirects and self.upnp: # setup missing redirects From 9b3b609e40fa39b9fb5a9e1403e3adafea9607ff Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 8 Jul 2021 03:46:48 -0300 Subject: [PATCH 2/3] re-enable test_losing_connection --- tests/unit/dht/test_node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/dht/test_node.py b/tests/unit/dht/test_node.py index a5e599f9b..5c502f9a7 100644 --- a/tests/unit/dht/test_node.py +++ b/tests/unit/dht/test_node.py @@ -92,7 +92,7 @@ class TestNodePingQueueDiscover(AsyncioTestCase): class TestTemporarilyLosingConnection(AsyncioTestCase): - @unittest.SkipTest + TIMEOUT = None # not supported as it advances time async def test_losing_connection(self): async def wait_for(check_ok, insist, timeout=20): start = loop.time() From c519d4651bf44df18561345615446455e9b2d3fd Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 8 Jul 2021 03:55:21 -0300 Subject: [PATCH 3/3] loop.time is not usable on advance time, use wall time --- tests/unit/dht/test_node.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/dht/test_node.py b/tests/unit/dht/test_node.py index 5c502f9a7..75f999a75 100644 --- a/tests/unit/dht/test_node.py +++ b/tests/unit/dht/test_node.py @@ -1,4 +1,5 @@ import asyncio +import time import unittest import typing from lbry.testcase import AsyncioTestCase @@ -95,8 +96,8 @@ class TestTemporarilyLosingConnection(AsyncioTestCase): TIMEOUT = None # not supported as it advances time async def test_losing_connection(self): async def wait_for(check_ok, insist, timeout=20): - start = loop.time() - while loop.time() - start < timeout: + start = time.time() + while time.time() - start < timeout: if check_ok(): break await asyncio.sleep(0)