Deduplicate test utility method wait_and_assert_operationid_status
Strictly speaking this is not a true deduplication; the test output will be slightly different (due to inconsistent print statements) but I think this is close enough.
This commit is contained in:
@@ -8,9 +8,8 @@
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
initialize_datadir, start_nodes, start_node, connect_nodes_bi, \
|
||||
bitcoind_processes
|
||||
bitcoind_processes, wait_and_assert_operationid_status
|
||||
|
||||
import time
|
||||
from decimal import Decimal
|
||||
|
||||
starttime = 1388534400
|
||||
@@ -41,30 +40,6 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
self.sync_all()
|
||||
|
||||
def wait_and_assert_operationid_status(self, myopid, in_status='success', in_errormsg=None):
|
||||
print('waiting for async operation {}'.format(myopid))
|
||||
opids = []
|
||||
opids.append(myopid)
|
||||
timeout = 300
|
||||
status = None
|
||||
errormsg = None
|
||||
for x in xrange(1, timeout):
|
||||
results = self.nodes[0].z_getoperationresult(opids)
|
||||
if len(results)==0:
|
||||
time.sleep(1)
|
||||
else:
|
||||
status = results[0]["status"]
|
||||
if status == "failed":
|
||||
errormsg = results[0]['error']['message']
|
||||
break
|
||||
print('...returned status: {}'.format(status))
|
||||
print('...error msg: {}'.format(errormsg))
|
||||
assert_equal(in_status, status)
|
||||
if errormsg is not None:
|
||||
assert(in_errormsg is not None)
|
||||
assert_equal(in_errormsg in errormsg, True)
|
||||
print('...returned error: {}'.format(errormsg))
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
|
||||
@@ -78,7 +53,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount":Decimal('10.0') - Decimal('0.0001')})
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
self.wait_and_assert_operationid_status(myopid)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
# Ensure the block times of the latest blocks exceed the variability
|
||||
|
||||
Reference in New Issue
Block a user