def setUp(self):
        yield super(TestTrustchainStatsEndpoint, self).setUp()

        self.mock_ipv8 = MockIPv8(
            u"low",
            TrustChainCommunity,
            working_directory=self.session.config.get_state_dir())
        self.session.lm.trustchain_community = self.mock_ipv8.overlay
        self.session.lm.wallets['MB'] = TrustchainWallet(
            self.session.lm.trustchain_community)
    def setUp(self, autoload_discovery=True):
        yield super(TestStatisticsEndpoint,
                    self).setUp(autoload_discovery=autoload_discovery)

        self.mock_ipv8 = MockIPv8(
            u"low",
            TrustChainCommunity,
            working_directory=self.session.config.get_state_dir())
        self.mock_ipv8.overlays = [self.mock_ipv8.overlay]
        self.session.lm.ipv8 = self.mock_ipv8
        self.session.config.set_ipv8_enabled(True)
Example #3
0
    def create_node(self):
        mock_ipv8 = MockIPv8(u"curve25519", TriblerTunnelCommunity, socks_listen_ports=[])
        mock_ipv8.overlay.settings.max_circuits = 1

        # Load the TrustChain community
        overlay = TrustChainCommunity(mock_ipv8.my_peer, mock_ipv8.endpoint, mock_ipv8.network,
                                      working_directory=u":memory:")
        mock_ipv8.overlay.bandwidth_wallet = TrustchainWallet(overlay)
        mock_ipv8.overlay.dht_provider = MockDHTProvider(mock_ipv8.endpoint.wan_address)

        return mock_ipv8
Example #4
0
    def create_node(self):
        mock_ipv8 = MockIPv8(u"curve25519", TriblerTunnelCommunity, socks_listen_ports=[],
                             exitnode_cache=join(mkdtemp(suffix="_tribler_test_cache"), 'cache.dat'))
        mock_ipv8.overlay.settings.max_circuits = 1

        # Load the TrustChain community
        mock_ipv8.trustchain = TrustChainCommunity(mock_ipv8.my_peer, mock_ipv8.endpoint, mock_ipv8.network,
                                      working_directory=u":memory:")
        mock_ipv8.overlay.bandwidth_wallet = TrustchainWallet(mock_ipv8.trustchain)
        mock_ipv8.overlay.dht_provider = MockDHTProvider(mock_ipv8.endpoint.wan_address)

        return mock_ipv8
Example #5
0
    def create_node(self):
        dum1_wallet = DummyWallet1()
        dum2_wallet = DummyWallet2()
        dum1_wallet.MONITOR_DELAY = 0
        dum2_wallet.MONITOR_DELAY = 0

        wallets = {'DUM1': dum1_wallet, 'DUM2': dum2_wallet}

        return MockIPv8(u"curve25519",
                        MarketCommunity,
                        is_matchmaker=True,
                        wallets=wallets,
                        use_database=False,
                        working_directory=u":memory:")
Example #6
0
    def create_node(self):
        dum1_wallet = DummyWallet1()
        dum2_wallet = DummyWallet2()
        dum1_wallet.MONITOR_DELAY = 0
        dum2_wallet.MONITOR_DELAY = 0

        wallets = {'DUM1': dum1_wallet, 'DUM2': dum2_wallet}

        mock_ipv8 = MockIPv8(u"curve25519", MarketCommunity, create_trustchain=True, create_dht=True,
                             is_matchmaker=True, wallets=wallets, use_database=False, working_directory=u":memory:")
        tc_wallet = TrustchainWallet(mock_ipv8.trustchain)
        mock_ipv8.overlay.wallets['MB'] = tc_wallet

        return mock_ipv8
Example #7
0
    def create_node(self, *args, **kwargs):
        mds = MetadataStore(
            os.path.join(self.temporary_directory(), 'test.db'),
            self.temporary_directory(), self.shared_key)

        # Add some content to the metadata database
        with db_session:
            mds.ChannelMetadata.create_channel('test', 'test')
            for torrent_ind in xrange(5):
                torrent = mds.TorrentMetadata(title='torrent%d' % torrent_ind,
                                              infohash=('%d' % torrent_ind) *
                                              20)
                torrent.health.seeders = torrent_ind + 1

        return MockIPv8(u"curve25519", PopularityCommunity, metadata_store=mds)
Example #8
0
    def setUp(self, autoload_discovery=True):
        yield super(TestMarketEndpoint,
                    self).setUp(autoload_discovery=autoload_discovery)

        dummy1_wallet = DummyWallet1()
        dummy2_wallet = DummyWallet2()
        wallets_dict = {
            dummy1_wallet.get_identifier(): dummy1_wallet,
            dummy2_wallet.get_identifier(): dummy2_wallet
        }
        self.mock_ipv8 = MockIPv8(
            u"low",
            MarketCommunity,
            wallets=wallets_dict,
            working_directory=self.session.config.get_state_dir())
        self.session.lm.market_community = self.mock_ipv8.overlay
    def setUp(self):
        yield super(TestStatisticsEndpoint, self).setUp()

        self.mock_ipv8 = MockIPv8(
            u"low",
            TrustChainCommunity,
            working_directory=self.session.config.get_state_dir())
        self.mock_ipv8.overlays = [self.mock_ipv8.overlay]
        self.mock_ipv8.endpoint.bytes_up = 100
        self.mock_ipv8.endpoint.bytes_down = 20
        self.session.lm.ipv8 = self.mock_ipv8
        self.session.config.set_ipv8_enabled(True)
        my_key = default_eccrypto.generate_key(u"curve25519")
        self.session.lm.mds = MetadataStore(
            os.path.join(self.session_base_dir, 'test.db'),
            self.session_base_dir, my_key)
Example #10
0
    def create_node(self):
        mock_ipv8 = MockIPv8(u"curve25519",
                             TriblerTunnelCommunity,
                             socks_listen_ports=[])
        mock_ipv8.overlay._use_main_thread = False
        mock_ipv8.overlay.settings.max_circuits = 1

        # Load the TriblerChain community
        overlay = TriblerChainCommunity(mock_ipv8.my_peer,
                                        mock_ipv8.endpoint,
                                        mock_ipv8.network,
                                        working_directory=u":memory:")
        mock_ipv8.overlay.triblerchain_community = overlay
        mock_ipv8.overlay.dht_provider = MockDHTProvider(
            mock_ipv8.endpoint.wan_address)

        return mock_ipv8
Example #11
0
    def create_node(self, *args, **kwargs):
        def load_random_torrents(limit):
            return [[
                '\xfdC\xf9+V\x11A\xe7QG\xfb\xb1*6\xef\xa5\xaeu\xc2\xe0',
                random.randint(200, 250),
                random.randint(1, 10), 1525704192.166107
            ] for _ in range(limit)]

        torrent_db = MockObject()
        torrent_db.getTorrent = lambda *args, **kwargs: None
        torrent_db.updateTorrent = lambda *args, **kwargs: None
        torrent_db.getRecentlyCheckedTorrents = load_random_torrents

        channel_db = MockObject()

        return MockIPv8(u"curve25519",
                        PopularityCommunity,
                        torrent_db=torrent_db,
                        channel_db=channel_db)
 def create_node(self):
     return MockIPv8(u"curve25519",
                     TrustChainCommunity,
                     working_directory=u":memory:")
Example #13
0
 def create_node(self, *args, **kwargs):
     return MockIPv8(u"curve25519", PubSubCommunity)