forked from LBRYCommunity/lbry-sdk
add wallet_syncing status
This commit is contained in:
parent
fdb42ac876
commit
1052126522
4 changed files with 17 additions and 1 deletions
|
@ -146,6 +146,7 @@ class WalletComponent(Component):
|
|||
best_hash = await self.wallet_manager.get_best_blockhash()
|
||||
result.update({
|
||||
'headers_synchronization_progress': progress,
|
||||
'wallet_syncing': len(self.wallet_manager.ledger._update_tasks) > 0,
|
||||
'blocks': max(local_height, 0),
|
||||
'blocks_behind': max(remote_height - local_height, 0),
|
||||
'best_blockhash': best_hash,
|
||||
|
|
|
@ -334,7 +334,7 @@ class Ledger(metaclass=LedgerRegistry):
|
|||
log.info("Subscribing and updating accounts.")
|
||||
async with self._header_processing_lock:
|
||||
await self._update_tasks.add(self.initial_headers_sync())
|
||||
await self.subscribe_accounts()
|
||||
await self._update_tasks.add(self.subscribe_accounts())
|
||||
await self._update_tasks.done.wait()
|
||||
self._on_ready_controller.add(True)
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ class TaskGroup:
|
|||
self._tasks = set()
|
||||
self.done = Event()
|
||||
|
||||
def __len__(self):
|
||||
return len(self._tasks)
|
||||
|
||||
def add(self, coro):
|
||||
task = self._loop.create_task(coro)
|
||||
self._tasks.add(task)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import asyncio
|
||||
import json
|
||||
import os
|
||||
|
||||
from lbry.wallet import ENCRYPT_ON_DISK
|
||||
from lbry.error import InvalidPasswordError
|
||||
|
@ -19,6 +20,17 @@ class WalletCommands(CommandTestCase):
|
|||
await self.daemon.jsonrpc_wallet_add(wallet.id)
|
||||
self.assertEqual(len(session.hashX_subs), 28)
|
||||
|
||||
async def test_wallet_syncing_status(self):
|
||||
address = await self.daemon.jsonrpc_address_unused()
|
||||
sendtxid = await self.blockchain.send_to_address(address, 1)
|
||||
|
||||
async def eventually_will_sync():
|
||||
while not (await self.daemon.jsonrpc_status())['wallet']['wallet_syncing']:
|
||||
pass
|
||||
check_sync = asyncio.create_task(eventually_will_sync())
|
||||
await self.confirm_tx(sendtxid, self.ledger)
|
||||
await asyncio.wait_for(check_sync, timeout=10)
|
||||
|
||||
async def test_wallet_reconnect(self):
|
||||
await self.conductor.spv_node.stop(True)
|
||||
self.conductor.spv_node.port = 54320
|
||||
|
|
Loading…
Reference in a new issue