integration tests for jsonrpc_transaction_show fixed

This commit is contained in:
Lex Berezhny 2019-05-05 16:57:34 -04:00
parent 048aa07e80
commit 587f0b2ea8
3 changed files with 6 additions and 6 deletions

View file

@ -197,10 +197,12 @@ class LbryWalletManager(BaseWalletManager):
tx = await self.db.get_transaction(txid=txid)
if not tx:
try:
_raw = await self.ledger.network.get_transaction(txid)
raw = await self.ledger.network.get_transaction(txid)
height = await self.ledger.network.get_transaction_height(txid)
except CodeMessageError as e:
return {'success': False, 'code': e.code, 'message': e.message}
tx = self.ledger.transaction_class(unhexlify(_raw))
tx = self.ledger.transaction_class(unhexlify(raw))
await self.ledger.maybe_verify_transaction(tx, height)
return tx
@staticmethod

View file

@ -61,9 +61,7 @@ class LBRYElectrumX(ElectrumX):
transaction_info = await self.daemon.getrawtransaction(tx_hash, True)
if transaction_info and 'hex' in transaction_info and 'confirmations' in transaction_info:
# an unconfirmed transaction from lbrycrdd will not have a 'confirmations' field
height = self.db.db_height
height = height - transaction_info['confirmations']
return height
return (self.db.db_height - transaction_info['confirmations']) + 1
elif transaction_info and 'hex' in transaction_info:
return -1
return None

View file

@ -17,7 +17,7 @@ class TransactionCommandsTestCase(CommandTestCase):
sendtxid = await self.blockchain.send_to_address(change_address, 10)
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
self.assertEqual(tx.id, sendtxid)
self.assertEqual(tx.height, -2)
self.assertEqual(tx.height, -1)
await self.generate(1)
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
self.assertEqual(tx.height, self.ledger.headers.height)