Started a test case for network with a test for bootstrapping

This commit is contained in:
Lee Miller 2023-08-20 06:48:05 +03:00
parent bb65e7f0b9
commit 0513e6f84e
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -0,0 +1,31 @@
"""Tests for network connections"""
import unittest
from minode import connection, main, shared
class TestNetwork(unittest.TestCase):
"""Test case starting connections"""
def test_bootstrap(self):
"""Start bootstrappers and check node pool"""
if shared.core_nodes:
shared.core_nodes = set()
if shared.unchecked_node_pool:
shared.unchecked_node_pool = set()
main.bootstrap_from_dns()
self.assertGreater(len(shared.core_nodes), 1)
self.assertEqual(len(shared.unchecked_node_pool), 0)
for node in shared.core_nodes:
c = connection.Bootstrapper(*node)
c.start()
c.join()
if len(shared.unchecked_node_pool) > 2:
break
else:
self.fail(
'Failed to find at least 2 nodes'
' after running %s bootstrappers' % len(shared.core_nodes))