forked from LBRYCommunity/lbry-sdk
apply timeout and check for expected height on wait
This commit is contained in:
parent
84b8a22423
commit
3e03dd3e80
2 changed files with 7 additions and 2 deletions
|
@ -90,6 +90,7 @@ class CommandTestCase(IntegrationTestCase):
|
||||||
self.daemons = []
|
self.daemons = []
|
||||||
self.extra_wallet_nodes = []
|
self.extra_wallet_nodes = []
|
||||||
self.extra_wallet_node_port = 5280
|
self.extra_wallet_node_port = 5280
|
||||||
|
self.__height = 0
|
||||||
self.daemon = await self.add_daemon(self.wallet_node)
|
self.daemon = await self.add_daemon(self.wallet_node)
|
||||||
|
|
||||||
await self.account.ensure_address_gap()
|
await self.account.ensure_address_gap()
|
||||||
|
@ -196,6 +197,7 @@ class CommandTestCase(IntegrationTestCase):
|
||||||
async def generate(self, blocks):
|
async def generate(self, blocks):
|
||||||
""" Ask lbrycrd to generate some blocks and wait until ledger has them. """
|
""" Ask lbrycrd to generate some blocks and wait until ledger has them. """
|
||||||
await self.blockchain.generate(blocks)
|
await self.blockchain.generate(blocks)
|
||||||
|
self.__height += 1
|
||||||
await self.ledger.on_header.where(self.blockchain.is_expected_block)
|
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):
|
async def blockchain_claim_name(self, name: str, value: str, amount: str, confirm=True):
|
||||||
|
@ -223,7 +225,7 @@ class CommandTestCase(IntegrationTestCase):
|
||||||
if confirm:
|
if confirm:
|
||||||
await self.ledger.wait(tx)
|
await self.ledger.wait(tx)
|
||||||
await self.generate(1)
|
await self.generate(1)
|
||||||
await self.ledger.wait(tx)
|
await self.ledger.wait(tx, self.__height)
|
||||||
return self.sout(tx)
|
return self.sout(tx)
|
||||||
|
|
||||||
def create_upload_file(self, data, prefix=None, suffix=None):
|
def create_upload_file(self, data, prefix=None, suffix=None):
|
||||||
|
|
|
@ -575,7 +575,10 @@ class BaseLedger(metaclass=LedgerRegistry):
|
||||||
# broadcast can't be a retriable call yet
|
# broadcast can't be a retriable call yet
|
||||||
return self.network.broadcast(hexlify(tx.raw).decode())
|
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()
|
addresses = set()
|
||||||
for txi in tx.inputs:
|
for txi in tx.inputs:
|
||||||
if txi.txo_ref.txo is not None:
|
if txi.txo_ref.txo is not None:
|
||||||
|
|
Loading…
Reference in a new issue