From 971b661d3cfc3e3b37bd22d7d11d159465e32577 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Mon, 8 Jul 2024 01:33:01 +0300 Subject: [PATCH] Check also the acceptable time offset --- minode/tests/test_network.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/minode/tests/test_network.py b/minode/tests/test_network.py index dbf5bc3..47b405a 100644 --- a/minode/tests/test_network.py +++ b/minode/tests/test_network.py @@ -127,19 +127,28 @@ class TestNetwork(unittest.TestCase): else: return 'Spent too much time trying to connect' - def time_offset_connections(nodes, offset): + def time_offset_bad_connections(nodes, offset): """Spoof time.time and open connections with given time offset""" with time_offset(offset) as time_call: result = try_connect(nodes, 200, time_call) if result: self.fail(result) + def time_offset_good_connections(nodes): + """Connect to at least one node with acceptable time offset""" + with time_offset(-3500) as time_call: + result = try_connect(nodes, 200, time_call) + if not result: + self.fail('Failed to connect with acceptable time offset') + self._make_initial_nodes() nodes = random.sample( tuple(shared.core_nodes.union(shared.unchecked_node_pool)), 5) - time_offset_connections(nodes, 4000) - time_offset_connections(nodes, -4000) + time_offset_bad_connections(nodes, 4000) + time_offset_bad_connections(nodes, -4000) + + time_offset_good_connections(nodes) class TestConnection(TestProcessProto):