diff --git a/lbry/lbry/wallet/manager.py b/lbry/lbry/wallet/manager.py index c25e42218..201ba5471 100644 --- a/lbry/lbry/wallet/manager.py +++ b/lbry/lbry/wallet/manager.py @@ -146,13 +146,7 @@ class LbryWalletManager(BaseWalletManager): return manager async def reset(self): - ledger_id = { - 'lbrycrd_main': 'lbc_mainnet', - 'lbrycrd_testnet': 'lbc_testnet', - 'lbrycrd_regtest': 'lbc_regtest' - }[self.config.blockchain_name] - ledger = self.get_or_create_ledger(ledger_id) - ledger.config = { + self.ledger.config = { 'auto_connect': True, 'default_servers': self.config.lbryum_servers, 'data_path': self.config.wallet_dir, diff --git a/lbry/tests/integration/test_wallet_commands.py b/lbry/tests/integration/test_wallet_commands.py index c1b0fd310..6daecf67b 100644 --- a/lbry/tests/integration/test_wallet_commands.py +++ b/lbry/tests/integration/test_wallet_commands.py @@ -19,6 +19,19 @@ class WalletCommands(CommandTestCase): await self.daemon.jsonrpc_wallet_add(wallet.id) self.assertEqual(len(session.hashX_subs), 28) + async def test_wallet_restart(self): + await self.conductor.spv_node.stop(True) + self.conductor.spv_node.port = 54320 + await self.conductor.spv_node.start(self.conductor.blockchain_node) + status = await self.daemon.jsonrpc_status() + self.assertEqual(len(status['wallet']['servers']), 1) + self.assertEqual(status['wallet']['servers'][0]['port'], 50002) + self.daemon.jsonrpc_settings_set('lbryum_servers', ['localhost:54320']) + await self.daemon.jsonrpc_wallet_restart() + status = await self.daemon.jsonrpc_status() + self.assertEqual(len(status['wallet']['servers']), 1) + self.assertEqual(status['wallet']['servers'][0]['port'], 54320) + async def test_balance_caching(self): account2 = await self.daemon.jsonrpc_account_create("Tip-er") address2 = await self.daemon.jsonrpc_address_unused(account2.id) diff --git a/torba/torba/client/baseledger.py b/torba/torba/client/baseledger.py index d00c14895..11a4dbc58 100644 --- a/torba/torba/client/baseledger.py +++ b/torba/torba/client/baseledger.py @@ -111,6 +111,7 @@ class BaseLedger(metaclass=LedgerRegistry): self.network = self.config.get('network') or self.network_class(self) self.network.on_header.listen(self.receive_header) self.network.on_status.listen(self.process_status_update) + self.network.on_connected.listen(self.join_network) self.accounts = [] self.fee_per_byte: int = self.config.get('fee_per_byte', self.default_fee_per_byte) @@ -290,8 +291,7 @@ class BaseLedger(metaclass=LedgerRegistry): await first_connection async with self._header_processing_lock: await self._update_tasks.add(self.initial_headers_sync()) - await self.join_network() - self.network.on_connected.listen(self.join_network) + await self._on_ready_controller.stream.first async def join_network(self, *_): log.info("Subscribing and updating accounts.")