Skip to content

Commit

Permalink
Fixing functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hackrush01 committed May 18, 2018
1 parent 9af75f2 commit 5570bad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
23 changes: 1 addition & 22 deletions lbrynet/core/Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Session(object):
peers can connect to this peer.
"""

def __init__(self, blob_data_payment_rate, db_dir=None, node_id=None, peer_manager=None, dht_node_port=None,
def __init__(self, blob_data_payment_rate, db_dir=None, node_id=None, dht_node_port=None,
known_dht_nodes=None, peer_finder=None, hash_announcer=None, blob_dir=None, blob_manager=None,
peer_port=None, use_upnp=True, rate_limiter=None, wallet=None, dht_node_class=node.Node,
blob_tracker_class=None, payment_rate_manager_class=None, is_generous=True, external_ip=None,
Expand Down Expand Up @@ -94,7 +94,6 @@ def __init__(self, blob_data_payment_rate, db_dir=None, node_id=None, peer_manag
"""
self.db_dir = db_dir
self.node_id = node_id
self.peer_manager = peer_manager
self.peer_finder = peer_finder
self.hash_announcer = hash_announcer
self.dht_node_port = dht_node_port
Expand Down Expand Up @@ -125,9 +124,6 @@ def setup(self):

log.debug("Starting session.")

if self.peer_manager is None:
self.peer_manager = self.dht_node.peer_manager

if self.peer_finder is None:
self.peer_finder = self.dht_node.peer_finder

Expand Down Expand Up @@ -214,23 +210,6 @@ def upnp_failed(err):
d.addErrback(upnp_failed)
return d

def _setup_dht(self): # does not block startup, the dht will re-attempt if necessary
self.dht_node = self.dht_node_class(
node_id=self.node_id,
udpPort=self.dht_node_port,
externalIP=self.external_ip,
peerPort=self.peer_port,
peer_manager=self.peer_manager,
peer_finder=self.peer_finder,
)
if not self.hash_announcer:
self.hash_announcer = hashannouncer.DHTHashAnnouncer(self.dht_node, self.storage)
self.peer_manager = self.dht_node.peer_manager
self.peer_finder = self.dht_node.peer_finder
self._join_dht_deferred = self.dht_node.joinNetwork(self.known_dht_nodes)
self._join_dht_deferred.addCallback(lambda _: log.info("Joined the dht"))
self._join_dht_deferred.addCallback(lambda _: self.hash_announcer.start())

def _setup_other_components(self):
log.debug("Setting up the rest of the components")

Expand Down
11 changes: 9 additions & 2 deletions lbrynet/tests/functional/test_streamify.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from lbrynet.core.StreamDescriptor import get_sd_info
from lbrynet.core.PeerManager import PeerManager
from lbrynet.core.RateLimiter import DummyRateLimiter
from lbrynet.daemon.Component import ComponentManager

from lbrynet.tests import mocks

Expand All @@ -26,6 +27,7 @@
GenFile = mocks.GenFile
test_create_stream_sd_file = mocks.create_stream_sd_file
DummyBlobAvailabilityTracker = mocks.BlobAvailabilityTracker
component_manager = ComponentManager


class TestStreamify(TestCase):
Expand Down Expand Up @@ -60,14 +62,19 @@ def test_create_stream(self):
hash_announcer = FakeAnnouncer()
rate_limiter = DummyRateLimiter()
sd_identifier = StreamDescriptorIdentifier()
dht_component = ComponentManager.get_component('dht')
dht_component.dht_node_class = FakeNode
dht_component.hash_announcer = FakeAnnouncer()
dht_component.setup()
dht_node = dht_component.dht_node

self.session = Session(
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, node_id="abcd",
peer_finder=peer_finder, hash_announcer=hash_announcer,
peer_finder=peer_finder,
blob_dir=self.blob_dir, peer_port=5553,
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
blob_tracker_class=DummyBlobAvailabilityTracker,
is_generous=self.is_generous, external_ip="127.0.0.1", dht_node_class=mocks.Node
is_generous=self.is_generous, external_ip="127.0.0.1", dht_node=dht_node
)

self.lbry_file_manager = EncryptedFileManager(self.session, sd_identifier)
Expand Down

0 comments on commit 5570bad

Please sign in to comment.