Beispiel #1
0
    async def run(self):
        await super().run()

        self._ipv8_component = await self.require_component(Ipv8Component)
        key_component = await self.require_component(KeyComponent)
        mds_component = await self.require_component(metadata_store_component.MetadataStoreComponent)

        db_path = self.session.config.state_dir / STATEDIR_DB_DIR / "tags.db"
        if self.session.config.gui_test_mode:
            db_path = ":memory:"

        self.tags_db = TagDatabase(str(db_path), create_tables=True)
        self.community = TagCommunity(
            self._ipv8_component.peer,
            self._ipv8_component.ipv8.endpoint,
            self._ipv8_component.ipv8.network,
            db=self.tags_db,
            tags_key=key_component.secondary_key
        )
        self.rules_processor = TagRulesProcessor(
            notifier=self.session.notifier,
            db=self.tags_db,
            mds=mds_component.mds,
        )
        self.rules_processor.start()

        self._ipv8_component.initialise_community_by_default(self.community)

        if self.session.config.gui_test_mode:
            generate_test_channels(mds_component.mds, self.tags_db)
    def create_node(self, *args, **kwargs):
        self.metadata_store = MetadataStore(
            Path(self.temporary_directory()) / "mds.db",
            Path(self.temporary_directory()),
            default_eccrypto.generate_key("curve25519"),
            disable_sync=True,
        )
        self.tags_db = TagDatabase(
            str(Path(self.temporary_directory()) / "tags.db"))

        kwargs['metadata_store'] = self.metadata_store
        kwargs['tags_db'] = self.tags_db
        kwargs['rqc_settings'] = RemoteQueryCommunitySettings()
        return super().create_node(*args, **kwargs)
Beispiel #3
0
    async def run(self):
        await super().run()

        self._ipv8_component = await self.require_component(Ipv8Component)
        key_component = await self.require_component(KeyComponent)

        db_path = self.session.config.state_dir / STATEDIR_DB_DIR / "tags.db"
        if self.session.config.gui_test_mode:
            db_path = ":memory:"

        self.tags_db = TagDatabase(str(db_path))
        self.community = TagCommunity(self._ipv8_component.peer,
                                      self._ipv8_component.ipv8.endpoint,
                                      self._ipv8_component.ipv8.network,
                                      db=self.tags_db,
                                      tags_key=key_component.secondary_key)

        self._ipv8_component.initialise_community_by_default(self.community)
Beispiel #4
0
def test_upgrade_pony13to14(upgrader: TriblerUpgrader, state_dir, channels_dir,
                            trustchain_keypair, mds_path):
    tags_path = state_dir / 'sqlite/tags.db'

    _copy(source_name='pony_v13.db', target=mds_path)
    _copy(source_name='tags_v13.db', target=tags_path)

    upgrader.upgrade_pony_db_13to14()
    mds = MetadataStore(mds_path,
                        channels_dir,
                        trustchain_keypair,
                        check_tables=False)
    tags = TagDatabase(str(tags_path), create_tables=False, check_tables=False)

    with db_session:
        assert upgrader.column_exists_in_table(mds._db, 'ChannelNode',
                                               'tag_processor_version')
        assert upgrader.column_exists_in_table(tags.instance, 'TorrentTagOp',
                                               'auto_generated')
        assert mds.get_value('db_version') == '14'
Beispiel #5
0
    def upgrade_pony_db_13to14(self):
        mds_path = self.state_dir / STATEDIR_DB_DIR / 'metadata.db'
        tagdb_path = self.state_dir / STATEDIR_DB_DIR / 'tags.db'

        mds = MetadataStore(mds_path,
                            self.channels_dir,
                            self.trustchain_keypair,
                            disable_sync=True,
                            check_tables=False,
                            db_version=13) if mds_path.exists() else None
        tag_db = TagDatabase(
            str(tagdb_path), create_tables=False,
            check_tables=False) if tagdb_path.exists() else None

        self.do_upgrade_pony_db_13to14(mds, tag_db)

        if mds:
            mds.shutdown()
        if tag_db:
            tag_db.shutdown()
Beispiel #6
0
 def setUp(self):
     super().setUp()
     self.db = TagDatabase()
Beispiel #7
0
 def test_constructor_create_tables_false(self,
                                          mocked_generate_mapping: Mock):
     TagDatabase(':memory:', create_tables=False)
     mocked_generate_mapping.assert_called_with(create_tables=False)
Beispiel #8
0
def tags_db():
    db = TagDatabase()
    yield db
    db.shutdown()
Beispiel #9
0
 def create_node(self, *args, **kwargs):
     return MockIPv8("curve25519",
                     TagCommunity,
                     db=TagDatabase(),
                     tags_key=LibNaCLSK(),
                     request_interval=REQUEST_INTERVAL_FOR_RANDOM_TAGS)