From 5602e1f1a6c1b69f2c87cc1754cf4850a70be525 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Fri, 14 Sep 2018 11:55:33 -0600 Subject: [PATCH] Allow passing timeout parameter to wait_and_assert_operationid_status --- qa/rpc-tests/mempool_tx_input_limit.py | 2 +- qa/rpc-tests/test_framework/util.py | 4 ++-- qa/rpc-tests/wallet_nullifiers.py | 8 ++++---- qa/rpc-tests/wallet_protectcoinbase.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qa/rpc-tests/mempool_tx_input_limit.py b/qa/rpc-tests/mempool_tx_input_limit.py index f91d9b52d..9a7131cfe 100755 --- a/qa/rpc-tests/mempool_tx_input_limit.py +++ b/qa/rpc-tests/mempool_tx_input_limit.py @@ -54,7 +54,7 @@ class MempoolTxInputLimitTest(BitcoinTestFramework): myopid = self.nodes[0].z_sendmany(node0_taddr, recipients) # Spend should fail due to -mempooltxinputlimit - wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Too many transparent inputs 3 > limit 2") + wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Too many transparent inputs 3 > limit 2", 120) # Mempool should be empty. assert_equal(set(self.nodes[0].getrawmempool()), set()) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 07d56204e..ca5bcee3e 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -383,10 +383,10 @@ def assert_raises(exc, fun, *args, **kwds): raise AssertionError("No exception raised") # Returns txid if operation was a success or None -def wait_and_assert_operationid_status(node, myopid, in_status='success', in_errormsg=None): +def wait_and_assert_operationid_status(node, myopid, in_status='success', in_errormsg=None, timeout=300): print('waiting for async operation {}'.format(myopid)) result = None - for x in xrange(1, 300): # 300 is the timeout + for _ in xrange(1, timeout): results = node.z_getoperationresult([myopid]) if len(results) > 0: result = results[0] diff --git a/qa/rpc-tests/wallet_nullifiers.py b/qa/rpc-tests/wallet_nullifiers.py index 4bd765ba9..9b4e5649c 100755 --- a/qa/rpc-tests/wallet_nullifiers.py +++ b/qa/rpc-tests/wallet_nullifiers.py @@ -25,7 +25,7 @@ class WalletNullifiersTest (BitcoinTestFramework): recipients = [] recipients.append({"address":myzaddr0, "amount":Decimal('10.0')-Decimal('0.0001')}) # utxo amount less fee - wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(mytaddr, recipients)) + wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(mytaddr, recipients), timeout=120) self.sync_all() self.nodes[0].generate(1) @@ -52,7 +52,7 @@ class WalletNullifiersTest (BitcoinTestFramework): recipients = [] recipients.append({"address":myzaddr, "amount":7.0}) - wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(myzaddr0, recipients)) + wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(myzaddr0, recipients), timeout=120) self.sync_all() self.nodes[0].generate(1) @@ -70,7 +70,7 @@ class WalletNullifiersTest (BitcoinTestFramework): recipients = [] recipients.append({"address":myzaddr3, "amount":2.0}) - wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(myzaddr, recipients)) + wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(myzaddr, recipients), timeout=120) self.sync_all() self.nodes[2].generate(1) @@ -97,7 +97,7 @@ class WalletNullifiersTest (BitcoinTestFramework): recipients = [] recipients.append({"address":mytaddr1, "amount":1.0}) - wait_and_assert_operationid_status(self.nodes[1], self.nodes[1].z_sendmany(myzaddr, recipients)) + wait_and_assert_operationid_status(self.nodes[1], self.nodes[1].z_sendmany(myzaddr, recipients), timeout=120) self.sync_all() self.nodes[1].generate(1) diff --git a/qa/rpc-tests/wallet_protectcoinbase.py b/qa/rpc-tests/wallet_protectcoinbase.py index 9c7c537cb..71512840d 100755 --- a/qa/rpc-tests/wallet_protectcoinbase.py +++ b/qa/rpc-tests/wallet_protectcoinbase.py @@ -82,7 +82,7 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework): recipients= [{"address":myzaddr, "amount": Decimal('1')}] myopid = self.nodes[3].z_sendmany(mytaddr, recipients) - wait_and_assert_operationid_status(self.nodes[3], myopid, "failed", "no UTXOs found for taddr from address") + wait_and_assert_operationid_status(self.nodes[3], myopid, "failed", "no UTXOs found for taddr from address", 10) # This send will fail because our wallet does not allow any change when protecting a coinbase utxo, # as it's currently not possible to specify a change address in z_sendmany. @@ -90,7 +90,7 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework): recipients.append({"address":myzaddr, "amount":Decimal('1.23456789')}) myopid = self.nodes[0].z_sendmany(mytaddr, recipients) - error_result = wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "wallet does not allow any change") + error_result = wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "wallet does not allow any change", 10) # Test that the returned status object contains a params field with the operation's input parameters assert_equal(error_result["method"], "z_sendmany")