Use utility method to wait for async operations
This commit is contained in:
@@ -54,22 +54,8 @@ class MempoolTxInputLimitTest(BitcoinTestFramework):
|
|||||||
recipients.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee
|
recipients.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
|
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
|
||||||
|
|
||||||
opids = []
|
|
||||||
opids.append(myopid)
|
|
||||||
|
|
||||||
# Spend should fail due to -mempooltxinputlimit
|
# Spend should fail due to -mempooltxinputlimit
|
||||||
timeout = 120
|
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Too many transparent inputs 3 > limit 2")
|
||||||
status = 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"]
|
|
||||||
msg = results[0]["error"]["message"]
|
|
||||||
assert_equal("failed", status)
|
|
||||||
assert_equal("Too many transparent inputs 3 > limit 2", msg)
|
|
||||||
break
|
|
||||||
|
|
||||||
# Mempool should be empty.
|
# Mempool should be empty.
|
||||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||||||
from test_framework.authproxy import JSONRPCException
|
from test_framework.authproxy import JSONRPCException
|
||||||
from test_framework.util import assert_equal, assert_greater_than, \
|
from test_framework.util import assert_equal, assert_greater_than, \
|
||||||
initialize_chain_clean, start_nodes, start_node, connect_nodes_bi, \
|
initialize_chain_clean, start_nodes, start_node, connect_nodes_bi, \
|
||||||
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds
|
stop_nodes, sync_blocks, sync_mempools, wait_and_assert_operationid_status, \
|
||||||
|
wait_bitcoinds
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
@@ -348,23 +349,9 @@ class WalletTest (BitcoinTestFramework):
|
|||||||
# send node 2 taddr to zaddr
|
# send node 2 taddr to zaddr
|
||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":myzaddr, "amount":7})
|
recipients.append({"address":myzaddr, "amount":7})
|
||||||
myopid = self.nodes[2].z_sendmany(mytaddr, recipients)
|
|
||||||
|
|
||||||
opids = []
|
mytxid = wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(mytaddr, recipients))
|
||||||
opids.append(myopid)
|
|
||||||
|
|
||||||
timeout = 300
|
|
||||||
status = None
|
|
||||||
for x in xrange(1, timeout):
|
|
||||||
results = self.nodes[2].z_getoperationresult(opids)
|
|
||||||
if len(results)==0:
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
|
||||||
status = results[0]["status"]
|
|
||||||
mytxid = results[0]["result"]["txid"]
|
|
||||||
break
|
|
||||||
|
|
||||||
assert_equal("success", status)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
@@ -399,7 +386,6 @@ class WalletTest (BitcoinTestFramework):
|
|||||||
assert("randomSeed" in myjoinsplit.keys())
|
assert("randomSeed" in myjoinsplit.keys())
|
||||||
assert("ciphertexts" in myjoinsplit.keys())
|
assert("ciphertexts" in myjoinsplit.keys())
|
||||||
|
|
||||||
|
|
||||||
# send from private note to node 0 and node 2
|
# send from private note to node 0 and node 2
|
||||||
node0balance = self.nodes[0].getbalance() # 25.99794745
|
node0balance = self.nodes[0].getbalance() # 25.99794745
|
||||||
node2balance = self.nodes[2].getbalance() # 16.99790000
|
node2balance = self.nodes[2].getbalance() # 16.99790000
|
||||||
@@ -407,20 +393,9 @@ class WalletTest (BitcoinTestFramework):
|
|||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":self.nodes[0].getnewaddress(), "amount":1})
|
recipients.append({"address":self.nodes[0].getnewaddress(), "amount":1})
|
||||||
recipients.append({"address":self.nodes[2].getnewaddress(), "amount":1.0})
|
recipients.append({"address":self.nodes[2].getnewaddress(), "amount":1.0})
|
||||||
myopid = self.nodes[2].z_sendmany(myzaddr, recipients)
|
|
||||||
|
wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(myzaddr, recipients))
|
||||||
|
|
||||||
status = None
|
|
||||||
opids = []
|
|
||||||
opids.append(myopid)
|
|
||||||
for x in xrange(1, timeout):
|
|
||||||
results = self.nodes[2].z_getoperationresult(opids)
|
|
||||||
if len(results)==0:
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
|
||||||
status = results[0]["status"]
|
|
||||||
break
|
|
||||||
|
|
||||||
assert_equal("success", status)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import assert_equal, assert_true, start_node, \
|
from test_framework.util import assert_equal, assert_true, bitcoind_processes, \
|
||||||
start_nodes, connect_nodes_bi, bitcoind_processes
|
connect_nodes_bi, start_node, start_nodes, wait_and_assert_operationid_status
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
@@ -25,22 +25,8 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||||||
mytaddr = self.nodes[0].getnewaddress();
|
mytaddr = self.nodes[0].getnewaddress();
|
||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":myzaddr0, "amount":Decimal('10.0')-Decimal('0.0001')}) # utxo amount less fee
|
recipients.append({"address":myzaddr0, "amount":Decimal('10.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
|
||||||
|
wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(mytaddr, recipients))
|
||||||
opids = []
|
|
||||||
opids.append(myopid)
|
|
||||||
|
|
||||||
timeout = 120
|
|
||||||
status = 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"]
|
|
||||||
assert_equal("success", status)
|
|
||||||
mytxid = results[0]["result"]["txid"]
|
|
||||||
break
|
|
||||||
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
@@ -66,22 +52,8 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||||||
# send node 0 zaddr to note 2 zaddr
|
# send node 0 zaddr to note 2 zaddr
|
||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":myzaddr, "amount":7.0})
|
recipients.append({"address":myzaddr, "amount":7.0})
|
||||||
myopid = self.nodes[0].z_sendmany(myzaddr0, recipients)
|
|
||||||
|
wait_and_assert_operationid_status(self.nodes[0], self.nodes[0].z_sendmany(myzaddr0, recipients))
|
||||||
opids = []
|
|
||||||
opids.append(myopid)
|
|
||||||
|
|
||||||
timeout = 120
|
|
||||||
status = 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"]
|
|
||||||
assert_equal("success", status)
|
|
||||||
mytxid = results[0]["result"]["txid"]
|
|
||||||
break
|
|
||||||
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
@@ -98,22 +70,8 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||||||
# send node 2 zaddr to note 3 zaddr
|
# send node 2 zaddr to note 3 zaddr
|
||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":myzaddr3, "amount":2.0})
|
recipients.append({"address":myzaddr3, "amount":2.0})
|
||||||
myopid = self.nodes[2].z_sendmany(myzaddr, recipients)
|
|
||||||
|
|
||||||
opids = []
|
wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(myzaddr, recipients))
|
||||||
opids.append(myopid)
|
|
||||||
|
|
||||||
timeout = 120
|
|
||||||
status = None
|
|
||||||
for x in xrange(1, timeout):
|
|
||||||
results = self.nodes[2].z_getoperationresult(opids)
|
|
||||||
if len(results)==0:
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
|
||||||
status = results[0]["status"]
|
|
||||||
assert_equal("success", status)
|
|
||||||
mytxid = results[0]["result"]["txid"]
|
|
||||||
break
|
|
||||||
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
@@ -139,23 +97,8 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||||||
mytaddr1 = self.nodes[1].getnewaddress();
|
mytaddr1 = self.nodes[1].getnewaddress();
|
||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":mytaddr1, "amount":1.0})
|
recipients.append({"address":mytaddr1, "amount":1.0})
|
||||||
myopid = self.nodes[1].z_sendmany(myzaddr, recipients)
|
|
||||||
|
wait_and_assert_operationid_status(self.nodes[1], self.nodes[1].z_sendmany(myzaddr, recipients))
|
||||||
opids = []
|
|
||||||
opids.append(myopid)
|
|
||||||
|
|
||||||
timeout = 120
|
|
||||||
status = None
|
|
||||||
for x in xrange(1, timeout):
|
|
||||||
results = self.nodes[1].z_getoperationresult(opids)
|
|
||||||
if len(results)==0:
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
|
||||||
status = results[0]["status"]
|
|
||||||
assert_equal("success", status)
|
|
||||||
mytxid = results[0]["result"]["txid"]
|
|
||||||
[mytxid] # hush pyflakes
|
|
||||||
break
|
|
||||||
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
@@ -206,7 +149,6 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
|||||||
if key != 'change':
|
if key != 'change':
|
||||||
assert_equal(received2[key], received3[key])
|
assert_equal(received2[key], received3[key])
|
||||||
|
|
||||||
|
|
||||||
# Node 3's balances should be unchanged without explicitly requesting
|
# Node 3's balances should be unchanged without explicitly requesting
|
||||||
# to include watch-only balances
|
# to include watch-only balances
|
||||||
assert_equal({k: Decimal(v) for k, v in self.nodes[3].z_gettotalbalance().items()}, {
|
assert_equal({k: Decimal(v) for k, v in self.nodes[3].z_gettotalbalance().items()}, {
|
||||||
|
|||||||
@@ -82,50 +82,25 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
|
|||||||
self.nodes[3].importaddress(mytaddr)
|
self.nodes[3].importaddress(mytaddr)
|
||||||
recipients= [{"address":myzaddr, "amount": Decimal('1')}]
|
recipients= [{"address":myzaddr, "amount": Decimal('1')}]
|
||||||
myopid = self.nodes[3].z_sendmany(mytaddr, recipients)
|
myopid = self.nodes[3].z_sendmany(mytaddr, recipients)
|
||||||
errorString=""
|
|
||||||
status = None
|
wait_and_assert_operationid_status(self.nodes[3], myopid, "failed", "no UTXOs found for taddr from address")
|
||||||
opids = [myopid]
|
|
||||||
timeout = 10
|
|
||||||
for x in xrange(1, timeout):
|
|
||||||
results = self.nodes[3].z_getoperationresult(opids)
|
|
||||||
if len(results)==0:
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
|
||||||
status = results[0]["status"]
|
|
||||||
errorString = results[0]["error"]["message"]
|
|
||||||
break
|
|
||||||
assert_equal("failed", status)
|
|
||||||
assert_equal("no UTXOs found for taddr from address" in errorString, True)
|
|
||||||
|
|
||||||
# This send will fail because our wallet does not allow any change when protecting a coinbase utxo,
|
# 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.
|
# as it's currently not possible to specify a change address in z_sendmany.
|
||||||
recipients = []
|
recipients = []
|
||||||
recipients.append({"address":myzaddr, "amount":Decimal('1.23456789')})
|
recipients.append({"address":myzaddr, "amount":Decimal('1.23456789')})
|
||||||
errorString = ""
|
|
||||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||||
opids = []
|
error_result = wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "wallet does not allow any change")
|
||||||
opids.append(myopid)
|
|
||||||
timeout = 10
|
|
||||||
status = 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"]
|
|
||||||
errorString = results[0]["error"]["message"]
|
|
||||||
|
|
||||||
# Test that the returned status object contains a params field with the operation's input parameters
|
# Test that the returned status object contains a params field with the operation's input parameters
|
||||||
assert_equal(results[0]["method"], "z_sendmany")
|
assert_equal(error_result["method"], "z_sendmany")
|
||||||
params =results[0]["params"]
|
params = error_result["params"]
|
||||||
assert_equal(params["fee"], Decimal('0.0001')) # default
|
assert_equal(params["fee"], Decimal('0.0001')) # default
|
||||||
assert_equal(params["minconf"], Decimal('1')) # default
|
assert_equal(params["minconf"], Decimal('1')) # default
|
||||||
assert_equal(params["fromaddress"], mytaddr)
|
assert_equal(params["fromaddress"], mytaddr)
|
||||||
assert_equal(params["amounts"][0]["address"], myzaddr)
|
assert_equal(params["amounts"][0]["address"], myzaddr)
|
||||||
assert_equal(params["amounts"][0]["amount"], Decimal('1.23456789'))
|
assert_equal(params["amounts"][0]["amount"], Decimal('1.23456789'))
|
||||||
break
|
|
||||||
assert_equal("failed", status)
|
|
||||||
assert_equal("wallet does not allow any change" in errorString, True)
|
|
||||||
|
|
||||||
# Add viewing key for myzaddr to Node 3
|
# Add viewing key for myzaddr to Node 3
|
||||||
myviewingkey = self.nodes[0].z_exportviewingkey(myzaddr)
|
myviewingkey = self.nodes[0].z_exportviewingkey(myzaddr)
|
||||||
|
|||||||
Reference in New Issue
Block a user