From 98e264f4cd1f713fbcdb4f9a0c413bb38e3c991a Mon Sep 17 00:00:00 2001 From: Brannon King Date: Fri, 17 Dec 2021 14:27:30 -0500 Subject: [PATCH] fix for the send-to-address timeout in asyncSetup --- lbry/testcase.py | 4 +--- lbry/wallet/orchstr8/service.py | 9 ++++++--- tests/integration/blockchain/test_purchase_command.py | 3 +-- .../transactions/test_transaction_commands.py | 5 ++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lbry/testcase.py b/lbry/testcase.py index ba2325805..470c3f6d2 100644 --- a/lbry/testcase.py +++ b/lbry/testcase.py @@ -385,9 +385,7 @@ class CommandTestCase(IntegrationTestCase): await self.account.ensure_address_gap() address = (await self.account.receiving.get_addresses(limit=1, only_usable=True))[0] - sendtxid = await self.blockchain.send_to_address(address, 10) - await self.confirm_tx(sendtxid) - await self.generate(5) + await self.send_to_address_and_wait(address, 10, 6) server_tmp_dir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, server_tmp_dir) diff --git a/lbry/wallet/orchstr8/service.py b/lbry/wallet/orchstr8/service.py index 032a35ac0..fac3e49ea 100644 --- a/lbry/wallet/orchstr8/service.py +++ b/lbry/wallet/orchstr8/service.py @@ -87,11 +87,14 @@ class ConductorService: if not address: raise ValueError("No address was provided.") amount = data.get('amount', 1) - txid = await self.stack.lbcwallet_node.send_to_address(address, amount) if self.stack.wallet_started: - await self.stack.wallet_node.ledger.on_transaction.where( - lambda e: e.tx.id == txid and e.address == address + watcher = self.stack.wallet_node.ledger.on_transaction.where( + lambda e: e.address == address # and e.tx.id == txid -- might stall; see send_to_address_and_wait ) + txid = await self.stack.lbcwallet_node.send_to_address(address, amount) + await watcher + else: + txid = await self.stack.lbcwallet_node.send_to_address(address, amount) return json_response({ 'address': address, 'amount': amount, diff --git a/tests/integration/blockchain/test_purchase_command.py b/tests/integration/blockchain/test_purchase_command.py index 64e99a7ac..8d3d45374 100644 --- a/tests/integration/blockchain/test_purchase_command.py +++ b/tests/integration/blockchain/test_purchase_command.py @@ -174,8 +174,7 @@ class PurchaseCommandTests(CommandTestCase): self.merchant_address = await self.account.receiving.get_or_create_usable_address() daemon2 = await self.add_daemon() address2 = await daemon2.wallet_manager.default_account.receiving.get_or_create_usable_address() - sendtxid = await self.blockchain.send_to_address(address2, 2) - await self.confirm_tx(sendtxid, daemon2.ledger) + await self.send_to_address_and_wait(address2, 2, 1, ledger=daemon2.ledger) stream = await self.priced_stream('a', '1.0') await self.assertBalance(self.account, '9.987893') diff --git a/tests/integration/transactions/test_transaction_commands.py b/tests/integration/transactions/test_transaction_commands.py index 1b193ae89..b2994dbdd 100644 --- a/tests/integration/transactions/test_transaction_commands.py +++ b/tests/integration/transactions/test_transaction_commands.py @@ -40,10 +40,9 @@ class TransactionCommandsTestCase(CommandTestCase): self.assertFalse(result['success']) async def test_utxo_release(self): - sendtxid = await self.blockchain.send_to_address( - await self.account.receiving.get_or_create_usable_address(), 1 + await self.send_to_address_and_wait( + await self.account.receiving.get_or_create_usable_address(), 1, 1 ) - await self.confirm_tx(sendtxid) await self.assertBalance(self.account, '11.0') await self.ledger.reserve_outputs(await self.account.get_utxos()) await self.assertBalance(self.account, '0.0')