Skip to content

Commit 6f36242

Browse files
committed
tests: Set descriptors default based on compilation
Determines whether descriptors should be used based on whether the --descriptor or --legacy-wallet option is set, and the compiled support. If no option is set and both BDB and SQLite are available, it defaults to legacy. This is used to switch descriptor agnostic tests between descriptors and legacy wallet.
1 parent d0852f3 commit 6f36242

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,30 @@ def parse_args(self):
186186
parser.add_argument('--timeout-factor', dest="timeout_factor", type=float, default=1.0, help='adjust test timeouts by a factor. Setting it to 0 disables all timeouts')
187187

188188
group = parser.add_mutually_exclusive_group()
189-
group.add_argument("--descriptors", default=False, action="store_true",
189+
group.add_argument("--descriptors", action='store_const', const=True,
190190
help="Run test using a descriptor wallet", dest='descriptors')
191-
group.add_argument("--legacy-wallet", default=False, action="store_false",
191+
group.add_argument("--legacy-wallet", action='store_const', const=False,
192192
help="Run test using legacy wallets", dest='descriptors')
193193

194194
self.add_options(parser)
195195
self.options = parser.parse_args()
196196
self.options.previous_releases_path = previous_releases_path
197197

198+
config = configparser.ConfigParser()
199+
config.read_file(open(self.options.configfile))
200+
self.config = config
201+
202+
if self.options.descriptors is None:
203+
# Prefer BDB unless it isn't available
204+
if self.is_bdb_compiled():
205+
self.options.descriptors = False
206+
elif self.is_sqlite_compiled():
207+
self.options.descriptors = True
208+
else:
209+
# If neither are compiled, tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter
210+
# It still needs to exist and be None in order for tests to work however.
211+
self.options.descriptors = None
212+
198213
def setup(self):
199214
"""Call this method to start up the test framework object with options set."""
200215

@@ -204,9 +219,8 @@ def setup(self):
204219

205220
self.options.cachedir = os.path.abspath(self.options.cachedir)
206221

207-
config = configparser.ConfigParser()
208-
config.read_file(open(self.options.configfile))
209-
self.config = config
222+
config = self.config
223+
210224
fname_bitcoind = os.path.join(
211225
config["environment"]["BUILDDIR"],
212226
"src",

0 commit comments

Comments
 (0)