diff --git a/experiment/popularity_community/initial_filling.py b/experiment/popularity_community/initial_filling.py index bc454716660..b5031b120ff 100644 --- a/experiment/popularity_community/initial_filling.py +++ b/experiment/popularity_community/initial_filling.py @@ -14,7 +14,7 @@ from ipv8_service import IPv8 from tribler_core.components.ipv8 import Ipv8Component from tribler_core.components.libtorrent import LibtorrentComponent -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent from tribler_core.components.popularity import PopularityComponent from tribler_core.components.restapi import RESTComponent diff --git a/experiment/tunnel_community/hidden_peer_discovery.py b/experiment/tunnel_community/hidden_peer_discovery.py index 5c36311aa23..3a5cc7c9853 100644 --- a/experiment/tunnel_community/hidden_peer_discovery.py +++ b/experiment/tunnel_community/hidden_peer_discovery.py @@ -6,7 +6,7 @@ from ipv8.taskmanager import TaskManager from tribler_core.components.ipv8 import Ipv8Component -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.restapi import RESTComponent from tribler_core.components.tunnels import TunnelsComponent from tribler_core.config.tribler_config import TriblerConfig diff --git a/experiment/tunnel_community/speed_test_exit.py b/experiment/tunnel_community/speed_test_exit.py index d9c91e8988b..fbe3a0a5ac3 100644 --- a/experiment/tunnel_community/speed_test_exit.py +++ b/experiment/tunnel_community/speed_test_exit.py @@ -6,7 +6,7 @@ from ipv8.messaging.anonymization.utils import run_speed_test from ipv8.taskmanager import TaskManager from tribler_core.components.ipv8 import Ipv8Component -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.restapi import RESTComponent from tribler_core.components.tunnels import TunnelsComponent from tribler_core.config.tribler_config import TriblerConfig diff --git a/src/tribler-core/tribler_core/components/bandwidth_accounting/tests/test_bandwidth_accounting_component.py b/src/tribler-core/tribler_core/components/bandwidth_accounting/tests/test_bandwidth_accounting_component.py index f13b42ed2b7..916ef585eac 100644 --- a/src/tribler-core/tribler_core/components/bandwidth_accounting/tests/test_bandwidth_accounting_component.py +++ b/src/tribler-core/tribler_core/components/bandwidth_accounting/tests/test_bandwidth_accounting_component.py @@ -5,7 +5,7 @@ from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent from tribler_core.components.base import Session from tribler_core.components.ipv8 import Ipv8Component -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.restapi import RESTComponent from tribler_core.restapi.rest_manager import RESTManager diff --git a/src/tribler-core/tribler_core/components/gigachannel/tests/test_gigachannel_component.py b/src/tribler-core/tribler_core/components/gigachannel/tests/test_gigachannel_component.py index 25a93807b09..4049b00b903 100644 --- a/src/tribler-core/tribler_core/components/gigachannel/tests/test_gigachannel_component.py +++ b/src/tribler-core/tribler_core/components/gigachannel/tests/test_gigachannel_component.py @@ -5,7 +5,7 @@ from tribler_core.components.base import Session from tribler_core.components.gigachannel.gigachannel_component import GigaChannelComponent from tribler_core.components.ipv8 import Ipv8Component -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent from tribler_core.components.restapi import RESTComponent from tribler_core.restapi.rest_manager import RESTManager diff --git a/src/tribler-core/tribler_core/components/gigachannel_manager/tests/test_gigachannel_manager_component.py b/src/tribler-core/tribler_core/components/gigachannel_manager/tests/test_gigachannel_manager_component.py index 3bcd2006e9a..285ac90e02c 100644 --- a/src/tribler-core/tribler_core/components/gigachannel_manager/tests/test_gigachannel_manager_component.py +++ b/src/tribler-core/tribler_core/components/gigachannel_manager/tests/test_gigachannel_manager_component.py @@ -5,7 +5,7 @@ from tribler_core.components.base import Session from tribler_core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent from tribler_core.components.libtorrent import LibtorrentComponent -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent from tribler_core.components.restapi import RESTComponent from tribler_core.components.socks_configurator import SocksServersComponent diff --git a/src/tribler-core/tribler_core/components/ipv8.py b/src/tribler-core/tribler_core/components/ipv8.py index 3c04697bded..2e16af25055 100644 --- a/src/tribler-core/tribler_core/components/ipv8.py +++ b/src/tribler-core/tribler_core/components/ipv8.py @@ -12,10 +12,8 @@ from ipv8.peerdiscovery.community import DiscoveryCommunity, PeriodicSimilarity from ipv8.peerdiscovery.discovery import RandomWalk from ipv8.taskmanager import TaskManager - from ipv8_service import IPv8 - -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.restapi import RestfulComponent INFINITE = -1 diff --git a/src/tribler-core/tribler_core/components/libtorrent.py b/src/tribler-core/tribler_core/components/libtorrent.py index 22ea5b57115..f9c4007380b 100644 --- a/src/tribler-core/tribler_core/components/libtorrent.py +++ b/src/tribler-core/tribler_core/components/libtorrent.py @@ -1,6 +1,6 @@ from tribler_common.simpledefs import STATE_CHECKPOINTS_LOADED, STATE_LOAD_CHECKPOINTS, STATE_START_LIBTORRENT -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.restapi import RestfulComponent from tribler_core.components.socks_configurator import SocksServersComponent from tribler_core.components.upgrade import UpgradeComponent diff --git a/src/tribler-core/tribler_core/components/masterkey/__init__.py b/src/tribler-core/tribler_core/components/masterkey/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/tribler-core/tribler_core/components/masterkey.py b/src/tribler-core/tribler_core/components/masterkey/masterkey_component.py similarity index 94% rename from src/tribler-core/tribler_core/components/masterkey.py rename to src/tribler-core/tribler_core/components/masterkey/masterkey_component.py index e9b7fe5df3e..0ea65c30754 100644 --- a/src/tribler-core/tribler_core/components/masterkey.py +++ b/src/tribler-core/tribler_core/components/masterkey/masterkey_component.py @@ -1,4 +1,4 @@ -import tribler_core.utilities.permid as permid_module +import tribler_core.components.masterkey.permid as permid_module from ipv8.keyvault.private.libnaclkey import LibNaCLSK from tribler_core.components.base import Component diff --git a/src/tribler-core/tribler_core/utilities/permid.py b/src/tribler-core/tribler_core/components/masterkey/permid.py similarity index 100% rename from src/tribler-core/tribler_core/utilities/permid.py rename to src/tribler-core/tribler_core/components/masterkey/permid.py diff --git a/src/tribler-core/tribler_core/modules/settings.py b/src/tribler-core/tribler_core/components/masterkey/settings.py similarity index 100% rename from src/tribler-core/tribler_core/modules/settings.py rename to src/tribler-core/tribler_core/components/masterkey/settings.py diff --git a/src/tribler-core/tribler_core/components/masterkey/tests/test_masterkey_component.py b/src/tribler-core/tribler_core/components/masterkey/tests/test_masterkey_component.py new file mode 100644 index 00000000000..4af5e141c95 --- /dev/null +++ b/src/tribler-core/tribler_core/components/masterkey/tests/test_masterkey_component.py @@ -0,0 +1,16 @@ +import pytest + +from tribler_core.components.base import Session +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent + + +@pytest.mark.asyncio +async def test_masterkey_component(tribler_config): + session = Session(tribler_config, [MasterKeyComponent()]) + with session: + comp = MasterKeyComponent.instance() + await session.start() + + assert comp.keypair + + await session.shutdown() diff --git a/src/tribler-core/tribler_core/components/metadata_store/metadata_store_component.py b/src/tribler-core/tribler_core/components/metadata_store/metadata_store_component.py index b2e6d8ebaba..901d1c08450 100644 --- a/src/tribler-core/tribler_core/components/metadata_store/metadata_store_component.py +++ b/src/tribler-core/tribler_core/components/metadata_store/metadata_store_component.py @@ -1,6 +1,6 @@ from tribler_common.simpledefs import NTFY, STATEDIR_DB_DIR -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.db.store import MetadataStore from tribler_core.components.metadata_store.utils import generate_test_channels from tribler_core.components.restapi import RestfulComponent diff --git a/src/tribler-core/tribler_core/components/metadata_store/tests/test_metadata_store_component.py b/src/tribler-core/tribler_core/components/metadata_store/tests/test_metadata_store_component.py index 8345a8b8c0b..f429a8af12c 100644 --- a/src/tribler-core/tribler_core/components/metadata_store/tests/test_metadata_store_component.py +++ b/src/tribler-core/tribler_core/components/metadata_store/tests/test_metadata_store_component.py @@ -3,7 +3,7 @@ import pytest from tribler_core.components.base import Session -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent from tribler_core.components.restapi import RESTComponent from tribler_core.restapi.rest_manager import RESTManager diff --git a/src/tribler-core/tribler_core/components/reporter.py b/src/tribler-core/tribler_core/components/reporter.py index a6190d4d72d..13532392482 100644 --- a/src/tribler-core/tribler_core/components/reporter.py +++ b/src/tribler-core/tribler_core/components/reporter.py @@ -1,6 +1,6 @@ from tribler_common.sentry_reporter.sentry_reporter import SentryReporter from tribler_core.components.base import Component -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.utilities.unicode import hexlify diff --git a/src/tribler-core/tribler_core/components/tests/test_tribler_components.py b/src/tribler-core/tribler_core/components/tests/test_tribler_components.py index 1a7debf2b84..4dd78f8b375 100644 --- a/src/tribler-core/tribler_core/components/tests/test_tribler_components.py +++ b/src/tribler-core/tribler_core/components/tests/test_tribler_components.py @@ -1,12 +1,10 @@ -from unittest.mock import patch - import pytest from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent from tribler_core.components.base import Session, SessionError from tribler_core.components.ipv8 import Ipv8Component from tribler_core.components.libtorrent import LibtorrentComponent -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent from tribler_core.components.payout import PayoutComponent from tribler_core.components.popularity import PopularityComponent @@ -19,7 +17,6 @@ from tribler_core.components.upgrade import UpgradeComponent from tribler_core.components.version_check import VersionCheckComponent from tribler_core.components.watch_folder import WatchFolderComponent -from tribler_core.restapi.rest_manager import RESTManager pytestmark = pytest.mark.asyncio @@ -50,18 +47,6 @@ def test_session_context_manager(loop, tribler_config): Session.current() -async def test_masterkey_component(tribler_config): - session = Session(tribler_config, [MasterKeyComponent()]) - with session: - await session.start() - - comp = MasterKeyComponent.instance() - assert comp.started.is_set() and not comp.failed - assert comp.keypair - - await session.shutdown() - - async def test_ipv8_component(tribler_config): tribler_config.ipv8.enabled = True components = [MasterKeyComponent(), RESTComponent(), Ipv8Component()] diff --git a/src/tribler-core/tribler_core/components/upgrade.py b/src/tribler-core/tribler_core/components/upgrade.py index 626439693af..9469e3eef3c 100644 --- a/src/tribler-core/tribler_core/components/upgrade.py +++ b/src/tribler-core/tribler_core/components/upgrade.py @@ -1,6 +1,6 @@ from tribler_common.simpledefs import STATE_UPGRADING_READABLE -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.restapi import RestfulComponent from tribler_core.upgrade.upgrade import TriblerUpgrader diff --git a/src/tribler-core/tribler_core/config/tribler_config_sections.py b/src/tribler-core/tribler_core/config/tribler_config_sections.py index 56a80ba4cec..c82c0c3011f 100644 --- a/src/tribler-core/tribler_core/config/tribler_config_sections.py +++ b/src/tribler-core/tribler_core/config/tribler_config_sections.py @@ -1,13 +1,14 @@ from pydantic import BaseSettings, Extra from tribler_core.components.bandwidth_accounting.settings import BandwidthAccountingSettings -from tribler_core.modules.libtorrent.settings import DownloadDefaultsSettings, LibtorrentSettings from tribler_core.components.gigachannel.community.settings import ChantSettings +from tribler_core.components.masterkey.settings import BootstrapSettings, DHTSettings, DiscoveryCommunitySettings, \ + Ipv8Settings, \ + TrustchainSettings, WatchFolderSettings +from tribler_core.modules.libtorrent.settings import DownloadDefaultsSettings, LibtorrentSettings from tribler_core.modules.popularity.settings import PopularityCommunitySettings from tribler_core.modules.remote_query_community.settings import RemoteQueryCommunitySettings from tribler_core.modules.resource_monitor.settings import ResourceMonitorSettings -from tribler_core.modules.settings import BootstrapSettings, DHTSettings, DiscoveryCommunitySettings, Ipv8Settings, \ - TrustchainSettings, WatchFolderSettings from tribler_core.modules.torrent_checker.settings import TorrentCheckerSettings from tribler_core.modules.tunnel.community.settings import TunnelCommunitySettings from tribler_core.restapi.settings import APISettings diff --git a/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py b/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py index eb83d146f59..d002f1bba00 100644 --- a/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py +++ b/src/tribler-core/tribler_core/modules/tunnel/tests/test_tunnel_settings.py @@ -1,7 +1,7 @@ import pytest from tribler_common.network_utils import NetworkUtils -from tribler_core.modules.settings import Ipv8Settings +from tribler_core.components.masterkey.settings import Ipv8Settings @pytest.mark.asyncio diff --git a/src/tribler-core/tribler_core/start_core.py b/src/tribler-core/tribler_core/start_core.py index c1672bcb99a..4b9f93997c2 100644 --- a/src/tribler-core/tribler_core/start_core.py +++ b/src/tribler-core/tribler_core/start_core.py @@ -19,7 +19,7 @@ from tribler_core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent from tribler_core.components.ipv8 import Ipv8Component from tribler_core.components.libtorrent import LibtorrentComponent -from tribler_core.components.masterkey import MasterKeyComponent +from tribler_core.components.masterkey.masterkey_component import MasterKeyComponent from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent from tribler_core.components.payout import PayoutComponent from tribler_core.components.popularity import PopularityComponent diff --git a/src/tribler-core/tribler_core/tests/test_permid.py b/src/tribler-core/tribler_core/tests/test_permid.py index a77a7c4e227..8bb718d7c01 100644 --- a/src/tribler-core/tribler_core/tests/test_permid.py +++ b/src/tribler-core/tribler_core/tests/test_permid.py @@ -2,7 +2,7 @@ from ipv8.keyvault.private.libnaclkey import LibNaCLSK -from tribler_core.utilities import permid +from tribler_core.components.masterkey import permid def test_save_load_keypair_pubkey_trustchain(tmpdir): diff --git a/src/tribler-core/tribler_core/upgrade/tests/test_upgrader.py b/src/tribler-core/tribler_core/upgrade/tests/test_upgrader.py index 71880edbe71..11a3ce5fcf8 100644 --- a/src/tribler-core/tribler_core/upgrade/tests/test_upgrader.py +++ b/src/tribler-core/tribler_core/upgrade/tests/test_upgrader.py @@ -10,7 +10,7 @@ from tribler_common.simpledefs import NTFY -import tribler_core.utilities.permid as permid_module +import tribler_core.components.masterkey.permid as permid_module from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase from tribler_core.components.metadata_store.db.orm_bindings.channel_metadata import CHANNEL_DIR_NAME_LENGTH from tribler_core.components.metadata_store.db.store import CURRENT_DB_VERSION, MetadataStore