From 587f0b2ea807d7952c7bb524aaed93c79b6c0547 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sun, 5 May 2019 16:57:34 -0400 Subject: [PATCH] integration tests for jsonrpc_transaction_show fixed --- lbrynet/wallet/manager.py | 6 ++++-- lbrynet/wallet/server/session.py | 4 +--- tests/integration/test_transaction_commands.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lbrynet/wallet/manager.py b/lbrynet/wallet/manager.py index 8f97e8e7f..d9627ead9 100644 --- a/lbrynet/wallet/manager.py +++ b/lbrynet/wallet/manager.py @@ -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 diff --git a/lbrynet/wallet/server/session.py b/lbrynet/wallet/server/session.py index 1d71837fe..842a7232d 100644 --- a/lbrynet/wallet/server/session.py +++ b/lbrynet/wallet/server/session.py @@ -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 diff --git a/tests/integration/test_transaction_commands.py b/tests/integration/test_transaction_commands.py index ac1010931..4d22c07d6 100644 --- a/tests/integration/test_transaction_commands.py +++ b/tests/integration/test_transaction_commands.py @@ -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)