2018-12-18 12:00:46 -08:00
|
|
|
#!/usr/bin/env python
|
2018-07-09 15:46:36 -07:00
|
|
|
# Copyright (c) 2018 The Zcash developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2019-07-18 07:16:09 -07:00
|
|
|
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
2018-07-09 15:46:36 -07:00
|
|
|
|
2018-12-18 12:00:46 -08:00
|
|
|
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
|
|
|
|
2018-07-09 15:46:36 -07:00
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
from test_framework.util import assert_equal, start_nodes
|
|
|
|
|
|
|
|
# Test wallet address behaviour across network upgradesa\
|
|
|
|
class WalletAddressesTest(BitcoinTestFramework):
|
|
|
|
|
|
|
|
def setup_nodes(self):
|
|
|
|
return start_nodes(4, self.options.tmpdir, [[
|
|
|
|
'-nuparams=5ba81b19:202', # Overwinter
|
|
|
|
'-nuparams=76b809bb:204', # Sapling
|
|
|
|
]] * 4)
|
|
|
|
|
|
|
|
def run_test(self):
|
|
|
|
def addr_checks(default_type):
|
2018-08-01 01:44:31 -07:00
|
|
|
# Check default type, as well as explicit types
|
|
|
|
types_and_addresses = [
|
|
|
|
(default_type, self.nodes[0].z_getnewaddress()),
|
|
|
|
('sprout', self.nodes[0].z_getnewaddress('sprout')),
|
|
|
|
('sapling', self.nodes[0].z_getnewaddress('sapling')),
|
|
|
|
]
|
|
|
|
|
|
|
|
all_addresses = self.nodes[0].z_listaddresses()
|
|
|
|
|
|
|
|
for addr_type, addr in types_and_addresses:
|
|
|
|
res = self.nodes[0].z_validateaddress(addr)
|
|
|
|
assert(res['isvalid'])
|
|
|
|
assert(res['ismine'])
|
|
|
|
assert_equal(res['type'], addr_type)
|
|
|
|
assert(addr in all_addresses)
|
2018-07-09 15:46:36 -07:00
|
|
|
|
|
|
|
# Sanity-check the test harness
|
|
|
|
assert_equal(self.nodes[0].getblockcount(), 200)
|
|
|
|
|
|
|
|
# Current height = 200 -> Sprout
|
2018-11-16 14:22:23 -08:00
|
|
|
# Default address type is Sapling
|
2018-07-09 15:46:36 -07:00
|
|
|
print "Testing height 200 (Sprout)"
|
2018-11-16 14:22:23 -08:00
|
|
|
addr_checks('sapling')
|
2018-07-09 15:46:36 -07:00
|
|
|
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all()
|
|
|
|
|
|
|
|
# Current height = 201 -> Sprout
|
2018-11-16 14:22:23 -08:00
|
|
|
# Default address type is Sapling
|
2018-07-09 15:46:36 -07:00
|
|
|
print "Testing height 201 (Sprout)"
|
2018-11-16 14:22:23 -08:00
|
|
|
addr_checks('sapling')
|
2018-07-09 15:46:36 -07:00
|
|
|
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all()
|
|
|
|
|
|
|
|
# Current height = 202 -> Overwinter
|
2018-11-16 14:22:23 -08:00
|
|
|
# Default address type is Sapling
|
2018-07-09 15:46:36 -07:00
|
|
|
print "Testing height 202 (Overwinter)"
|
2018-11-16 14:22:23 -08:00
|
|
|
addr_checks('sapling')
|
2018-07-09 15:46:36 -07:00
|
|
|
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all()
|
|
|
|
|
|
|
|
# Current height = 203 -> Overwinter
|
2018-11-16 14:22:23 -08:00
|
|
|
# Default address type is Sapling
|
2018-07-09 15:46:36 -07:00
|
|
|
print "Testing height 203 (Overwinter)"
|
2018-11-16 14:22:23 -08:00
|
|
|
addr_checks('sapling')
|
2018-07-09 15:46:36 -07:00
|
|
|
|
|
|
|
self.nodes[0].generate(1)
|
|
|
|
self.sync_all()
|
|
|
|
|
|
|
|
# Current height = 204 -> Sapling
|
2018-11-16 14:22:23 -08:00
|
|
|
# Default address type is Sapling
|
2018-07-09 15:46:36 -07:00
|
|
|
print "Testing height 204 (Sapling)"
|
2018-11-16 14:22:23 -08:00
|
|
|
addr_checks('sapling')
|
2018-07-09 15:46:36 -07:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
WalletAddressesTest().main()
|