From 519614b2fdbba3e32a2d90d3de7c9e9ceae732ee Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Sun, 17 Jan 2021 15:53:13 -0500 Subject: [PATCH] skip libtorrent component in tests --- lbry/extras/daemon/components.py | 9 ++++++--- lbry/testcase.py | 8 ++++++-- tests/integration/datanetwork/test_file_commands.py | 4 ++++ tests/integration/other/test_cli.py | 6 ++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lbry/extras/daemon/components.py b/lbry/extras/daemon/components.py index 38c4d4650..50c45612a 100644 --- a/lbry/extras/daemon/components.py +++ b/lbry/extras/daemon/components.py @@ -328,7 +328,7 @@ class HashAnnouncerComponent(Component): class FileManagerComponent(Component): component_name = FILE_MANAGER_COMPONENT - depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT, LIBTORRENT_COMPONENT] + depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT] def __init__(self, component_manager): super().__init__(component_manager) @@ -351,7 +351,10 @@ class FileManagerComponent(Component): wallet = self.component_manager.get_component(WALLET_COMPONENT) node = self.component_manager.get_component(DHT_COMPONENT) \ if self.component_manager.has_component(DHT_COMPONENT) else None - torrent = self.component_manager.get_component(LIBTORRENT_COMPONENT) if TorrentSession else None + try: + torrent = self.component_manager.get_component(LIBTORRENT_COMPONENT) if TorrentSession else None + except NameError: + torrent = None log.info('Starting the file manager') loop = asyncio.get_event_loop() self.file_manager = FileManager( @@ -360,7 +363,7 @@ class FileManagerComponent(Component): self.file_manager.source_managers['stream'] = StreamManager( loop, self.conf, blob_manager, wallet, storage, node, ) - if TorrentSession: + if TorrentSession and LIBTORRENT_COMPONENT not in self.conf.components_to_skip: self.file_manager.source_managers['torrent'] = TorrentManager( loop, self.conf, torrent, storage, self.component_manager.analytics_manager ) diff --git a/lbry/testcase.py b/lbry/testcase.py index 1efefff17..0c72279b5 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -23,8 +23,9 @@ from lbry.wallet.orchstr8.node import BlockchainNode, WalletNode from lbry.extras.daemon.daemon import Daemon, jsonrpc_dumps_pretty from lbry.extras.daemon.components import Component, WalletComponent from lbry.extras.daemon.components import ( - DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT, - UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT + DHT_COMPONENT, + HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT, + UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, LIBTORRENT_COMPONENT ) from lbry.extras.daemon.componentmanager import ComponentManager from lbry.extras.daemon.exchange_rate_manager import ( @@ -320,6 +321,7 @@ class CommandTestCase(IntegrationTestCase): self.server_blob_manager = None self.server = None self.reflector = None + self.skip_libtorrent = True async def asyncSetUp(self): await super().asyncSetUp() @@ -395,6 +397,8 @@ class CommandTestCase(IntegrationTestCase): DHT_COMPONENT, UPNP_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT ] + if self.skip_libtorrent: + conf.components_to_skip.append(LIBTORRENT_COMPONENT) wallet_node.manager.config = conf def wallet_maker(component_manager): diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index df46c6fab..b2532db45 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -9,6 +9,10 @@ from lbry.wallet import Transaction class FileCommands(CommandTestCase): + def __init__(self, *a, **kw): + super().__init__(*a, **kw) + self.skip_libtorrent = False + async def initialize_torrent(self, tx_to_update=None): if not hasattr(self, 'seeder_session'): self.seeder_session = TorrentSession(self.loop, None) diff --git a/tests/integration/other/test_cli.py b/tests/integration/other/test_cli.py index 459d2171a..a08bb9895 100644 --- a/tests/integration/other/test_cli.py +++ b/tests/integration/other/test_cli.py @@ -7,7 +7,8 @@ from lbry.extras import cli from lbry.extras.daemon.components import ( DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT, - UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT + UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT, + LIBTORRENT_COMPONENT ) from lbry.extras.daemon.daemon import Daemon @@ -22,7 +23,8 @@ class CLIIntegrationTest(AsyncioTestCase): conf.components_to_skip = ( DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT, - UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT + UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT, + LIBTORRENT_COMPONENT ) Daemon.component_attributes = {} self.daemon = Daemon(conf)