From 5a26aea398910a6adfde458644491c2ecbf0a770 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 20 Sep 2022 08:35:50 -0500 Subject: [PATCH] Feedback: Reuse IntegrationTestcase.generate() in generate_and_wait(). --- lbry/testcase.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lbry/testcase.py b/lbry/testcase.py index 1aba50e9b..3ddaec459 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -298,23 +298,11 @@ class IntegrationTestCase(AsyncioTestCase): async def generate_and_wait(self, blocks_to_generate, txids, ledger=None): if blocks_to_generate > 0: - watcher1 = (ledger or self.ledger).on_transaction.where( + 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 ) - watcher2 = (ledger or self.ledger).on_header.where(self.blockchain.is_expected_block) - self.conductor.spv_node.server.synchronized.clear() - await self.blockchain.generate(blocks_to_generate) - height = self.blockchain.block_expected - await watcher1 - await watcher2 - 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: - continue - if self.conductor.spv_node.server._es_height < height: - continue - break + await self.generate(blocks_to_generate) + await watcher def on_address_update(self, address): return self.ledger.on_transaction.where(