Latest Zcash bug fixes
This commit is contained in:
@@ -16,15 +16,16 @@ class WalletPersistenceTest (BitcoinTestFramework):
|
||||
|
||||
def setup_chain(self):
|
||||
print("Initializing test directory " + self.options.tmpdir)
|
||||
initialize_chain_clean(self.options.tmpdir, 2)
|
||||
initialize_chain_clean(self.options.tmpdir, 3)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(2, self.options.tmpdir,
|
||||
self.nodes = start_nodes(3, self.options.tmpdir,
|
||||
extra_args=[[
|
||||
'-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:201', # Sapling
|
||||
]] * 2)
|
||||
]] * 3)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
self.is_network_split=False
|
||||
self.sync_all()
|
||||
|
||||
@@ -97,5 +98,34 @@ class WalletPersistenceTest (BitcoinTestFramework):
|
||||
assert_equal(self.nodes[0].z_getbalance(sapling_addr), Decimal('5'))
|
||||
assert_equal(self.nodes[1].z_getbalance(dest_addr), Decimal('15'))
|
||||
|
||||
# Verify importing a spending key will update and persist the nullifiers and witnesses correctly
|
||||
sk0 = self.nodes[0].z_exportkey(sapling_addr)
|
||||
self.nodes[2].z_importkey(sk0, "yes")
|
||||
assert_equal(self.nodes[2].z_getbalance(sapling_addr), Decimal('5'))
|
||||
|
||||
# Restart the nodes
|
||||
stop_nodes(self.nodes)
|
||||
wait_bitcoinds()
|
||||
self.setup_network()
|
||||
|
||||
# Verify nullifiers persisted correctly by checking balance
|
||||
# Prior to PR #3590, there will be an error as spent notes are considered unspent:
|
||||
# Assertion failed: expected: <25.00000000> but was: <5>
|
||||
assert_equal(self.nodes[2].z_getbalance(sapling_addr), Decimal('5'))
|
||||
|
||||
# Verity witnesses persisted correctly by sending shielded funds
|
||||
recipients = []
|
||||
recipients.append({"address": dest_addr, "amount": Decimal('1')})
|
||||
myopid = self.nodes[2].z_sendmany(sapling_addr, recipients, 1, 0)
|
||||
wait_and_assert_operationid_status(self.nodes[2], myopid)
|
||||
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Verify balances
|
||||
assert_equal(self.nodes[2].z_getbalance(sapling_addr), Decimal('4'))
|
||||
assert_equal(self.nodes[1].z_getbalance(dest_addr), Decimal('16'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletPersistenceTest().main()
|
||||
@@ -4,6 +4,7 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
start_nodes,
|
||||
@@ -18,17 +19,57 @@ class WalletSaplingTest(BitcoinTestFramework):
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
'-nuparams=5ba81b19:201', # Overwinter
|
||||
'-nuparams=76b809bb:201', # Sapling
|
||||
'-nuparams=76b809bb:203', # Sapling
|
||||
'-experimentalfeatures', '-zmergetoaddress',
|
||||
]] * 4)
|
||||
|
||||
def run_test(self):
|
||||
# Sanity-check the test harness
|
||||
assert_equal(self.nodes[0].getblockcount(), 200)
|
||||
|
||||
# Activate Sapling
|
||||
# Activate Overwinter
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Verify RPCs disallow Sapling value transfer if Sapling is not active
|
||||
tmp_taddr = self.nodes[3].getnewaddress()
|
||||
tmp_zaddr = self.nodes[3].z_getnewaddress('sapling')
|
||||
try:
|
||||
recipients = []
|
||||
recipients.append({"address": tmp_zaddr, "amount": Decimal('20')})
|
||||
self.nodes[3].z_sendmany(tmp_taddr, recipients, 1, 0)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
try:
|
||||
recipients = []
|
||||
recipients.append({"address": tmp_taddr, "amount": Decimal('20')})
|
||||
self.nodes[3].z_sendmany(tmp_zaddr, recipients, 1, 0)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
try:
|
||||
self.nodes[3].z_shieldcoinbase(tmp_taddr, tmp_zaddr)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
|
||||
# Verify z_mergetoaddress RPC does not support Sapling yet
|
||||
try:
|
||||
self.nodes[3].z_mergetoaddress([tmp_taddr], tmp_zaddr)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling is not supported yet by z_mergetoadress", e.error['message'])
|
||||
try:
|
||||
self.nodes[3].z_mergetoaddress([tmp_zaddr], tmp_taddr)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling is not supported yet by z_mergetoadress", e.error['message'])
|
||||
|
||||
# Activate Sapling
|
||||
self.nodes[2].generate(2)
|
||||
self.sync_all()
|
||||
|
||||
taddr0 = self.nodes[0].getnewaddress()
|
||||
# Skip over the address containing node 1's coinbase
|
||||
self.nodes[1].getnewaddress()
|
||||
@@ -144,5 +185,18 @@ class WalletSaplingTest(BitcoinTestFramework):
|
||||
self.nodes[2].z_importkey(sk1, "yes")
|
||||
assert_equal(self.nodes[2].z_getbalance(saplingAddr1), Decimal('5'))
|
||||
|
||||
# Make sure we get a useful error when trying to send to both sprout and sapling
|
||||
node4_sproutaddr = self.nodes[3].z_getnewaddress('sprout')
|
||||
node4_saplingaddr = self.nodes[3].z_getnewaddress('sapling')
|
||||
try:
|
||||
self.nodes[1].z_sendmany(
|
||||
taddr1,
|
||||
[{'address': node4_sproutaddr, 'amount': 2.5}, {'address': node4_saplingaddr, 'amount': 2.4999}],
|
||||
1, 0.0001
|
||||
)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Cannot send to both Sprout and Sapling addresses using z_sendmany", e.error['message'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletSaplingTest().main()
|
||||
|
||||
Reference in New Issue
Block a user