diff --git a/lbry/wallet/orchstr8/node.py b/lbry/wallet/orchstr8/node.py index de0c69669..7042c05ad 100644 --- a/lbry/wallet/orchstr8/node.py +++ b/lbry/wallet/orchstr8/node.py @@ -335,9 +335,9 @@ class BlockchainNode: except asyncio.CancelledError: self.running.clear() raise - except: + except Exception as e: self.running.clear() - log.exception("boom") + log.exception('failed to start lbrycrdd', exc_info=e) async def stop(self, cleanup=True): self.stopped = True diff --git a/tests/integration/blockchain/test_blockchain_reorganization.py b/tests/integration/blockchain/test_blockchain_reorganization.py index dc9e1be28..f0f2854f6 100644 --- a/tests/integration/blockchain/test_blockchain_reorganization.py +++ b/tests/integration/blockchain/test_blockchain_reorganization.py @@ -1,9 +1,7 @@ import logging import asyncio -from binascii import unhexlify from lbry.testcase import CommandTestCase from lbry.wallet.server.prometheus import REORG_COUNT -from lbry.wallet.transaction import Transaction class BlockchainReorganizationTests(CommandTestCase): @@ -41,22 +39,27 @@ class BlockchainReorganizationTests(CommandTestCase): async def test_reorg_dropping_claim(self): # sanity check - result_txs, _, _, _ = await self.ledger.claim_search([], name='hovercraft') - self.assertListEqual(result_txs, []) + txos, _, _, _ = await self.ledger.claim_search([], name='hovercraft') + self.assertListEqual(txos, []) - # create a claim and verify it is returned by claim_search + # create a claim and verify it's returned by claim_search self.assertEqual(self.ledger.headers.height, 206) - broadcast_tx = Transaction(unhexlify((await self.stream_create(name='hovercraft'))['hex'].encode())) + broadcast_tx = await self.daemon.jsonrpc_stream_create( + 'hovercraft', '1.0', file_path=self.create_upload_file(data=b'hi!') + ) + await self.ledger.wait(broadcast_tx) + await self.generate(1) + await self.ledger.wait(broadcast_tx, self.blockchain.block_expected) self.assertEqual(self.ledger.headers.height, 207) - result_txs, _, _, _ = await self.ledger.claim_search([], name='hovercraft') - self.assertEqual(1, len(result_txs)) - tx = result_txs[0] - self.assertEqual(tx.tx_ref.id, broadcast_tx.id) + txos, _, _, _ = await self.ledger.claim_search([], name='hovercraft') + self.assertEqual(1, len(txos)) + txo = txos[0] + self.assertEqual(txo.tx_ref.id, broadcast_tx.id) # check that our tx is in block 207 as returned by lbrycrdd invalidated_block_hash = (await self.ledger.headers.hash(207)).decode() block_207 = await self.blockchain.get_block(invalidated_block_hash) - self.assertIn(tx.tx_ref.id, block_207['tx']) + self.assertIn(txo.tx_ref.id, block_207['tx']) # reorg the last block dropping our claim tx await self.blockchain.invalidate_block(invalidated_block_hash) @@ -67,7 +70,7 @@ class BlockchainReorganizationTests(CommandTestCase): reorg_block_hash = await self.blockchain.get_block_hash(207) self.assertNotEqual(invalidated_block_hash, reorg_block_hash) block_207 = await self.blockchain.get_block(reorg_block_hash) - self.assertNotIn(tx.tx_ref.id, block_207['tx']) + self.assertNotIn(txo.tx_ref.id, block_207['tx']) # wait for the client to catch up and verify the reorg await asyncio.wait_for(self.on_header(208), 3.0) @@ -77,5 +80,6 @@ class BlockchainReorganizationTests(CommandTestCase): client_reorg_block_hash = (await self.ledger.headers.hash(207)).decode() self.assertEqual(client_reorg_block_hash, reorg_block_hash) - result_txs, _, _, _ = await self.ledger.claim_search([], name='hovercraft') - self.assertListEqual(result_txs, []) + # verify the dropped claim is no longer returned by claim search + txos, _, _, _ = await self.ledger.claim_search([], name='hovercraft') + self.assertListEqual(txos, [])