From 3e03dd3e80ac65dbb967bdad3df745426b09d39b Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 19 Dec 2019 20:20:42 -0300 Subject: [PATCH] apply timeout and check for expected height on wait --- lbry/lbry/testcase.py | 4 +++- torba/torba/client/baseledger.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lbry/lbry/testcase.py b/lbry/lbry/testcase.py index c49206c47..23b880a6f 100644 --- a/lbry/lbry/testcase.py +++ b/lbry/lbry/testcase.py @@ -90,6 +90,7 @@ class CommandTestCase(IntegrationTestCase): self.daemons = [] self.extra_wallet_nodes = [] self.extra_wallet_node_port = 5280 + self.__height = 0 self.daemon = await self.add_daemon(self.wallet_node) await self.account.ensure_address_gap() @@ -196,6 +197,7 @@ class CommandTestCase(IntegrationTestCase): async def generate(self, blocks): """ Ask lbrycrd to generate some blocks and wait until ledger has them. """ await self.blockchain.generate(blocks) + self.__height += 1 await self.ledger.on_header.where(self.blockchain.is_expected_block) async def blockchain_claim_name(self, name: str, value: str, amount: str, confirm=True): @@ -223,7 +225,7 @@ class CommandTestCase(IntegrationTestCase): if confirm: await self.ledger.wait(tx) await self.generate(1) - await self.ledger.wait(tx) + await self.ledger.wait(tx, self.__height) return self.sout(tx) def create_upload_file(self, data, prefix=None, suffix=None): diff --git a/torba/torba/client/baseledger.py b/torba/torba/client/baseledger.py index f3cf38518..fa0349769 100644 --- a/torba/torba/client/baseledger.py +++ b/torba/torba/client/baseledger.py @@ -575,7 +575,10 @@ class BaseLedger(metaclass=LedgerRegistry): # broadcast can't be a retriable call yet return self.network.broadcast(hexlify(tx.raw).decode()) - async def wait(self, tx: basetransaction.BaseTransaction, height=-1, timeout=None): + async def wait(self, tx: basetransaction.BaseTransaction, height=-1, timeout=1): + we_have = await self.get_transactions(txid=tx.id) + if we_have and we_have[0].height >= height: + return addresses = set() for txi in tx.inputs: if txi.txo_ref.txo is not None: