test: Set default in add_wallet_options if only one type can be chosen

This commit is contained in:
MacroFake 2022-11-15 10:05:02 +01:00
parent 555519d082
commit fa10f193b5
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -449,11 +449,15 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def add_wallet_options(self, parser, *, descriptors=True, legacy=True):
group = parser.add_mutually_exclusive_group()
kwargs = {}
if descriptors + legacy == 1:
# If only one type can be chosen, set it as default
kwargs["default"] = descriptors
if descriptors:
group.add_argument("--descriptors", action='store_const', const=True,
group.add_argument("--descriptors", action='store_const', const=True, **kwargs,
help="Run test using a descriptor wallet", dest='descriptors')
if legacy:
group.add_argument("--legacy-wallet", action='store_const', const=False,
group.add_argument("--legacy-wallet", action='store_const', const=False, **kwargs,
help="Run test using legacy wallets", dest='descriptors')
def add_nodes(self, num_nodes: int, extra_args=None, *, rpchost=None, binary=None, binary_cli=None, versions=None):