Skip to content

Commit

Permalink
[Tests] Add -legacywallet flag to run functional tests on pre-HD wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Mar 15, 2020
1 parent d1b070c commit 4cc90d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test/functional/wallet_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions test/functional/wallet_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 4cc90d0

Please sign in to comment.