mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
953b6706f4
c7b7e0a69265946aecc885be911c7650911ba2e3 tests: Make only desc wallets for wallet_multwallet.py --descriptors (Andrew Chow) d4b67ad214ada7645c4ce2d5ec336fe5c3f7f7ca Avoid creating legacy wallets in wallet_importdescriptors.py (Andrew Chow) 6c9c12bf87f95066acc28ea2270a00196eb77703 Update feature_backwards_compatibility for descriptor wallets (Andrew Chow) 9a4c631e1c00eb1661c000978b133d7aa0226290 Update wallet_labels.py to not require descriptors=False (Andrew Chow) 242aed7cc1d003e8fed574bbebd19c7e54e23402 tests: Add a --legacy-wallet that is mutually exclusive with --descriptors (Andrew Chow) 388053e1722632c2e485c56a444bc75cf0152188 Disable some tests for tool_wallet when descriptors (Andrew Chow) 47d3243160fdec7e464cfb8f869be7f5d4ee25fe Make raw multisig tests legacy wallet only in rpc_rawtransaction.py (Andrew Chow) 59d3da5bce4ebd9c2291d8f201a53ee087938b21 Do addmultisigaddress tests in legacy wallet mode in wallet_address_types.py (Andrew Chow) 25bc5dccbfd52691adca6edd418dd54290300c28 Use importdescriptors when in descriptor wallet mode in wallet_createwallet.py (Andrew Chow) 0bd1860300b13b12a25d330ba3a93ff2d13aa379 Avoid dumpprivkey and watchonly behavior in rpc_signrawtransaction.py (Andrew Chow) 08067aebfd7e838e6ce6b030c31a69422260fc6f Add script equivalent of functions in address.py (Andrew Chow) 86968882a8a26312a7af29c572313c4aff488c11 Add descriptor wallet output to tool_wallet.py (Andrew Chow) 3457679870e8eff2a7d14fe59a479692738c48b6 Use separate watchonly wallet for multisig in feature_nulldummy.py (Andrew Chow) a42652ec10c733a5bf37e418e45d4841f54331b4 Move import and watchonly tests to be legacy wallet only in wallet_balance.py (Andrew Chow) 4b871909d6e4a51888e062d322bf53263deda15e Use importdescriptors for descriptor wallets in wallet_bumpfee.py (Andrew Chow) c2711e4230d9a423ead24f6609691fb338b1d26b Avoid dumpprivkey in wallet_listsinceblock.py (Andrew Chow) 553dbf9af4dea96e6a3e79bba9607003342029bd Make import tests in wallet_listtransactions.py legacy wallet only (Andrew Chow) dc81418fd01021070f3f66bab5fee1484456691a Use a separate watchonly wallet in rpc_fundrawtransaction.py (Andrew Chow) a357111047411f18c156cd34a002a38430f2901c Update wallet_importprunedfunds to avoid dumpprivkey (Andrew Chow) Pull request description: I went through all the tests and checked whether they passed with descriptor wallets. This partially informed some changes in #16528. Some tests needed changes to work with descriptor wallets. These were primarily due to import and watchonly behavior. There are some tests and test cases that only test legacy wallet behavior so those tests won't be run with descriptor wallets. This PR updates more tests to have to the `--descriptors` switch in `test_runner.py`. Additionally a mutually exclusive `--legacy-wallet` option has been added to force legacy wallets. This does nothing currently but will be useful in the future when descriptor wallets are the default. For the tests that rely on legacy wallet behavior, this option is being set so that we don't forget in the future. Those tests are `feature_segwit.py`, `wallet_watchonly.py`, `wallet_implicitsegwit.py`, `wallet_import_with_label.py`, and `wallet_import_with_label.py`. If you invert the `--descriptors`/`--legacy-wallet` default so that descriptor wallets are the default, all tests (besides the legacy wallet specific ones) will pass. ACKs for top commit: MarcoFalke: review ACK c7b7e0a69265946aecc885be911c7650911ba2e3 🎿 laanwj: ACK c7b7e0a69265946aecc885be911c7650911ba2e3 Tree-SHA512: 2f4e87815005d1d0a2543ea7947f7cd7593d8cf5312228ef85f8e096f19739b225769961943049cb44f6f07a35b8de988e2246ab9aca5bb5a0b2e62694d5637d
401 lines
16 KiB
Python
Executable File
401 lines
16 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2018-2019 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Backwards compatibility functional test
|
|
|
|
Test various backwards compatibility scenarios. Requires previous releases binaries,
|
|
see test/README.md.
|
|
|
|
v0.15.0.0 is not required by this test, but it is used in wallet_upgradewallet.py.
|
|
Due to a hardfork in regtest, it can't be used to sync nodes.
|
|
|
|
Due to RPC changes introduced in various versions the below tests
|
|
won't work for older versions without some patches or workarounds.
|
|
|
|
Use only the latest patch version of each release, unless a test specifically
|
|
needs an older patch version.
|
|
"""
|
|
|
|
import os
|
|
import shutil
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
from test_framework.util import (
|
|
assert_equal,
|
|
assert_raises_rpc_error,
|
|
)
|
|
|
|
|
|
class BackwardsCompatibilityTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 7
|
|
# Add new version after each release:
|
|
self.extra_args = [
|
|
[], # Pre-release: use to mine blocks
|
|
["-nowallet"], # Pre-release: use to receive coins, swap wallets, etc
|
|
["-nowallet"], # v20.0.1
|
|
["-nowallet"], # v19.3.0
|
|
["-nowallet"], # v18.2.2
|
|
["-nowallet"], # v0.17.0.3
|
|
["-nowallet"], # v0.16.1.1
|
|
]
|
|
self.wallet_names = [self.default_wallet_name]
|
|
|
|
def skip_test_if_missing_module(self):
|
|
self.skip_if_no_wallet()
|
|
self.skip_if_no_previous_releases()
|
|
|
|
def setup_nodes(self):
|
|
self.add_nodes(self.num_nodes, extra_args=self.extra_args, versions=[
|
|
None,
|
|
None,
|
|
19030000,
|
|
19030000,
|
|
18020200,
|
|
170003,
|
|
160101,
|
|
])
|
|
|
|
self.start_nodes()
|
|
self.import_deterministic_coinbase_privkeys()
|
|
|
|
def run_test(self):
|
|
self.nodes[0].generatetoaddress(101, self.nodes[0].getnewaddress())
|
|
|
|
self.sync_blocks()
|
|
|
|
# Sanity check the test framework:
|
|
res = self.nodes[self.num_nodes - 1].getblockchaininfo()
|
|
assert_equal(res['blocks'], 101)
|
|
|
|
node_master = self.nodes[self.num_nodes - 6]
|
|
node_v20 = self.nodes[self.num_nodes - 5]
|
|
node_v19 = self.nodes[self.num_nodes - 4]
|
|
node_v18 = self.nodes[self.num_nodes - 3]
|
|
node_v17 = self.nodes[self.num_nodes - 2]
|
|
node_v16 = self.nodes[self.num_nodes - 1]
|
|
|
|
self.log.info("Test wallet backwards compatibility...")
|
|
# Create a number of wallets and open them in older versions:
|
|
|
|
# w1: regular wallet, created on master: update this test when default
|
|
# wallets can no longer be opened by older versions.
|
|
node_master.createwallet(wallet_name="w1")
|
|
wallet = node_master.get_wallet_rpc("w1")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
# Create a confirmed transaction, receiving coins
|
|
address = wallet.getnewaddress()
|
|
self.nodes[0].sendtoaddress(address, 1)
|
|
self.sync_mempools()
|
|
self.nodes[0].generate(1)
|
|
self.sync_blocks()
|
|
|
|
# w1_v19: regular wallet, created with v0.19
|
|
node_v19.rpc.createwallet(wallet_name="w1_v19")
|
|
wallet = node_v19.get_wallet_rpc("w1_v19")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
# Use addmultisigaddress (see #18075)
|
|
address_18075 = wallet.addmultisigaddress(1, ["0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52", "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073"], "")["address"]
|
|
assert wallet.getaddressinfo(address_18075)["solvable"]
|
|
|
|
# w1_v18: regular wallet, created with v0.18
|
|
node_v18.rpc.createwallet(wallet_name="w1_v18")
|
|
wallet = node_v18.get_wallet_rpc("w1_v18")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
|
|
# w2: wallet with private keys disabled, created on master: update this
|
|
# test when default wallets private keys disabled can no longer be
|
|
# opened by older versions.
|
|
node_master.rpc.createwallet(wallet_name="w2", disable_private_keys=True)
|
|
wallet = node_master.get_wallet_rpc("w2")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled'] == False
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# w1_v20: regular wallet, created with v20.0
|
|
node_v20.rpc.createwallet(wallet_name="w1_v20")
|
|
wallet = node_v20.get_wallet_rpc("w1_v20")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
|
|
# w2_v19: wallet with private keys disabled, created with v0.19
|
|
node_v19.rpc.createwallet(wallet_name="w2_v19", disable_private_keys=True)
|
|
wallet = node_v19.get_wallet_rpc("w2_v19")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled'] == False
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# w2_v18: wallet with private keys disabled, created with v0.18
|
|
node_v18.rpc.createwallet(wallet_name="w2_v18", disable_private_keys=True)
|
|
wallet = node_v18.get_wallet_rpc("w2_v18")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled'] == False
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# w3: blank wallet, created on master: update this
|
|
# test when default blank wallets can no longer be opened by older versions.
|
|
node_master.rpc.createwallet(wallet_name="w3", blank=True)
|
|
wallet = node_master.get_wallet_rpc("w3")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# w3_v19: blank wallet, created with v0.19
|
|
node_v19.rpc.createwallet(wallet_name="w3_v19", blank=True)
|
|
wallet = node_v19.get_wallet_rpc("w3_v19")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# w3_v18: blank wallet, created with v0.18
|
|
node_v18.rpc.createwallet(wallet_name="w3_v18", blank=True)
|
|
wallet = node_v18.get_wallet_rpc("w3_v18")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# Copy the wallets to older nodes:
|
|
node_master_wallets_dir = os.path.join(node_master.datadir, "regtest/wallets")
|
|
node_v20_wallets_dir = os.path.join(node_v20.datadir, "regtest/wallets")
|
|
node_v19_wallets_dir = os.path.join(node_v19.datadir, "regtest/wallets")
|
|
node_v18_wallets_dir = os.path.join(node_v18.datadir, "regtest/wallets")
|
|
node_v17_wallets_dir = os.path.join(node_v17.datadir, "regtest/wallets")
|
|
node_v16_wallets_dir = os.path.join(node_v16.datadir, "regtest")
|
|
node_master.unloadwallet("w1")
|
|
node_master.unloadwallet("w2")
|
|
node_v19.unloadwallet("w1_v19")
|
|
node_v19.unloadwallet("w2_v19")
|
|
node_v18.unloadwallet("w1_v18")
|
|
node_v18.unloadwallet("w2_v18")
|
|
|
|
# Copy wallets to v0.16
|
|
for wallet in os.listdir(node_master_wallets_dir):
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, wallet),
|
|
os.path.join(node_v16_wallets_dir, wallet)
|
|
)
|
|
|
|
# Copy wallets to v0.17
|
|
for wallet in os.listdir(node_master_wallets_dir):
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, wallet),
|
|
os.path.join(node_v17_wallets_dir, wallet)
|
|
)
|
|
for wallet in os.listdir(node_v18_wallets_dir):
|
|
shutil.copytree(
|
|
os.path.join(node_v18_wallets_dir, wallet),
|
|
os.path.join(node_v17_wallets_dir, wallet)
|
|
)
|
|
|
|
# Copy wallets to v0.18
|
|
for wallet in os.listdir(node_master_wallets_dir):
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, wallet),
|
|
os.path.join(node_v18_wallets_dir, wallet)
|
|
)
|
|
|
|
# Copy wallets to v0.19
|
|
for wallet in os.listdir(node_master_wallets_dir):
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, wallet),
|
|
os.path.join(node_v19_wallets_dir, wallet)
|
|
)
|
|
|
|
# Copy wallets to v0.20
|
|
for wallet in os.listdir(node_master_wallets_dir):
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, wallet),
|
|
os.path.join(node_v20_wallets_dir, wallet)
|
|
)
|
|
|
|
if not self.options.descriptors:
|
|
# Descriptor wallets break compatibility, only run this test for legacy wallet
|
|
# Open the wallets in v0.20
|
|
node_v20.loadwallet("w1")
|
|
wallet = node_v20.get_wallet_rpc("w1")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
txs = wallet.listtransactions()
|
|
assert_equal(len(txs), 1)
|
|
|
|
node_v20.loadwallet("w2")
|
|
wallet = node_v20.get_wallet_rpc("w2")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled'] == False
|
|
assert info['keypoolsize'] == 0
|
|
|
|
node_v20.loadwallet("w3")
|
|
wallet = node_v20.get_wallet_rpc("w3")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# Open the wallets in v0.19
|
|
node_v19.loadwallet("w1")
|
|
wallet = node_v19.get_wallet_rpc("w1")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
txs = wallet.listtransactions()
|
|
assert_equal(len(txs), 1)
|
|
|
|
node_v19.loadwallet("w2")
|
|
wallet = node_v19.get_wallet_rpc("w2")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled'] == False
|
|
assert info['keypoolsize'] == 0
|
|
|
|
node_v19.loadwallet("w3")
|
|
wallet = node_v19.get_wallet_rpc("w3")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] == 0
|
|
|
|
# Open the wallets in v0.18
|
|
node_v18.loadwallet("w1")
|
|
wallet = node_v18.get_wallet_rpc("w1")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
txs = wallet.listtransactions()
|
|
assert_equal(len(txs), 1)
|
|
|
|
node_v18.loadwallet("w2")
|
|
wallet = node_v18.get_wallet_rpc("w2")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled'] == False
|
|
assert info['keypoolsize'] == 0
|
|
|
|
node_v18.loadwallet("w3")
|
|
wallet = node_v18.get_wallet_rpc("w3")
|
|
info = wallet.getwalletinfo()
|
|
assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] == 0
|
|
|
|
node_v17.loadwallet("w1")
|
|
wallet = node_v17.get_wallet_rpc("w1")
|
|
info = wallet.getwalletinfo()
|
|
# doesn't have private_keys_enabled in v17
|
|
#assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
|
|
node_v17.loadwallet("w2")
|
|
wallet = node_v17.get_wallet_rpc("w2")
|
|
info = wallet.getwalletinfo()
|
|
# doesn't have private_keys_enabled in v17
|
|
# TODO enable back when HD wallets are created by default
|
|
# assert info['private_keys_enabled'] == False
|
|
# assert info['keypoolsize'] == 0
|
|
else:
|
|
# Descriptor wallets appear to be corrupted wallets to old software
|
|
assert_raises_rpc_error(-4, "Wallet requires newer version of Dash Core", node_v19.loadwallet, "w1")
|
|
node_v19.loadwallet("w2")
|
|
node_v19.loadwallet("w3")
|
|
assert_raises_rpc_error(-18, "Data is not in recognized format", node_v18.loadwallet, "w1")
|
|
node_v18.loadwallet("w2")
|
|
node_v18.loadwallet("w3")
|
|
|
|
# Open the wallets in v0.17
|
|
node_v17.loadwallet("w1_v18")
|
|
wallet = node_v17.get_wallet_rpc("w1_v18")
|
|
info = wallet.getwalletinfo()
|
|
# doesn't have private_keys_enabled in v17
|
|
# assert info['private_keys_enabled']
|
|
assert info['keypoolsize'] > 0
|
|
|
|
node_v17.loadwallet("w2_v18")
|
|
wallet = node_v17.get_wallet_rpc("w2_v18")
|
|
info = wallet.getwalletinfo()
|
|
# doesn't have private_keys_enabled in v17
|
|
# TODO enable back when HD wallets are created by default
|
|
#assert info['private_keys_enabled'] == False
|
|
#assert info['keypoolsize'] == 0
|
|
|
|
# RPC loadwallet failure causes bitcoind to exit, in addition to the RPC
|
|
# call failure, so the following test won't work:
|
|
# assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3_v18')
|
|
|
|
# Instead, we stop node and try to launch it with the wallet:
|
|
self.stop_node(5)
|
|
# it expected to fail with error 'DBErrors::TOO_NEW' but Dash Core can open v18 by version 17
|
|
# can be implemented in future if there's any incompatible versions
|
|
#node_v17.assert_start_raises_init_error(["-wallet=w3_v18"], "Error: Error loading w3_v18: Wallet requires newer version of Dash Core")
|
|
#node_v17.assert_start_raises_init_error(["-wallet=w3"], "Error: Error loading w3: Wallet requires newer version of Dash Core")
|
|
self.start_node(5)
|
|
|
|
# Open most recent wallet in v0.16 (no loadwallet RPC)
|
|
self.restart_node(6, extra_args=["-wallet=w2"])
|
|
wallet = node_v16.get_wallet_rpc("w2")
|
|
info = wallet.getwalletinfo()
|
|
assert info['keypoolsize'] == 1
|
|
|
|
self.log.info("Test wallet upgrade path...")
|
|
# u1: regular wallet, created with v0.17
|
|
node_v17.rpc.createwallet(wallet_name="u1_v17")
|
|
wallet = node_v17.get_wallet_rpc("u1_v17")
|
|
address = wallet.getnewaddress()
|
|
v17_info = wallet.getaddressinfo(address)
|
|
# TODO enable back when HD wallets are created by default
|
|
#v17_hdkeypath = v17_info["hdkeypath"]
|
|
v17_pubkey = v17_info["pubkey"]
|
|
|
|
# Copy the 0.17 wallet to the last Bitcoin Core version and open it:
|
|
node_v17.unloadwallet("u1_v17")
|
|
shutil.copytree(
|
|
os.path.join(node_v17_wallets_dir, "u1_v17"),
|
|
os.path.join(node_master_wallets_dir, "u1_v17")
|
|
)
|
|
node_master.loadwallet("u1_v17")
|
|
wallet = node_master.get_wallet_rpc("u1_v17")
|
|
info = wallet.getaddressinfo(address)
|
|
# TODO enable back when HD wallets are created by default
|
|
#descriptor = "pkh([" + info["hdmasterfingerprint"] + hdkeypath[1:] + "]" + v17_pubkey + ")"
|
|
#assert_equal(info["desc"], descsum_create(descriptor))
|
|
assert_equal(info["pubkey"], v17_pubkey)
|
|
|
|
# Now copy that same wallet back to 0.17 to make sure no automatic upgrade breaks it
|
|
node_master.unloadwallet("u1_v17")
|
|
shutil.rmtree(os.path.join(node_v17_wallets_dir, "u1_v17"))
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, "u1_v17"),
|
|
os.path.join(node_v17_wallets_dir, "u1_v17")
|
|
)
|
|
node_v17.loadwallet("u1_v17")
|
|
wallet = node_v17.get_wallet_rpc("u1_v17")
|
|
info = wallet.getaddressinfo(address)
|
|
assert_equal(info, v17_info)
|
|
|
|
# Copy the 0.19 wallet to the last Bitcoin Core version and open it:
|
|
shutil.copytree(
|
|
os.path.join(node_v19_wallets_dir, "w1_v19"),
|
|
os.path.join(node_master_wallets_dir, "w1_v19")
|
|
)
|
|
node_master.loadwallet("w1_v19")
|
|
wallet = node_master.get_wallet_rpc("w1_v19")
|
|
assert wallet.getaddressinfo(address_18075)["solvable"]
|
|
|
|
# Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
|
|
node_master.unloadwallet("w1_v19")
|
|
shutil.rmtree(os.path.join(node_v19_wallets_dir, "w1_v19"))
|
|
shutil.copytree(
|
|
os.path.join(node_master_wallets_dir, "w1_v19"),
|
|
os.path.join(node_v19_wallets_dir, "w1_v19")
|
|
)
|
|
node_v19.loadwallet("w1_v19")
|
|
wallet = node_v19.get_wallet_rpc("w1_v19")
|
|
assert wallet.getaddressinfo(address_18075)["solvable"]
|
|
|
|
if __name__ == '__main__':
|
|
BackwardsCompatibilityTest().main()
|