diff --git a/lbrynet/tests/functional/test_misc.py b/lbrynet/tests/functional/test_misc.py index 355fa1d14..e806da5c2 100644 --- a/lbrynet/tests/functional/test_misc.py +++ b/lbrynet/tests/functional/test_misc.py @@ -22,7 +22,6 @@ from twisted.internet import defer, threads, task from twisted.trial.unittest import TestCase from twisted.python.failure import Failure -from lbrynet.dht.node import Node from lbrynet.core.PeerManager import PeerManager from lbrynet.core.RateLimiter import DummyRateLimiter, RateLimiter from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory @@ -115,7 +114,7 @@ class LbryUploader(object): node_id="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer, peer_port=5553, dht_node_port=4445, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet, blob_tracker_class=DummyBlobAvailabilityTracker, - dht_node_class=Node, is_generous=self.is_generous, external_ip="127.0.0.1") + dht_node_class=FakeNode, is_generous=self.is_generous, external_ip="127.0.0.1") self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier) if self.ul_rate_limit is not None: self.session.rate_limiter.set_ul_limit(self.ul_rate_limit) @@ -207,7 +206,7 @@ def start_lbry_reuploader(sd_hash, kill_event, dead_event, db_dir, blob_dir = mk_db_and_blob_dir() session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, - node_id="abcd" + str(n), dht_node_port=4446, + node_id="abcd" + str(n), dht_node_port=4446, dht_node_class=FakeNode, peer_finder=peer_finder, hash_announcer=hash_announcer, blob_dir=blob_dir, peer_port=peer_port, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet, @@ -315,7 +314,7 @@ def start_blob_uploader(blob_hash_queue, kill_event, dead_event, slow, is_genero db_dir, blob_dir = mk_db_and_blob_dir() session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, node_id="efgh", - peer_finder=peer_finder, hash_announcer=hash_announcer, + peer_finder=peer_finder, hash_announcer=hash_announcer, dht_node_class=FakeNode, blob_dir=blob_dir, peer_port=peer_port, dht_node_port=4446, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet, blob_tracker_class=DummyBlobAvailabilityTracker, @@ -497,7 +496,7 @@ class TestTransfer(TestCase): blob_dir=blob_dir, peer_port=5553, dht_node_port=4445, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet, blob_tracker_class=DummyBlobAvailabilityTracker, - dht_node_class=Node, is_generous=self.is_generous, external_ip="127.0.0.1") + dht_node_class=FakeNode, is_generous=self.is_generous, external_ip="127.0.0.1") self.lbry_file_manager = EncryptedFileManager( self.session, sd_identifier) @@ -582,7 +581,7 @@ class TestTransfer(TestCase): self.session = Session( conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, node_id="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer, - blob_dir=blob_dir, peer_port=5553, dht_node_port=4445, + blob_dir=blob_dir, peer_port=5553, dht_node_port=4445, dht_node_class=FakeNode, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet, blob_tracker_class=DummyBlobAvailabilityTracker, is_generous=conf.ADJUSTABLE_SETTINGS['is_generous_host'][1], external_ip="127.0.0.1") @@ -662,7 +661,7 @@ class TestTransfer(TestCase): db_dir, blob_dir = mk_db_and_blob_dir() self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, - node_id="abcd", peer_finder=peer_finder, dht_node_port=4445, + node_id="abcd", peer_finder=peer_finder, dht_node_port=4445, dht_node_class=FakeNode, hash_announcer=hash_announcer, blob_dir=blob_dir, peer_port=5553, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet, blob_tracker_class=DummyBlobAvailabilityTracker, @@ -769,7 +768,7 @@ class TestTransfer(TestCase): sd_identifier = StreamDescriptorIdentifier() db_dir, blob_dir = mk_db_and_blob_dir() - self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, + self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, dht_node_class=FakeNode, node_id="abcd", peer_finder=peer_finder, dht_node_port=4445, hash_announcer=hash_announcer, blob_dir=blob_dir, peer_port=5553, use_upnp=False, rate_limiter=rate_limiter, diff --git a/lbrynet/tests/mocks.py b/lbrynet/tests/mocks.py index d4c52a2cd..d2bce3730 100644 --- a/lbrynet/tests/mocks.py +++ b/lbrynet/tests/mocks.py @@ -9,6 +9,7 @@ from lbrynet.core.client.ClientRequest import ClientRequest from lbrynet.core.Error import RequestCanceledError from lbrynet.core import BlobAvailability from lbrynet.core.utils import generate_id +from lbrynet.dht.node import Node as RealNode from lbrynet.daemon import ExchangeRateManager as ERM from lbrynet import conf from util import debug_kademlia_packet @@ -24,15 +25,9 @@ class FakeLBRYFile(object): self.file_name = 'fake_lbry_file' -class Node(object): - def __init__(self, peer_finder=None, peer_manager=None, dht_node_port=None, peer_port=3333, **kwargs): - self.peer_finder = peer_finder - self.peer_manager = peer_manager - self.peerPort = peer_port - self.udpPort = dht_node_port - - def joinNetwork(self, *args): - return defer.succeed(True) +class Node(RealNode): + def joinNetwork(self, known_node_addresses=None): + return defer.succeed(None) def stop(self): return defer.succeed(None) @@ -392,6 +387,7 @@ create_stream_sd_file = { def mock_conf_settings(obj, settings={}): + conf.initialize_settings(False) original_settings = conf.settings conf.settings = conf.Config(conf.FIXED_SETTINGS, conf.ADJUSTABLE_SETTINGS) conf.settings.installation_id = conf.settings.get_installation_id() diff --git a/lbrynet/tests/unit/core/client/test_ConnectionManager.py b/lbrynet/tests/unit/core/client/test_ConnectionManager.py index 107afa997..61f177127 100644 --- a/lbrynet/tests/unit/core/client/test_ConnectionManager.py +++ b/lbrynet/tests/unit/core/client/test_ConnectionManager.py @@ -116,7 +116,7 @@ class MocServerProtocolFactory(ServerFactory): class TestIntegrationConnectionManager(unittest.TestCase): def setUp(self): - conf.initialize_settings() + conf.initialize_settings(False) self.TEST_PEER = Peer(LOCAL_HOST, PEER_PORT) self.downloader = MocDownloader() diff --git a/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py b/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py index 0d3999c0b..2f67d5567 100644 --- a/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py +++ b/lbrynet/tests/unit/core/server/test_DHTHashAnnouncer.py @@ -34,7 +34,7 @@ class DHTHashAnnouncerTest(unittest.TestCase): @defer.inlineCallbacks def setUp(self): from lbrynet.conf import initialize_settings - initialize_settings() + initialize_settings(False) self.num_blobs = 10 self.blobs_to_announce = [] for i in range(0, self.num_blobs): diff --git a/lbrynet/tests/unit/core/test_BlobManager.py b/lbrynet/tests/unit/core/test_BlobManager.py index 48b6df982..7526ee2fc 100644 --- a/lbrynet/tests/unit/core/test_BlobManager.py +++ b/lbrynet/tests/unit/core/test_BlobManager.py @@ -17,7 +17,7 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj class BlobManagerTest(unittest.TestCase): @defer.inlineCallbacks def setUp(self): - conf.initialize_settings() + conf.initialize_settings(False) self.blob_dir = tempfile.mkdtemp() self.db_dir = tempfile.mkdtemp() self.bm = DiskBlobManager(self.blob_dir, SQLiteStorage(self.db_dir)) diff --git a/lbrynet/tests/unit/database/test_SQLiteStorage.py b/lbrynet/tests/unit/database/test_SQLiteStorage.py index 7cd69c3ff..5bfe72988 100644 --- a/lbrynet/tests/unit/database/test_SQLiteStorage.py +++ b/lbrynet/tests/unit/database/test_SQLiteStorage.py @@ -85,7 +85,7 @@ class StorageTest(unittest.TestCase): @defer.inlineCallbacks def setUp(self): - conf.initialize_settings() + conf.initialize_settings(False) self.db_dir = tempfile.mkdtemp() self.storage = SQLiteStorage(self.db_dir) yield self.storage.setup() diff --git a/lbrynet/tests/unit/lbrynet_daemon/auth/test_server.py b/lbrynet/tests/unit/lbrynet_daemon/auth/test_server.py index ea1cefb55..80fa4aa7c 100644 --- a/lbrynet/tests/unit/lbrynet_daemon/auth/test_server.py +++ b/lbrynet/tests/unit/lbrynet_daemon/auth/test_server.py @@ -1,6 +1,6 @@ import mock from twisted.trial import unittest - +from lbrynet import conf from lbrynet.tests.mocks import mock_conf_settings from lbrynet.daemon.auth import server @@ -10,6 +10,7 @@ class AuthJSONRPCServerTest(unittest.TestCase): # and add useful general utilities like this # onto it. def setUp(self): + conf.initialize_settings(False) self.server = server.AuthJSONRPCServer(use_authentication=False) def test_get_server_port(self):