From 4cc90d05c30fe4201965ddb5971d9d6db1aa928b Mon Sep 17 00:00:00 2001 From: random-zebra Date: Sat, 14 Mar 2020 16:32:21 +0100 Subject: [PATCH] [Tests] Add -legacywallet flag to run functional tests on pre-HD wallets --- test/functional/test_framework/test_framework.py | 7 +++++++ test/functional/test_runner.py | 3 +++ test/functional/wallet_hd.py | 6 +++++- test/functional/wallet_upgrade.py | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 2545de85ef1bb..3362c1cec9e71 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -122,6 +122,8 @@ def main(self): help="Write tested RPC commands into this directory") parser.add_option("--configfile", dest="configfile", help="Location of the test framework config file") + parser.add_option('--legacywallet', dest="legacywallet", default=False, action="store_true", + help='create pre-HD wallets only') parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true", help="Attach a python debugger if test fails") parser.add_option("--usecli", dest="usecli", default=False, action="store_true", @@ -248,6 +250,11 @@ def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, bin if extra_args is None: extra_args = [[]] * num_nodes + # Check wallet version + if self.options.legacywallet: + for arg in extra_args: + arg.append('-legacywallet') + self.log.info("Running test with legacy (pre-HD) wallet") if binary is None: binary = [None] * num_nodes assert_equal(len(extra_args), num_nodes) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 26b18a0e65731..ad386eac89d35 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -178,6 +178,7 @@ def main(): parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.') parser.add_argument('--keepcache', '-k', action='store_true', help='the default behavior is to flush the cache directory on startup. --keepcache retains the cache from the previous testrun.') parser.add_argument('--quiet', '-q', action='store_true', help='only print dots, results summary and failure logs') + parser.add_argument('--legacywallet', '-w', action='store_true', help='create pre-HD wallets only') parser.add_argument('--tmpdirprefix', '-t', default=tempfile.gettempdir(), help="Root directory for datadirs") args, unknown_args = parser.parse_known_args() @@ -191,6 +192,8 @@ def main(): config.read_file(open(configfile)) passon_args.append("--configfile=%s" % configfile) + if args.legacywallet: + passon_args.append("--legacywallet") # Set up logging logging_level = logging.INFO if args.quiet else logging.DEBUG diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index c43e7122d950d..0a1a6fd7a2cff 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -26,7 +26,11 @@ def skip_test_if_missing_module(self): self.skip_if_no_wallet() def run_test(self): - # Make sure we use hd, keep masterkeyid + # Make sure we use hd + if '-legacywallet' in self.nodes[0].extra_args: + self.log.info("Exiting HD test for non-HD wallets") + return + # keep masterkeyid masterkeyid = self.nodes[1].getwalletinfo()['hdseedid'] assert_equal(len(masterkeyid), 40) diff --git a/test/functional/wallet_upgrade.py b/test/functional/wallet_upgrade.py index 0e6baf3dc081a..56da7680f5d24 100755 --- a/test/functional/wallet_upgrade.py +++ b/test/functional/wallet_upgrade.py @@ -101,6 +101,10 @@ def check_keys(self, addrs): def run_test(self): + # Make sure we use hd + if '-legacywallet' in self.nodes[0].extra_args: + self.log.info("Exiting HD upgrade test for non-HD wallets") + return self.log.info("Checking correct version") assert_equal(self.nodes[0].getwalletinfo()['walletversion'], 61000)