Auto merge of #3479 - Eirik0:rpc-test-cleanup, r=bitcartel
Rpc test cleanup The main purpose of this PR was to inline the method 'wait_for_async_operation_id' from util.py in tests where we were doing this manually. To make it work in all cases, I had to change the method to return the result in the case where the call failed. I also did a bit of general clean up (removing semicolons) in the files which I changed.
This commit is contained in:
commit
379c7439a0
|
@ -8,7 +8,6 @@ from test_framework.authproxy import JSONRPCException
|
||||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||||
start_node, connect_nodes, wait_and_assert_operationid_status
|
start_node, connect_nodes, wait_and_assert_operationid_status
|
||||||
|
|
||||||
import time
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
# Test -mempooltxinputlimit
|
# Test -mempooltxinputlimit
|
||||||
|
@ -49,27 +48,13 @@ class MempoolTxInputLimitTest(BitcoinTestFramework):
|
||||||
node0_zaddr = self.nodes[0].z_getnewaddress()
|
node0_zaddr = self.nodes[0].z_getnewaddress()
|
||||||
|
|
||||||
# Send three inputs from node 0 taddr to zaddr to get out of coinbase
|
# Send three inputs from node 0 taddr to zaddr to get out of coinbase
|
||||||
node0_taddr = self.nodes[0].getnewaddress();
|
node0_taddr = self.nodes[0].getnewaddress()
|
||||||
recipients = []
|
recipients = []
|
||||||
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", 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"]
|
|
||||||
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())
|
||||||
|
|
|
@ -76,13 +76,13 @@ def initialize_datadir(dirname, n):
|
||||||
if not os.path.isdir(datadir):
|
if not os.path.isdir(datadir):
|
||||||
os.makedirs(datadir)
|
os.makedirs(datadir)
|
||||||
with open(os.path.join(datadir, "zcash.conf"), 'w') as f:
|
with open(os.path.join(datadir, "zcash.conf"), 'w') as f:
|
||||||
f.write("regtest=1\n");
|
f.write("regtest=1\n")
|
||||||
f.write("showmetrics=0\n");
|
f.write("showmetrics=0\n")
|
||||||
f.write("rpcuser=rt\n");
|
f.write("rpcuser=rt\n")
|
||||||
f.write("rpcpassword=rt\n");
|
f.write("rpcpassword=rt\n")
|
||||||
f.write("port="+str(p2p_port(n))+"\n");
|
f.write("port="+str(p2p_port(n))+"\n")
|
||||||
f.write("rpcport="+str(rpc_port(n))+"\n");
|
f.write("rpcport="+str(rpc_port(n))+"\n")
|
||||||
f.write("listenonion=0\n");
|
f.write("listenonion=0\n")
|
||||||
return datadir
|
return datadir
|
||||||
|
|
||||||
def initialize_chain(test_dir):
|
def initialize_chain(test_dir):
|
||||||
|
@ -383,31 +383,36 @@ def assert_raises(exc, fun, *args, **kwds):
|
||||||
raise AssertionError("No exception raised")
|
raise AssertionError("No exception raised")
|
||||||
|
|
||||||
# Returns txid if operation was a success or None
|
# 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))
|
print('waiting for async operation {}'.format(myopid))
|
||||||
opids = []
|
result = None
|
||||||
opids.append(myopid)
|
for _ in xrange(1, timeout):
|
||||||
timeout = 300
|
results = node.z_getoperationresult([myopid])
|
||||||
status = None
|
if len(results) > 0:
|
||||||
errormsg = None
|
result = results[0]
|
||||||
txid = None
|
|
||||||
for x in xrange(1, timeout):
|
|
||||||
results = node.z_getoperationresult(opids)
|
|
||||||
if len(results)==0:
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
|
||||||
status = results[0]["status"]
|
|
||||||
if status == "failed":
|
|
||||||
errormsg = results[0]['error']['message']
|
|
||||||
elif status == "success":
|
|
||||||
txid = results[0]['result']['txid']
|
|
||||||
break
|
break
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
assert_true(result is not None, "timeout occured")
|
||||||
|
status = result['status']
|
||||||
|
|
||||||
|
txid = None
|
||||||
|
errormsg = None
|
||||||
|
if status == "failed":
|
||||||
|
errormsg = result['error']['message']
|
||||||
|
elif status == "success":
|
||||||
|
txid = result['result']['txid']
|
||||||
|
|
||||||
if os.getenv("PYTHON_DEBUG", ""):
|
if os.getenv("PYTHON_DEBUG", ""):
|
||||||
print('...returned status: {}'.format(status))
|
print('...returned status: {}'.format(status))
|
||||||
if errormsg is not None:
|
if errormsg is not None:
|
||||||
print('...returned error: {}'.format(errormsg))
|
print('...returned error: {}'.format(errormsg))
|
||||||
assert_equal(in_status, status)
|
|
||||||
|
assert_equal(in_status, status, "Operation returned mismatched status. Error Message: {}".format(errormsg))
|
||||||
|
|
||||||
if errormsg is not None:
|
if errormsg is not None:
|
||||||
assert(in_errormsg is not None)
|
assert_true(in_errormsg is not None, "No error retured. Expected: {}".format(errormsg))
|
||||||
assert_equal(in_errormsg in errormsg, True)
|
assert_true(in_errormsg in errormsg, "Error returned: {}. Error expected: {}".format(errormsg, in_errormsg))
|
||||||
return txid
|
return result # if there was an error return the result
|
||||||
|
else:
|
||||||
|
return txid # otherwise return the txid
|
||||||
|
|
|
@ -8,9 +8,9 @@ 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
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
class WalletTest (BitcoinTestFramework):
|
class WalletTest (BitcoinTestFramework):
|
||||||
|
@ -219,7 +219,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
for uTx in unspentTxs:
|
for uTx in unspentTxs:
|
||||||
if uTx['txid'] == zeroValueTxid:
|
if uTx['txid'] == zeroValueTxid:
|
||||||
found = True
|
found = True
|
||||||
assert_equal(uTx['amount'], Decimal('0.00000000'));
|
assert_equal(uTx['amount'], Decimal('0.00000000'))
|
||||||
assert(found)
|
assert(found)
|
||||||
|
|
||||||
#do some -walletbroadcast tests
|
#do some -walletbroadcast tests
|
||||||
|
@ -231,13 +231,13 @@ class WalletTest (BitcoinTestFramework):
|
||||||
connect_nodes_bi(self.nodes,0,2)
|
connect_nodes_bi(self.nodes,0,2)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
|
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
|
||||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[1].generate(1) #mine a block, tx should not be in there
|
self.nodes[1].generate(1) #mine a block, tx should not be in there
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('9.99800000')); #should not be changed because tx was not broadcasted
|
assert_equal(self.nodes[2].getbalance(), Decimal('9.99800000')) #should not be changed because tx was not broadcasted
|
||||||
assert_equal(self.nodes[2].getbalance("*"), Decimal('9.99800000')); #should not be changed because tx was not broadcasted
|
assert_equal(self.nodes[2].getbalance("*"), Decimal('9.99800000')) #should not be changed because tx was not broadcasted
|
||||||
|
|
||||||
#now broadcast from another node, mine a block, sync, and check the balance
|
#now broadcast from another node, mine a block, sync, and check the balance
|
||||||
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
|
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
|
||||||
|
@ -245,11 +245,11 @@ class WalletTest (BitcoinTestFramework):
|
||||||
self.nodes[1].generate(1)
|
self.nodes[1].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('11.99800000')); #should not be
|
assert_equal(self.nodes[2].getbalance(), Decimal('11.99800000')) #should not be
|
||||||
assert_equal(self.nodes[2].getbalance("*"), Decimal('11.99800000')); #should not be
|
assert_equal(self.nodes[2].getbalance("*"), Decimal('11.99800000')) #should not be
|
||||||
|
|
||||||
#create another tx
|
#create another tx
|
||||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2);
|
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
|
||||||
|
|
||||||
#restart the nodes with -walletbroadcast=1
|
#restart the nodes with -walletbroadcast=1
|
||||||
stop_nodes(self.nodes)
|
stop_nodes(self.nodes)
|
||||||
|
@ -264,18 +264,18 @@ class WalletTest (BitcoinTestFramework):
|
||||||
sync_blocks(self.nodes)
|
sync_blocks(self.nodes)
|
||||||
|
|
||||||
#tx should be added to balance because after restarting the nodes tx should be broadcastet
|
#tx should be added to balance because after restarting the nodes tx should be broadcastet
|
||||||
assert_equal(self.nodes[2].getbalance(), Decimal('13.99800000')); #should not be
|
assert_equal(self.nodes[2].getbalance(), Decimal('13.99800000')) #should not be
|
||||||
assert_equal(self.nodes[2].getbalance("*"), Decimal('13.99800000')); #should not be
|
assert_equal(self.nodes[2].getbalance("*"), Decimal('13.99800000')) #should not be
|
||||||
|
|
||||||
# send from node 0 to node 2 taddr
|
# send from node 0 to node 2 taddr
|
||||||
mytaddr = self.nodes[2].getnewaddress();
|
mytaddr = self.nodes[2].getnewaddress()
|
||||||
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0);
|
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
mybalance = self.nodes[2].z_getbalance(mytaddr)
|
mybalance = self.nodes[2].z_getbalance(mytaddr)
|
||||||
assert_equal(mybalance, Decimal('10.0'));
|
assert_equal(mybalance, Decimal('10.0'))
|
||||||
|
|
||||||
mytxdetails = self.nodes[2].gettransaction(mytxid)
|
mytxdetails = self.nodes[2].gettransaction(mytxid)
|
||||||
myvjoinsplits = mytxdetails["vjoinsplit"]
|
myvjoinsplits = mytxdetails["vjoinsplit"]
|
||||||
|
@ -348,23 +348,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()
|
||||||
|
@ -378,7 +364,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
assert_equal(self.nodes[2].getbalance("*"), node2utxobalance)
|
assert_equal(self.nodes[2].getbalance("*"), node2utxobalance)
|
||||||
|
|
||||||
# check zaddr balance
|
# check zaddr balance
|
||||||
assert_equal(self.nodes[2].z_getbalance(myzaddr), zsendmanynotevalue);
|
assert_equal(self.nodes[2].z_getbalance(myzaddr), zsendmanynotevalue)
|
||||||
|
|
||||||
# check via z_gettotalbalance
|
# check via z_gettotalbalance
|
||||||
resp = self.nodes[2].z_gettotalbalance()
|
resp = self.nodes[2].z_gettotalbalance()
|
||||||
|
@ -399,7 +385,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 +392,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()
|
||||||
|
@ -453,7 +427,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
except JSONRPCException,e:
|
except JSONRPCException,e:
|
||||||
errorString = e.error['message']
|
errorString = e.error['message']
|
||||||
|
|
||||||
assert_equal("Invalid amount" in errorString, True);
|
assert_equal("Invalid amount" in errorString, True)
|
||||||
|
|
||||||
errorString = ""
|
errorString = ""
|
||||||
try:
|
try:
|
||||||
|
@ -461,7 +435,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
except JSONRPCException,e:
|
except JSONRPCException,e:
|
||||||
errorString = e.error['message']
|
errorString = e.error['message']
|
||||||
|
|
||||||
assert_equal("not an integer" in errorString, True);
|
assert_equal("not an integer" in errorString, True)
|
||||||
|
|
||||||
myzaddr = self.nodes[0].z_getnewaddress()
|
myzaddr = self.nodes[0].z_getnewaddress()
|
||||||
recipients = [ {"address": myzaddr, "amount": Decimal('0.0') } ]
|
recipients = [ {"address": myzaddr, "amount": Decimal('0.0') } ]
|
||||||
|
|
|
@ -5,10 +5,9 @@
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
class WalletNullifiersTest (BitcoinTestFramework):
|
class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
|
@ -22,25 +21,11 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
myzaddr0 = self.nodes[0].z_getnewaddress()
|
myzaddr0 = self.nodes[0].z_getnewaddress()
|
||||||
|
|
||||||
# send node 0 taddr to zaddr to get out of coinbase
|
# send node 0 taddr to zaddr to get out of coinbase
|
||||||
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), timeout=120)
|
||||||
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 +51,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), timeout=120)
|
||||||
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 +69,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), timeout=120)
|
||||||
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)
|
||||||
|
@ -136,26 +93,11 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||||
# This requires that node 1 be unlocked, which triggers caching of
|
# This requires that node 1 be unlocked, which triggers caching of
|
||||||
# uncached nullifiers.
|
# uncached nullifiers.
|
||||||
self.nodes[1].walletpassphrase("test", 600)
|
self.nodes[1].walletpassphrase("test", 600)
|
||||||
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), timeout=120)
|
||||||
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 +148,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()}, {
|
||||||
|
|
|
@ -11,7 +11,6 @@ from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||||
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status
|
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import timeit
|
import timeit
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
@ -82,50 +81,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", 10)
|
||||||
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", 10)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue