From b385e6f9c4ccb15e720d64075d8084c2ce5b20cd Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Wed, 17 Jul 2024 13:31:26 +0300 Subject: [PATCH] Test bootstrapping with a minode process --- minode/tests/test_network.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/minode/tests/test_network.py b/minode/tests/test_network.py index f1ae7df..c683637 100644 --- a/minode/tests/test_network.py +++ b/minode/tests/test_network.py @@ -249,3 +249,31 @@ class TestListener(TestProcessProto): if c.status == 'fully_established': self.fail('Established a connection') time.sleep(0.5) + + +class TestBootstrapProcess(TestProcessProto): + """A separate test case for bootstrapping with a minode process""" + _listen = True + _connection_limit = 24 + + def test_bootstrap(self): + """Start a bootstrapper for the local process and check node pool""" + if shared.unchecked_node_pool: + shared.unchecked_node_pool = set() + + started = time.time() + while not self.connections(): + if time.time() - started > 60: + self.fail('Failed to establish a connection') + time.sleep(1) + + for _ in range(3): + c = connection.Bootstrapper('127.0.0.1', 8444) + c.start() + c.join() + if len(shared.unchecked_node_pool) > 2: + break + else: + self.fail( + 'Failed to find at least 3 nodes' + ' after 3 tries to bootstrap with the local process')