dht test environment fixes
This commit is contained in:
parent
51b42da1c5
commit
545930cea4
2 changed files with 10 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer, task
|
||||
from lbrynet.dht import constants
|
||||
from lbrynet.dht.node import Node
|
||||
from mock_transport import resolve, listenUDP, MOCK_DHT_SEED_DNS, mock_node_generator
|
||||
|
||||
|
@ -110,14 +111,14 @@ class TestKademliaBase(unittest.TestCase):
|
|||
seed_dl.append(
|
||||
seed.start(known_addresses)
|
||||
)
|
||||
yield self.run_reactor(901, seed_dl)
|
||||
yield self.run_reactor(constants.checkRefreshInterval+1, seed_dl)
|
||||
while len(self.nodes + self._seeds) < self.network_size:
|
||||
network_dl = []
|
||||
for i in range(min(10, self.network_size - len(self._seeds) - len(self.nodes))):
|
||||
network_dl.append(self.add_node())
|
||||
yield self.run_reactor(31, network_dl)
|
||||
yield self.run_reactor(constants.checkRefreshInterval*2+1, network_dl)
|
||||
self.assertEqual(len(self.nodes + self._seeds), self.network_size)
|
||||
self.pump_clock(1800)
|
||||
self.pump_clock(3600)
|
||||
self.verify_all_nodes_are_routable()
|
||||
self.verify_all_nodes_are_pingable()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import struct
|
||||
import hashlib
|
||||
import logging
|
||||
from twisted.internet import defer, error
|
||||
from lbrynet.core.utils import generate_id
|
||||
from lbrynet.dht.encoding import Bencode
|
||||
from lbrynet.dht.error import DecodeError
|
||||
from lbrynet.dht.msgformat import DefaultFormat
|
||||
|
@ -121,7 +121,9 @@ def mock_node_generator(count=None, mock_node_ids=MOCK_DHT_NODES):
|
|||
if count and num >= count:
|
||||
break
|
||||
if num >= len(mock_node_ids):
|
||||
node_id = generate_id().encode('hex')
|
||||
h = hashlib.sha384()
|
||||
h.update("node %i" % num)
|
||||
node_id = h.hexdigest()
|
||||
else:
|
||||
node_id = mock_node_ids[num]
|
||||
yield (node_id, node_ip)
|
||||
|
|
Loading…
Reference in a new issue