add wait_until_block testing helper to BlockchainProcessorService
This commit is contained in:
parent
2363865e00
commit
3b2b8f814c
1 changed files with 9 additions and 0 deletions
|
@ -56,6 +56,7 @@ class BlockchainProcessorService(BlockchainService):
|
||||||
self.wait_for_blocks_duration = 0.1
|
self.wait_for_blocks_duration = 0.1
|
||||||
self._ready_to_stop = asyncio.Event()
|
self._ready_to_stop = asyncio.Event()
|
||||||
self.blocks_event = asyncio.Event()
|
self.blocks_event = asyncio.Event()
|
||||||
|
self.advanced = asyncio.Event()
|
||||||
self.prefetcher = Prefetcher(self.daemon, env.coin, self.blocks_event)
|
self.prefetcher = Prefetcher(self.daemon, env.coin, self.blocks_event)
|
||||||
self._caught_up_event: Optional[asyncio.Event] = None
|
self._caught_up_event: Optional[asyncio.Event] = None
|
||||||
self.height = 0
|
self.height = 0
|
||||||
|
@ -226,6 +227,7 @@ class BlockchainProcessorService(BlockchainService):
|
||||||
"applying extended claim expiration fork on claims accepted by, %i", self.height
|
"applying extended claim expiration fork on claims accepted by, %i", self.height
|
||||||
)
|
)
|
||||||
await self.run_in_thread_with_lock(self.db.apply_expiration_extension_fork)
|
await self.run_in_thread_with_lock(self.db.apply_expiration_extension_fork)
|
||||||
|
self.advanced.set()
|
||||||
except:
|
except:
|
||||||
self.log.exception("advance blocks failed")
|
self.log.exception("advance blocks failed")
|
||||||
raise
|
raise
|
||||||
|
@ -271,6 +273,13 @@ class BlockchainProcessorService(BlockchainService):
|
||||||
'resetting the prefetcher')
|
'resetting the prefetcher')
|
||||||
await self.prefetcher.reset_height(self.height)
|
await self.prefetcher.reset_height(self.height)
|
||||||
|
|
||||||
|
async def wait_until_block(self, height: int):
|
||||||
|
while self.height < height:
|
||||||
|
await self.advanced.wait()
|
||||||
|
self.advanced.clear()
|
||||||
|
if self.height >= height:
|
||||||
|
break
|
||||||
|
|
||||||
def _add_claim_or_update(self, height: int, txo: 'TxOutput', tx_hash: bytes, tx_num: int, nout: int,
|
def _add_claim_or_update(self, height: int, txo: 'TxOutput', tx_hash: bytes, tx_num: int, nout: int,
|
||||||
spent_claims: typing.Dict[bytes, typing.Tuple[int, int, str]], first_input: 'TxInput'):
|
spent_claims: typing.Dict[bytes, typing.Tuple[int, int, str]], first_input: 'TxInput'):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue