diff --git a/lbry/testcase.py b/lbry/testcase.py index 371f0aad4..3977e6efc 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -299,8 +299,15 @@ class IntegrationTestCase(AsyncioTestCase): watcher = (ledger or self.ledger).on_transaction.where( lambda e: ((e.tx.id in txids and txids.remove(e.tx.id)), len(txids) <= 0)[-1] # multi-statement lambda ) + self.conductor.spv_node.server.synchronized.clear() await self.blockchain.generate(blocks_to_generate) + height = self.blockchain.block_expected await watcher + while True: + await self.conductor.spv_node.server.synchronized.wait() + self.conductor.spv_node.server.synchronized.clear() + if self.conductor.spv_node.server.db.db_height >= height: + break def on_address_update(self, address): return self.ledger.on_transaction.where( @@ -315,10 +322,15 @@ class IntegrationTestCase(AsyncioTestCase): async def generate(self, blocks): """ Ask lbrycrd to generate some blocks and wait until ledger has them. """ prepare = self.ledger.on_header.where(self.blockchain.is_expected_block) + height = self.blockchain.block_expected self.conductor.spv_node.server.synchronized.clear() await self.blockchain.generate(blocks) await prepare # no guarantee that it didn't happen already, so start waiting from before calling generate - await self.conductor.spv_node.server.synchronized.wait() + while True: + await self.conductor.spv_node.server.synchronized.wait() + self.conductor.spv_node.server.synchronized.clear() + if self.conductor.spv_node.server.db.db_height >= height: + break class FakeExchangeRateManager(ExchangeRateManager):