Started a test case for network with a test for bootstrapping
This commit is contained in:
parent
bb65e7f0b9
commit
0513e6f84e
31
minode/tests/test_network.py
Normal file
31
minode/tests/test_network.py
Normal 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))
|
Loading…
Reference in New Issue
Block a user