refactor + tests
This commit is contained in:
parent
0bf1be6198
commit
c2106de7e1
3 changed files with 16 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in a new issue