示例#1
0
    async def add_daemon(self, wallet_node=None, seed=None):
        if wallet_node is None:
            wallet_node = WalletNode(self.wallet_node.manager_class,
                                     self.wallet_node.ledger_class,
                                     port=self.extra_wallet_node_port)
            self.extra_wallet_node_port += 1
            await wallet_node.start(self.conductor.spv_node, seed=seed)
            self.extra_wallet_nodes.append(wallet_node)

        upload_dir = os.path.join(wallet_node.data_path, 'uploads')
        os.mkdir(upload_dir)

        conf = Config()
        conf.data_dir = wallet_node.data_path
        conf.wallet_dir = wallet_node.data_path
        conf.download_dir = wallet_node.data_path
        conf.upload_dir = upload_dir  # not a real conf setting
        conf.share_usage_data = False
        conf.use_upnp = False
        conf.reflect_streams = True
        conf.blockchain_name = 'lbrycrd_regtest'
        conf.lbryum_servers = [('127.0.0.1', 50001)]
        conf.reflector_servers = [('127.0.0.1', 5566)]
        conf.fixed_peers = [('127.0.0.1', 5567)]
        conf.known_dht_nodes = []
        conf.blob_lru_cache_size = self.blob_lru_cache_size
        conf.transaction_cache_size = 10000
        conf.components_to_skip = [
            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):
            wallet_component = WalletComponent(component_manager)
            wallet_component.wallet_manager = wallet_node.manager
            wallet_component._running = True
            return wallet_component

        daemon = Daemon(
            conf,
            ComponentManager(conf,
                             skip_components=conf.components_to_skip,
                             wallet=wallet_maker,
                             exchange_rate_manager=partial(
                                 ExchangeRateManagerComponent,
                                 rates={
                                     'BTCLBC': 1.0,
                                     'USDBTC': 2.0
                                 })))
        await daemon.initialize()
        self.daemons.append(daemon)
        wallet_node.manager.old_db = daemon.storage
        return daemon
示例#2
0
 async def asyncSetUp(self):
     conf = Config()
     conf.data_dir = '/tmp'
     conf.share_usage_data = False
     conf.api = 'localhost:5299'
     conf.components_to_skip = (
         DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
         HASH_ANNOUNCER_COMPONENT, STREAM_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
         UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
     )
     Daemon.component_attributes = {}
     self.daemon = Daemon(conf)
     await self.daemon.start()
示例#3
0
 async def asyncSetUp(self):
     conf = Config(allowed_origin='localhost')
     conf.data_dir = '/tmp'
     conf.share_usage_data = False
     conf.api = 'localhost:5299'
     conf.components_to_skip = (
         DATABASE_COMPONENT, DISK_SPACE_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, LIBTORRENT_COMPONENT,
         BACKGROUND_DOWNLOADER_COMPONENT, TRACKER_ANNOUNCER_COMPONENT)
     Daemon.component_attributes = {}
     self.daemon = Daemon(conf)
     await self.daemon.start()
     self.addCleanup(self.daemon.stop)
示例#4
0
    async def add_daemon(self, wallet_node=None, seed=None):
        if wallet_node is None:
            wallet_node = WalletNode(self.wallet_node.manager_class,
                                     self.wallet_node.ledger_class,
                                     port=self.extra_wallet_node_port)
            self.extra_wallet_node_port += 1
            await wallet_node.start(self.conductor.spv_node, seed=seed)
            self.extra_wallet_nodes.append(wallet_node)

        conf = Config()
        conf.data_dir = wallet_node.data_path
        conf.wallet_dir = wallet_node.data_path
        conf.download_dir = wallet_node.data_path
        conf.share_usage_data = False
        conf.use_upnp = False
        conf.reflect_streams = True
        conf.blockchain_name = 'lbrycrd_regtest'
        conf.lbryum_servers = [('127.0.0.1', 50001)]
        conf.reflector_servers = [('127.0.0.1', 5566)]
        conf.known_dht_nodes = []
        conf.blob_lru_cache_size = self.blob_lru_cache_size
        conf.components_to_skip = [
            DHT_COMPONENT, UPNP_COMPONENT, HASH_ANNOUNCER_COMPONENT,
            PEER_PROTOCOL_SERVER_COMPONENT
        ]

        def wallet_maker(component_manager):
            wallet_component = WalletComponent(component_manager)
            wallet_component.wallet_manager = wallet_node.manager
            wallet_component._running = True
            return wallet_component

        daemon = Daemon(
            conf,
            ComponentManager(
                conf,
                skip_components=conf.components_to_skip,
                wallet=wallet_maker,
                exchange_rate_manager=ExchangeRateManagerComponent))
        await daemon.initialize()
        self.daemons.append(daemon)
        wallet_node.manager.old_db = daemon.storage
        return daemon
示例#5
0
    async def asyncSetUp(self):
        self.wallet_node = WalletNode(LbryWalletManager, RegTestLedger)
        await self.wallet_node.start(
            SPVNode(None),
            "carbon smart garage balance margin twelve chest sword toast envelope bottom stomach absent",
            False)
        self.account = self.wallet_node.account

        conf = Config()
        conf.data_dir = self.wallet_node.data_path
        conf.wallet_dir = self.wallet_node.data_path
        conf.download_dir = self.wallet_node.data_path
        conf.share_usage_data = False
        conf.use_upnp = False
        conf.reflect_streams = False
        conf.blockchain_name = 'lbrycrd_regtest'
        conf.lbryum_servers = [('localhost', 50001)]
        conf.reflector_servers = []
        conf.known_dht_nodes = []

        def wallet_maker(component_manager):
            self.wallet_component = WalletComponent(component_manager)
            self.wallet_component.wallet_manager = self.wallet_node.manager
            self.wallet_component._running = True
            return self.wallet_component

        conf.components_to_skip = [
            DHT_COMPONENT, UPNP_COMPONENT, HASH_ANNOUNCER_COMPONENT,
            PEER_PROTOCOL_SERVER_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
        ]
        self.daemon = Daemon(
            conf,
            ComponentManager(conf,
                             skip_components=conf.components_to_skip,
                             wallet=wallet_maker))
        await self.daemon.initialize()
示例#6
0
def get_test_daemon(conf: Config, with_fee=False):
    conf.data_dir = '/tmp'
    rates = {
        'BTCLBC': {
            'spot': 3.0,
            'ts': test_utils.DEFAULT_ISO_TIME + 1
        },
        'USDBTC': {
            'spot': 2.0,
            'ts': test_utils.DEFAULT_ISO_TIME + 2
        }
    }
    component_manager = ComponentManager(
        conf,
        skip_components=[
            DATABASE_COMPONENT, DHT_COMPONENT, WALLET_COMPONENT,
            UPNP_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
            HASH_ANNOUNCER_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT,
            BLOB_COMPONENT, RATE_LIMITER_COMPONENT
        ],
        file_manager=FakeFileManager)
    daemon = LBRYDaemon(conf, component_manager=component_manager)
    daemon.payment_rate_manager = OnlyFreePaymentsManager()
    daemon.wallet_manager = mock.Mock(spec=WalletManager)
    daemon.wallet_manager.wallet = mock.Mock(spec=Wallet)
    daemon.wallet_manager.use_encryption = False
    daemon.wallet_manager.network = FakeNetwork()
    daemon.storage = mock.Mock(spec=SQLiteStorage)
    market_feeds = [BTCLBCFeed(), USDBTCFeed()]
    daemon.exchange_rate_manager = DummyExchangeRateManager(
        market_feeds, rates)
    daemon.stream_manager = component_manager.get_component(
        FILE_MANAGER_COMPONENT)

    metadata = {
        "author": "fake author",
        "language": "en",
        "content_type": "fake/format",
        "description": "fake description",
        "license": "fake license",
        "license_url": "fake license url",
        "nsfw": False,
        "sources": {
            "lbry_sd_hash":
            'd2b8b6e907dde95245fe6d144d16c2fdd60c4e0c6463ec98'
            'b85642d06d8e9414e8fcfdcb7cb13532ec5454fb8fe7f280'
        },
        "thumbnail": "fake thumbnail",
        "title": "fake title",
        "ver": "0.0.3"
    }
    if with_fee:
        metadata.update({
            "fee": {
                "USD": {
                    "address": "bQ6BGboPV2SpTMEP7wLNiAcnsZiH8ye6eA",
                    "amount": 0.75
                }
            }
        })
    migrated = smart_decode(json.dumps(metadata))
    daemon._resolve = daemon.resolve = lambda *_: defer.succeed(
        {"test": {
            'claim': {
                'value': migrated.claim_dict
            }
        }})
    return daemon