async def test_socks_servers_component(tribler_config):
    components = [SocksServersComponent()]
    async with Session(tribler_config, components).start():
        comp = SocksServersComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.socks_ports
        assert comp.socks_servers
Example #2
0
async def test_socks_servers_component(tribler_config):
    components = [SocksServersComponent()]
    session = Session(tribler_config, components)
    with session:
        await session.start()

        comp = SocksServersComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.socks_ports
        assert comp.socks_servers

        await session.shutdown()
async def test_popularity_component(tribler_config):
    components = [SocksServersComponent(), LibtorrentComponent(), TorrentCheckerComponent(), TagComponent(),
                  MetadataStoreComponent(), KeyComponent(), Ipv8Component(), PopularityComponent()]
    async with Session(tribler_config, components).start():
        comp = PopularityComponent.instance()
        assert comp.community
        assert comp._ipv8_component
Example #4
0
async def test_rest_component(tribler_config):
    components = [
        KeyComponent(),
        RESTComponent(),
        Ipv8Component(),
        LibtorrentComponent(),
        ResourceMonitorComponent(),
        BandwidthAccountingComponent(),
        GigaChannelComponent(),
        TagComponent(),
        SocksServersComponent(),
        MetadataStoreComponent()
    ]
    async with Session(tribler_config, components).start():
        # Test REST component starts normally
        comp = RESTComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.rest_manager

        # Test report callback works
        # mock callbacks
        comp._events_endpoint.on_tribler_exception = MagicMock()

        # try to call report_callback from core_exception_handler and assert
        # that corresponding methods in events_endpoint and state_endpoint have been called
        error = ReportedError(type='', text='text', event={})
        comp._core_exception_handler.report_callback(error)
        comp._events_endpoint.on_tribler_exception.assert_called_with(error)
async def test_gigachannel_manager_component(tribler_config):
    components = [Ipv8Component(), TagComponent(), SocksServersComponent(), KeyComponent(), MetadataStoreComponent(),
                  LibtorrentComponent(), GigachannelManagerComponent()]
    async with Session(tribler_config, components).start():
        comp = GigachannelManagerComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.gigachannel_manager
Example #6
0
def components_gen():
    yield KeyComponent()
    yield RESTComponent()
    yield Ipv8Component()
    yield ResourceMonitorComponent()
    yield BandwidthAccountingComponent()
    yield SocksServersComponent()
    yield TunnelsComponent()
async def test_watch_folder_component(tribler_config):
    components = [
        KeyComponent(),
        SocksServersComponent(),
        LibtorrentComponent(),
        WatchFolderComponent()
    ]
    async with Session(tribler_config, components).start():
        comp = WatchFolderComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.watch_folder
Example #8
0
async def test_torrent_checker_component(tribler_config):
    components = [
        SocksServersComponent(),
        LibtorrentComponent(),
        KeyComponent(),
        Ipv8Component(),
        TagComponent(),
        MetadataStoreComponent(),
        TorrentCheckerComponent()
    ]
    async with Session(tribler_config, components).start():
        comp = TorrentCheckerComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.torrent_checker
Example #9
0
 def __init__(self, timeout_in_sec, working_dir):
     super().__init__(config=TriblerConfig(state_dir=working_dir),
                      timeout_in_sec=timeout_in_sec,
                      working_dir=working_dir,
                      components=[
                          SocksServersComponent(),
                          LibtorrentComponent(),
                          TorrentCheckerComponent(),
                          MetadataStoreComponent(),
                          KeyComponent(),
                          RESTComponent(),
                          Ipv8Component(),
                          ObservablePopularityComponent()
                      ])
Example #10
0
 def __init__(self, source_dir, working_dir):
     super().__init__(TriblerConfig(state_dir=working_dir),
                      working_dir=working_dir,
                      components=[
                          RESTComponent(),
                          KeyComponent(),
                          SocksServersComponent(),
                          LibtorrentComponent(),
                          Ipv8Component(),
                          MetadataStoreComponent(),
                          GigachannelManagerComponent(),
                          GigaChannelComponent()
                      ])
     self.source_dir = Path(source_dir)
async def test_libtorrent_component(tribler_config):
    components = [
        KeyComponent(),
        SocksServersComponent(),
        LibtorrentComponent()
    ]
    session = Session(tribler_config, components)
    with session:
        await session.start()

        comp = LibtorrentComponent.instance()
        assert comp.started_event.is_set() and not comp.failed
        assert comp.download_manager

        await session.shutdown()
Example #12
0
def components_gen(config: TriblerConfig):
    """This function defines components that will be used in Tibler
    """
    yield ReporterComponent()
    if config.api.http_enabled or config.api.https_enabled:
        yield RESTComponent()
    if config.chant.enabled or config.torrent_checking.enabled:
        yield MetadataStoreComponent()
    if config.ipv8.enabled:
        yield Ipv8Component()

    yield KeyComponent()
    yield TagComponent()

    if config.libtorrent.enabled:
        yield LibtorrentComponent()
    if config.ipv8.enabled and config.chant.enabled:
        yield GigaChannelComponent()
    if config.ipv8.enabled:
        yield BandwidthAccountingComponent()
    if config.resource_monitor.enabled:
        yield ResourceMonitorComponent()

    # The components below are skipped if config.gui_test_mode == True
    if config.gui_test_mode:
        return

    if config.libtorrent.enabled:
        yield SocksServersComponent()

    if config.torrent_checking.enabled:
        yield TorrentCheckerComponent()
    if config.ipv8.enabled and config.torrent_checking.enabled and config.popularity_community.enabled:
        yield PopularityComponent()
    if config.ipv8.enabled and config.tunnel_community.enabled:
        yield TunnelsComponent()
    if config.ipv8.enabled:
        yield PayoutComponent()
    if config.watch_folder.enabled:
        yield WatchFolderComponent()
    if config.general.version_checker_enabled:
        yield VersionCheckComponent()
    if config.chant.enabled and config.chant.manager_enabled and config.libtorrent.enabled:
        yield GigachannelManagerComponent()