lbry-sdk/lbrynet/tests/functional/dht/test_contact_rejoin.py

39 lines
1.3 KiB
Python
Raw Normal View History

2018-05-24 18:57:20 +02:00
import logging
from twisted.internet import defer
2018-05-29 22:22:30 +02:00
from lbrynet.dht import constants
2018-05-24 18:57:20 +02:00
from dht_test_environment import TestKademliaBase
log = logging.getLogger()
class TestReJoin(TestKademliaBase):
network_size = 40
@defer.inlineCallbacks
2018-05-29 22:22:30 +02:00
def setUp(self):
yield super(TestReJoin, self).setUp()
self.removed_node = self.nodes[20]
self.nodes.remove(self.removed_node)
yield self.run_reactor(1, [self.removed_node.stop()])
self.pump_clock(constants.checkRefreshInterval * 2)
2018-05-24 18:57:20 +02:00
self.verify_all_nodes_are_routable()
self.verify_all_nodes_are_pingable()
@defer.inlineCallbacks
2018-05-29 22:22:30 +02:00
def test_re_join(self):
self.nodes.append(self.removed_node)
2018-05-24 18:57:20 +02:00
yield self.run_reactor(
2018-05-29 22:22:30 +02:00
31, [self.removed_node.start([(seed_name, 4444) for seed_name in sorted(self.seed_dns.keys())])]
2018-05-24 18:57:20 +02:00
)
2018-05-29 22:22:30 +02:00
self.pump_clock(constants.checkRefreshInterval*2)
2018-05-24 18:57:20 +02:00
self.verify_all_nodes_are_routable()
self.verify_all_nodes_are_pingable()
2018-05-29 22:22:30 +02:00
def test_re_join_with_new_ip(self):
self.removed_node.externalIP = "10.43.43.43"
return self.test_re_join()
2018-05-24 18:57:20 +02:00
2018-05-29 22:22:30 +02:00
def test_re_join_with_new_node_id(self):
self.removed_node.node_id = self.removed_node._generateID()
return self.test_re_join()