Latest Zcash updates
This commit is contained in:
@@ -17,6 +17,7 @@ testScripts=(
|
||||
'wallet_treestate.py'
|
||||
'wallet_anchorfork.py'
|
||||
'wallet_changeindicator.py'
|
||||
'wallet_import_export.py'
|
||||
'wallet_protectcoinbase.py'
|
||||
'wallet_shieldcoinbase.py'
|
||||
'wallet_mergetoaddress.py'
|
||||
@@ -44,6 +45,7 @@ testScripts=(
|
||||
'merkle_blocks.py'
|
||||
# 'fundrawtransaction.py'
|
||||
'signrawtransactions.py'
|
||||
'signrawtransaction_offline.py'
|
||||
'walletbackup.py'
|
||||
'key_import_export.py'
|
||||
'nodehandling.py'
|
||||
@@ -61,7 +63,7 @@ testScripts=(
|
||||
'getblocktemplate.py'
|
||||
'bip65-cltv-p2p.py'
|
||||
'bipdersig-p2p.py'
|
||||
'overwinter_peer_management.py'
|
||||
'p2p_nu_peer_management.py'
|
||||
'rewind_index.py'
|
||||
'p2p_txexpiry_dos.py'
|
||||
'p2p_node_bloom.py'
|
||||
|
||||
@@ -8,7 +8,6 @@ from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_node, connect_nodes, wait_and_assert_operationid_status
|
||||
|
||||
import time
|
||||
from decimal import Decimal
|
||||
|
||||
# Test -mempooltxinputlimit
|
||||
@@ -49,27 +48,13 @@ class MempoolTxInputLimitTest(BitcoinTestFramework):
|
||||
node0_zaddr = self.nodes[0].z_getnewaddress()
|
||||
|
||||
# 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.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
|
||||
|
||||
opids = []
|
||||
opids.append(myopid)
|
||||
|
||||
# Spend should fail due to -mempooltxinputlimit
|
||||
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"]
|
||||
msg = results[0]["error"]["message"]
|
||||
assert_equal("failed", status)
|
||||
assert_equal("Too many transparent inputs 3 > limit 2", msg)
|
||||
break
|
||||
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())
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
|
||||
msg_ping, SPROUT_PROTO_VERSION, OVERWINTER_PROTO_VERSION
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import initialize_chain_clean, start_nodes, \
|
||||
p2p_port, assert_equal
|
||||
|
||||
import time
|
||||
|
||||
#
|
||||
# In this test we connect Sprout and Overwinter mininodes to a Zcashd node
|
||||
# which will activate Overwinter at block 10.
|
||||
#
|
||||
# We test:
|
||||
# 1. the mininodes stay connected to Zcash with Sprout consensus rules
|
||||
# 2. when Overwinter activates, the Sprout mininodes are dropped
|
||||
# 3. new Overwinter nodes can connect to Zcash
|
||||
# 4. new Sprout nodes cannot connect to Zcash
|
||||
#
|
||||
# This test *does not* verify that prior to Overwinter activation, the Zcashd
|
||||
# node will prefer connections with Overwinter nodes, with an eviction process
|
||||
# that prioritizes Sprout connections.
|
||||
#
|
||||
|
||||
|
||||
class TestManager(NodeConnCB):
|
||||
def __init__(self):
|
||||
NodeConnCB.__init__(self)
|
||||
self.create_callback_map()
|
||||
|
||||
def on_close(self, conn):
|
||||
pass
|
||||
|
||||
def on_reject(self, conn, message):
|
||||
conn.rejectMessage = message
|
||||
|
||||
|
||||
class OverwinterPeerManagementTest(BitcoinTestFramework):
|
||||
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory "+self.options.tmpdir
|
||||
initialize_chain_clean(self.options.tmpdir, 1)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = start_nodes(1, self.options.tmpdir,
|
||||
extra_args=[['-nuparams=5ba81b19:10', '-debug', '-whitelist=127.0.0.1']])
|
||||
|
||||
def run_test(self):
|
||||
test = TestManager()
|
||||
|
||||
# Launch 10 Sprout and 10 Overwinter mininodes
|
||||
nodes = []
|
||||
for x in xrange(10):
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test, "regtest", SPROUT_PROTO_VERSION))
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
|
||||
# Start up network handling in another thread
|
||||
NetworkThread().start()
|
||||
|
||||
# Sprout consensus rules apply at block height 9
|
||||
self.nodes[0].generate(9)
|
||||
assert_equal(9, self.nodes[0].getblockcount())
|
||||
|
||||
# Verify mininodes are still connected to zcashd node
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(10, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
|
||||
# Overwinter consensus rules activate at block height 10
|
||||
self.nodes[0].generate(1)
|
||||
assert_equal(10, self.nodes[0].getblockcount())
|
||||
|
||||
# Mininodes send ping message to zcashd node.
|
||||
pingCounter = 1
|
||||
for node in nodes:
|
||||
node.send_message(msg_ping(pingCounter))
|
||||
pingCounter = pingCounter + 1
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Verify Sprout mininodes have been dropped and Overwinter mininodes are still connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
|
||||
# Extend the Overwinter chain with another block.
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
# Connect a new Overwinter mininode to the zcashd node, which is accepted.
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
time.sleep(3)
|
||||
assert_equal(11, len(self.nodes[0].getpeerinfo()))
|
||||
|
||||
# Try to connect a new Sprout mininode to the zcashd node, which is rejected.
|
||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION)
|
||||
nodes.append(sprout)
|
||||
time.sleep(3)
|
||||
assert("Version must be 170003 or greater" in str(sprout.rejectMessage))
|
||||
|
||||
# Verify that only Overwinter mininodes are connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(11, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
|
||||
for node in nodes:
|
||||
node.disconnect_node()
|
||||
|
||||
if __name__ == '__main__':
|
||||
OverwinterPeerManagementTest().main()
|
||||
192
qa/rpc-tests/p2p_nu_peer_management.py
Executable file
192
qa/rpc-tests/p2p_nu_peer_management.py
Executable file
@@ -0,0 +1,192 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
from test_framework.mininode import (
|
||||
NodeConn,
|
||||
NodeConnCB,
|
||||
NetworkThread,
|
||||
msg_ping,
|
||||
SPROUT_PROTO_VERSION,
|
||||
OVERWINTER_PROTO_VERSION,
|
||||
SAPLING_PROTO_VERSION,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import initialize_chain_clean, start_nodes, \
|
||||
p2p_port, assert_equal
|
||||
|
||||
import time
|
||||
|
||||
#
|
||||
# In this test we connect Sprout, Overwinter, and Sapling mininodes to a Zcashd
|
||||
# node which will activate Overwinter at block 10 and Sapling at block 15.
|
||||
#
|
||||
# We test:
|
||||
# 1. the mininodes stay connected to Zcash with Sprout consensus rules
|
||||
# 2. when Overwinter activates, the Sprout mininodes are dropped
|
||||
# 3. new Overwinter and Sapling nodes can connect to Zcash
|
||||
# 4. new Sprout nodes cannot connect to Zcash
|
||||
# 5. when Sapling activates, the Overwinter mininodes are dropped
|
||||
# 6. new Sapling nodes can connect to Zcash
|
||||
# 7. new Sprout and Overwinter nodes cannot connect to Zcash
|
||||
#
|
||||
# This test *does not* verify that prior to each activation, the Zcashd
|
||||
# node will prefer connections with NU-aware nodes, with an eviction process
|
||||
# that prioritizes non-NU-aware connections.
|
||||
#
|
||||
|
||||
|
||||
class TestManager(NodeConnCB):
|
||||
def __init__(self):
|
||||
NodeConnCB.__init__(self)
|
||||
self.create_callback_map()
|
||||
|
||||
def on_close(self, conn):
|
||||
pass
|
||||
|
||||
def on_reject(self, conn, message):
|
||||
conn.rejectMessage = message
|
||||
|
||||
|
||||
class NUPeerManagementTest(BitcoinTestFramework):
|
||||
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory "+self.options.tmpdir
|
||||
initialize_chain_clean(self.options.tmpdir, 1)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = start_nodes(1, self.options.tmpdir, extra_args=[[
|
||||
'-nuparams=5ba81b19:10', # Overwinter
|
||||
'-nuparams=76b809bb:15', # Sapling
|
||||
'-debug',
|
||||
'-whitelist=127.0.0.1',
|
||||
]])
|
||||
|
||||
def run_test(self):
|
||||
test = TestManager()
|
||||
|
||||
# Launch Sprout, Overwinter, and Sapling mininodes
|
||||
nodes = []
|
||||
for x in xrange(10):
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test, "regtest", SPROUT_PROTO_VERSION))
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test, "regtest", SAPLING_PROTO_VERSION))
|
||||
|
||||
# Start up network handling in another thread
|
||||
NetworkThread().start()
|
||||
|
||||
# Sprout consensus rules apply at block height 9
|
||||
self.nodes[0].generate(9)
|
||||
assert_equal(9, self.nodes[0].getblockcount())
|
||||
|
||||
# Verify mininodes are still connected to zcashd node
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(10, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(10, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
# Overwinter consensus rules activate at block height 10
|
||||
self.nodes[0].generate(1)
|
||||
assert_equal(10, self.nodes[0].getblockcount())
|
||||
print('Overwinter active')
|
||||
|
||||
# Mininodes send ping message to zcashd node.
|
||||
pingCounter = 1
|
||||
for node in nodes:
|
||||
node.send_message(msg_ping(pingCounter))
|
||||
pingCounter = pingCounter + 1
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Verify Sprout mininodes have been dropped, while Overwinter and
|
||||
# Sapling mininodes are still connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(10, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
# Extend the Overwinter chain with another block.
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
# Connect a new Overwinter mininode to the zcashd node, which is accepted.
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
time.sleep(3)
|
||||
assert_equal(21, len(self.nodes[0].getpeerinfo()))
|
||||
|
||||
# Connect a new Sapling mininode to the zcashd node, which is accepted.
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SAPLING_PROTO_VERSION))
|
||||
time.sleep(3)
|
||||
assert_equal(22, len(self.nodes[0].getpeerinfo()))
|
||||
|
||||
# Try to connect a new Sprout mininode to the zcashd node, which is rejected.
|
||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION)
|
||||
nodes.append(sprout)
|
||||
time.sleep(3)
|
||||
assert("Version must be 170003 or greater" in str(sprout.rejectMessage))
|
||||
|
||||
# Verify that only Overwinter and Sapling mininodes are connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(11, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(11, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
# Sapling consensus rules activate at block height 15
|
||||
self.nodes[0].generate(4)
|
||||
assert_equal(15, self.nodes[0].getblockcount())
|
||||
print('Sapling active')
|
||||
|
||||
# Mininodes send ping message to zcashd node.
|
||||
pingCounter = 1
|
||||
for node in nodes:
|
||||
node.send_message(msg_ping(pingCounter))
|
||||
pingCounter = pingCounter + 1
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Verify Sprout and Overwinter mininodes have been dropped, while
|
||||
# Sapling mininodes are still connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(0, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(11, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
# Extend the Sapling chain with another block.
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
# Connect a new Sapling mininode to the zcashd node, which is accepted.
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SAPLING_PROTO_VERSION))
|
||||
time.sleep(3)
|
||||
assert_equal(12, len(self.nodes[0].getpeerinfo()))
|
||||
|
||||
# Try to connect a new Sprout mininode to the zcashd node, which is rejected.
|
||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION)
|
||||
nodes.append(sprout)
|
||||
time.sleep(3)
|
||||
assert("Version must be 170006 or greater" in str(sprout.rejectMessage))
|
||||
|
||||
# Try to connect a new Overwinter mininode to the zcashd node, which is rejected.
|
||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION)
|
||||
nodes.append(sprout)
|
||||
time.sleep(3)
|
||||
assert("Version must be 170006 or greater" in str(sprout.rejectMessage))
|
||||
|
||||
# Verify that only Sapling mininodes are connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(0, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(12, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
for node in nodes:
|
||||
node.disconnect_node()
|
||||
|
||||
if __name__ == '__main__':
|
||||
NUPeerManagementTest().main()
|
||||
46
qa/rpc-tests/signrawtransaction_offline.py
Executable file
46
qa/rpc-tests/signrawtransaction_offline.py
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node
|
||||
|
||||
class SignOfflineTest (BitcoinTestFramework):
|
||||
# Setup Methods
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory " + self.options.tmpdir
|
||||
initialize_chain_clean(self.options.tmpdir, 2)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = [ start_node(0, self.options.tmpdir, ["-nuparams=5ba81b19:10"]) ]
|
||||
self.is_network_split = False
|
||||
self.sync_all()
|
||||
|
||||
# Tests
|
||||
def run_test(self):
|
||||
print "Mining blocks..."
|
||||
self.nodes[0].generate(101)
|
||||
|
||||
offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=5ba81b19:10"])
|
||||
self.nodes.append(offline_node)
|
||||
|
||||
assert_equal(0, len(offline_node.getpeerinfo())) # make sure node 1 has no peers
|
||||
|
||||
privkeys = [self.nodes[0].dumpprivkey(self.nodes[0].getnewaddress())]
|
||||
taddr = self.nodes[0].getnewaddress()
|
||||
|
||||
tx = self.nodes[0].listunspent()[0]
|
||||
txid = tx['txid']
|
||||
scriptpubkey = tx['scriptPubKey']
|
||||
|
||||
create_inputs = [{'txid': txid, 'vout': 0}]
|
||||
sign_inputs = [{'txid': txid, 'vout': 0, 'scriptPubKey': scriptpubkey, 'amount': 10}]
|
||||
|
||||
create_hex = self.nodes[0].createrawtransaction(create_inputs, {taddr: 9.9999})
|
||||
|
||||
signed_tx = offline_node.signrawtransaction(create_hex, sign_inputs, privkeys)
|
||||
|
||||
# If we return the transaction hash, then we have have not thrown an error (success)
|
||||
online_tx_hash = self.nodes[0].sendrawtransaction(signed_tx['hex'])
|
||||
assert_true(len(online_tx_hash) > 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
SignOfflineTest().main()
|
||||
@@ -42,6 +42,7 @@ from .equihash import (
|
||||
OVERWINTER_PROTO_VERSION = 170003
|
||||
BIP0031_VERSION = 60000
|
||||
SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong
|
||||
SAPLING_PROTO_VERSION = 170006
|
||||
MY_SUBVERSION = "/python-mininode-tester:0.0.1/"
|
||||
|
||||
OVERWINTER_VERSION_GROUP_ID = 0x03C48270
|
||||
@@ -1415,7 +1416,7 @@ class NodeConn(asyncore.dispatcher):
|
||||
vt.addrFrom.port = 0
|
||||
self.send_message(vt, True)
|
||||
print 'MiniNode: Connecting to Bitcoin Node IP # ' + dstaddr + ':' \
|
||||
+ str(dstport)
|
||||
+ str(dstport) + ' using version ' + str(protocol_version)
|
||||
|
||||
try:
|
||||
self.connect((dstaddr, dstport))
|
||||
|
||||
@@ -417,31 +417,36 @@ 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))
|
||||
opids = []
|
||||
opids.append(myopid)
|
||||
timeout = 300
|
||||
status = None
|
||||
errormsg = None
|
||||
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']
|
||||
result = None
|
||||
for _ in xrange(1, timeout):
|
||||
results = node.z_getoperationresult([myopid])
|
||||
if len(results) > 0:
|
||||
result = results[0]
|
||||
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", ""):
|
||||
print('...returned status: {}'.format(status))
|
||||
if errormsg is not None:
|
||||
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:
|
||||
assert(in_errormsg is not None)
|
||||
assert_equal(in_errormsg in errormsg, True)
|
||||
return txid
|
||||
assert_true(in_errormsg is not None, "No error retured. Expected: {}".format(errormsg))
|
||||
assert_true(in_errormsg in errormsg, "Error returned: {}. Error expected: {}".format(errormsg, in_errormsg))
|
||||
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.util import assert_equal, assert_greater_than, \
|
||||
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
|
||||
|
||||
class WalletTest (BitcoinTestFramework):
|
||||
@@ -219,7 +219,7 @@ class WalletTest (BitcoinTestFramework):
|
||||
for uTx in unspentTxs:
|
||||
if uTx['txid'] == zeroValueTxid:
|
||||
found = True
|
||||
assert_equal(uTx['amount'], Decimal('0.00000000'));
|
||||
assert_equal(uTx['amount'], Decimal('0.00000000'))
|
||||
assert(found)
|
||||
|
||||
#do some -walletbroadcast tests
|
||||
@@ -231,13 +231,13 @@ class WalletTest (BitcoinTestFramework):
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
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)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1) #mine a block, tx should not be in there
|
||||
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
|
||||
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
|
||||
@@ -245,11 +245,11 @@ class WalletTest (BitcoinTestFramework):
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
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
|
||||
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
|
||||
stop_nodes(self.nodes)
|
||||
@@ -264,18 +264,18 @@ class WalletTest (BitcoinTestFramework):
|
||||
sync_blocks(self.nodes)
|
||||
|
||||
#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
|
||||
mytaddr = self.nodes[2].getnewaddress();
|
||||
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0);
|
||||
mytaddr = self.nodes[2].getnewaddress()
|
||||
mytxid = self.nodes[0].sendtoaddress(mytaddr, 10.0)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
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)
|
||||
myvjoinsplits = mytxdetails["vjoinsplit"]
|
||||
@@ -348,23 +348,9 @@ class WalletTest (BitcoinTestFramework):
|
||||
# send node 2 taddr to zaddr
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount":7})
|
||||
myopid = self.nodes[2].z_sendmany(mytaddr, recipients)
|
||||
|
||||
opids = []
|
||||
opids.append(myopid)
|
||||
mytxid = wait_and_assert_operationid_status(self.nodes[2], self.nodes[2].z_sendmany(mytaddr, recipients))
|
||||
|
||||
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.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
@@ -378,7 +364,7 @@ class WalletTest (BitcoinTestFramework):
|
||||
assert_equal(self.nodes[2].getbalance("*"), node2utxobalance)
|
||||
|
||||
# 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
|
||||
resp = self.nodes[2].z_gettotalbalance()
|
||||
@@ -399,7 +385,6 @@ class WalletTest (BitcoinTestFramework):
|
||||
assert("randomSeed" in myjoinsplit.keys())
|
||||
assert("ciphertexts" in myjoinsplit.keys())
|
||||
|
||||
|
||||
# send from private note to node 0 and node 2
|
||||
node0balance = self.nodes[0].getbalance() # 25.99794745
|
||||
node2balance = self.nodes[2].getbalance() # 16.99790000
|
||||
@@ -407,20 +392,9 @@ class WalletTest (BitcoinTestFramework):
|
||||
recipients = []
|
||||
recipients.append({"address":self.nodes[0].getnewaddress(), "amount":1})
|
||||
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.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
@@ -453,7 +427,7 @@ class WalletTest (BitcoinTestFramework):
|
||||
except JSONRPCException,e:
|
||||
errorString = e.error['message']
|
||||
|
||||
assert_equal("Invalid amount" in errorString, True);
|
||||
assert_equal("Invalid amount" in errorString, True)
|
||||
|
||||
errorString = ""
|
||||
try:
|
||||
@@ -461,7 +435,7 @@ class WalletTest (BitcoinTestFramework):
|
||||
except JSONRPCException,e:
|
||||
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()
|
||||
recipients = [ {"address": myzaddr, "amount": Decimal('0.0') } ]
|
||||
|
||||
82
qa/rpc-tests/wallet_import_export.py
Executable file
82
qa/rpc-tests/wallet_import_export.py
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, start_nodes
|
||||
|
||||
class WalletImportExportTest (BitcoinTestFramework):
|
||||
def setup_network(self, split=False):
|
||||
num_nodes = 3
|
||||
extra_args = [["-exportdir={}/export{}".format(self.options.tmpdir, i)] for i in range(num_nodes)]
|
||||
self.nodes = start_nodes(num_nodes, self.options.tmpdir, extra_args)
|
||||
|
||||
def run_test(self):
|
||||
sapling_address2 = self.nodes[2].z_getnewaddress('sapling')
|
||||
privkey2 = self.nodes[2].z_exportkey(sapling_address2)
|
||||
self.nodes[0].z_importkey(privkey2)
|
||||
|
||||
sprout_address0 = self.nodes[0].z_getnewaddress('sprout')
|
||||
sapling_address0 = self.nodes[0].z_getnewaddress('sapling')
|
||||
|
||||
# node 0 should have the keys
|
||||
dump_path0 = self.nodes[0].z_exportwallet('walletdump')
|
||||
(t_keys0, sprout_keys0, sapling_keys0) = parse_wallet_file(dump_path0)
|
||||
|
||||
sapling_line_lengths = [len(sapling_key0.split(' #')[0].split()) for sapling_key0 in sapling_keys0.splitlines()]
|
||||
assert_equal(2, len(sapling_line_lengths), "Should have 2 sapling keys")
|
||||
assert_true(2 in sapling_line_lengths, "Should have a key with 2 parameters")
|
||||
assert_true(4 in sapling_line_lengths, "Should have a key with 4 parameters")
|
||||
|
||||
assert_true(sprout_address0 in sprout_keys0)
|
||||
assert_true(sapling_address0 in sapling_keys0)
|
||||
assert_true(sapling_address2 in sapling_keys0)
|
||||
|
||||
# node 1 should not have the keys
|
||||
dump_path1 = self.nodes[1].z_exportwallet('walletdumpbefore')
|
||||
(t_keys1, sprout_keys1, sapling_keys1) = parse_wallet_file(dump_path1)
|
||||
|
||||
assert_true(sprout_address0 not in sprout_keys1)
|
||||
assert_true(sapling_address0 not in sapling_keys1)
|
||||
|
||||
# import wallet to node 1
|
||||
self.nodes[1].z_importwallet(dump_path0)
|
||||
|
||||
# node 1 should now have the keys
|
||||
dump_path1 = self.nodes[1].z_exportwallet('walletdumpafter')
|
||||
(t_keys1, sprout_keys1, sapling_keys1) = parse_wallet_file(dump_path1)
|
||||
|
||||
assert_true(sprout_address0 in sprout_keys1)
|
||||
assert_true(sapling_address0 in sapling_keys1)
|
||||
assert_true(sapling_address2 in sapling_keys1)
|
||||
|
||||
# make sure we have perserved the metadata
|
||||
for sapling_key0 in sapling_keys0.splitlines():
|
||||
assert_true(sapling_key0 in sapling_keys1)
|
||||
|
||||
# Helper functions
|
||||
def parse_wallet_file(dump_path):
|
||||
file_lines = open(dump_path, "r").readlines()
|
||||
# We expect information about the HDSeed and fingerpring in the header
|
||||
assert_true("HDSeed" in file_lines[4], "Expected HDSeed")
|
||||
assert_true("fingerprint" in file_lines[4], "Expected fingerprint")
|
||||
(t_keys, i) = parse_wallet_file_lines(file_lines, 0)
|
||||
(sprout_keys, i) = parse_wallet_file_lines(file_lines, i)
|
||||
(sapling_keys, i) = parse_wallet_file_lines(file_lines, i)
|
||||
|
||||
return (t_keys, sprout_keys, sapling_keys)
|
||||
|
||||
def parse_wallet_file_lines(file_lines, i):
|
||||
keys = []
|
||||
# skip blank lines and comments
|
||||
while i < len(file_lines) and (file_lines[i] == '\n' or file_lines[i].startswith("#")):
|
||||
i += 1
|
||||
# add keys until we hit another blank line or comment
|
||||
while i < len(file_lines) and not (file_lines[i] == '\n' or file_lines[i].startswith("#")):
|
||||
keys.append(file_lines[i])
|
||||
i += 1
|
||||
return ("".join(keys), i)
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletImportExportTest().main()
|
||||
@@ -5,10 +5,9 @@
|
||||
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, start_node, \
|
||||
start_nodes, connect_nodes_bi, bitcoind_processes
|
||||
from test_framework.util import assert_equal, assert_true, bitcoind_processes, \
|
||||
connect_nodes_bi, start_node, start_nodes, wait_and_assert_operationid_status
|
||||
|
||||
import time
|
||||
from decimal import Decimal
|
||||
|
||||
class WalletNullifiersTest (BitcoinTestFramework):
|
||||
@@ -22,25 +21,11 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||
myzaddr0 = self.nodes[0].z_getnewaddress()
|
||||
|
||||
# send node 0 taddr to zaddr to get out of coinbase
|
||||
mytaddr = self.nodes[0].getnewaddress();
|
||||
mytaddr = self.nodes[0].getnewaddress()
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr0, "amount":Decimal('10.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||
myopid = 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
|
||||
|
||||
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)
|
||||
@@ -66,22 +51,8 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||
# send node 0 zaddr to note 2 zaddr
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount":7.0})
|
||||
myopid = 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
|
||||
|
||||
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)
|
||||
@@ -98,22 +69,8 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||
# send node 2 zaddr to note 3 zaddr
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr3, "amount":2.0})
|
||||
myopid = self.nodes[2].z_sendmany(myzaddr, recipients)
|
||||
|
||||
opids = []
|
||||
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
|
||||
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)
|
||||
@@ -136,26 +93,11 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||
# This requires that node 1 be unlocked, which triggers caching of
|
||||
# uncached nullifiers.
|
||||
self.nodes[1].walletpassphrase("test", 600)
|
||||
mytaddr1 = self.nodes[1].getnewaddress();
|
||||
mytaddr1 = self.nodes[1].getnewaddress()
|
||||
recipients = []
|
||||
recipients.append({"address":mytaddr1, "amount":1.0})
|
||||
myopid = 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
|
||||
|
||||
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)
|
||||
@@ -206,7 +148,6 @@ class WalletNullifiersTest (BitcoinTestFramework):
|
||||
if key != 'change':
|
||||
assert_equal(received2[key], received3[key])
|
||||
|
||||
|
||||
# Node 3's balances should be unchanged without explicitly requesting
|
||||
# to include watch-only balances
|
||||
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
|
||||
|
||||
import sys
|
||||
import time
|
||||
import timeit
|
||||
from decimal import Decimal
|
||||
|
||||
@@ -82,50 +81,25 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
|
||||
self.nodes[3].importaddress(mytaddr)
|
||||
recipients= [{"address":myzaddr, "amount": Decimal('1')}]
|
||||
myopid = self.nodes[3].z_sendmany(mytaddr, recipients)
|
||||
errorString=""
|
||||
status = None
|
||||
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)
|
||||
|
||||
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.
|
||||
recipients = []
|
||||
recipients.append({"address":myzaddr, "amount":Decimal('1.23456789')})
|
||||
errorString = ""
|
||||
|
||||
myopid = self.nodes[0].z_sendmany(mytaddr, recipients)
|
||||
opids = []
|
||||
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"]
|
||||
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(results[0]["method"], "z_sendmany")
|
||||
params =results[0]["params"]
|
||||
assert_equal(params["fee"], Decimal('0.0001')) # default
|
||||
assert_equal(params["minconf"], Decimal('1')) # default
|
||||
assert_equal(params["fromaddress"], mytaddr)
|
||||
assert_equal(params["amounts"][0]["address"], myzaddr)
|
||||
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)
|
||||
# Test that the returned status object contains a params field with the operation's input parameters
|
||||
assert_equal(error_result["method"], "z_sendmany")
|
||||
params = error_result["params"]
|
||||
assert_equal(params["fee"], Decimal('0.0001')) # default
|
||||
assert_equal(params["minconf"], Decimal('1')) # default
|
||||
assert_equal(params["fromaddress"], mytaddr)
|
||||
assert_equal(params["amounts"][0]["address"], myzaddr)
|
||||
assert_equal(params["amounts"][0]["amount"], Decimal('1.23456789'))
|
||||
|
||||
# Add viewing key for myzaddr to Node 3
|
||||
myviewingkey = self.nodes[0].z_exportviewingkey(myzaddr)
|
||||
|
||||
@@ -89,7 +89,7 @@ class WalletSaplingTest(BitcoinTestFramework):
|
||||
recipients.append({"address": saplingAddr0, "amount": Decimal('5')})
|
||||
recipients.append({"address": taddr1, "amount": Decimal('5')})
|
||||
myopid = self.nodes[1].z_sendmany(saplingAddr1, recipients, 1, 0)
|
||||
wait_and_assert_operationid_status(self.nodes[1], myopid)
|
||||
mytxid = wait_and_assert_operationid_status(self.nodes[1], myopid)
|
||||
|
||||
self.sync_all()
|
||||
self.nodes[2].generate(1)
|
||||
@@ -100,5 +100,26 @@ class WalletSaplingTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[1].z_getbalance(saplingAddr1), Decimal('5'))
|
||||
assert_equal(self.nodes[1].z_getbalance(taddr1), Decimal('5'))
|
||||
|
||||
# Verify existence of Sapling related JSON fields
|
||||
resp = self.nodes[0].getrawtransaction(mytxid, 1)
|
||||
assert_equal(resp['valueBalance'], Decimal('5'))
|
||||
assert(len(resp['vShieldedSpend']) == 1)
|
||||
assert(len(resp['vShieldedOutput']) == 2)
|
||||
assert('bindingSig' in resp)
|
||||
shieldedSpend = resp['vShieldedSpend'][0]
|
||||
assert('cv' in shieldedSpend)
|
||||
assert('anchor' in shieldedSpend)
|
||||
assert('nullifier' in shieldedSpend)
|
||||
assert('rk' in shieldedSpend)
|
||||
assert('proof' in shieldedSpend)
|
||||
assert('spendAuthSig' in shieldedSpend)
|
||||
shieldedOutput = resp['vShieldedOutput'][0]
|
||||
assert('cv' in shieldedOutput)
|
||||
assert('cmu' in shieldedOutput)
|
||||
assert('ephemeralKey' in shieldedOutput)
|
||||
assert('encCiphertext' in shieldedOutput)
|
||||
assert('outCiphertext' in shieldedOutput)
|
||||
assert('proof' in shieldedOutput)
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletSaplingTest().main()
|
||||
|
||||
Reference in New Issue
Block a user