MiNode/minode/tests/test_network.py

32 lines
935 B
Python

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