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 39f92fd1b2
commit 210284acc9
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
1 changed files with 31 additions and 0 deletions

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))