apply timeout and check for expected height on wait

This commit is contained in:
Victor Shyba 2019-12-19 20:20:42 -03:00
parent 84b8a22423
commit 3e03dd3e80
2 changed files with 7 additions and 2 deletions

View file

@ -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):

View file

@ -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: