Skip to content

Commit 555519d

Browse files
author
MacroFake
committed
test: Remove wallet option from non-wallet tests
Review note: The changes are complete, because self.options.descriptors is set to None in parse_args (test_framework.py). A value of None implies -disablewallet, see the previous commit. So if a call to add_wallet_options is missing, it will lead to a test failure when the wallet is compiled in.
1 parent fac8d59 commit 555519d

File tree

80 files changed

+244
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+244
-8
lines changed

test/functional/example_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class ExampleTest(BitcoinTestFramework):
7979
# Override the set_test_params(), skip_test_if_missing_module(), add_options(), setup_chain(), setup_network()
8080
# and setup_nodes() methods to customize the test setup as required.
8181

82+
def add_options(self, parser):
83+
self.add_wallet_options(parser)
84+
8285
def set_test_params(self):
8386
"""Override test parameters for your individual test.
8487

test/functional/feature_backwards_compatibility.py

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232

3333

3434
class BackwardsCompatibilityTest(BitcoinTestFramework):
35+
def add_options(self, parser):
36+
self.add_wallet_options(parser)
37+
3538
def set_test_params(self):
3639
self.setup_clean_chain = True
3740
self.num_nodes = 10

test/functional/feature_bip68_sequence.py

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
NOT_FINAL_ERROR = "non-BIP68-final"
4545

4646
class BIP68Test(BitcoinTestFramework):
47+
def add_options(self, parser):
48+
self.add_wallet_options(parser)
49+
4750
def set_test_params(self):
4851
self.num_nodes = 2
4952
self.extra_args = [

test/functional/feature_config_args.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313

1414
class ConfArgsTest(BitcoinTestFramework):
15+
def add_options(self, parser):
16+
self.add_wallet_options(parser)
17+
1518
def set_test_params(self):
1619
self.setup_clean_chain = True
1720
self.num_nodes = 1

test/functional/feature_filelock.py

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from test_framework.test_node import ErrorMatch
1212

1313
class FilelockTest(BitcoinTestFramework):
14+
def add_options(self, parser):
15+
self.add_wallet_options(parser)
16+
1417
def set_test_params(self):
1518
self.setup_clean_chain = True
1619
self.num_nodes = 2

test/functional/feature_init.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class InitStressTest(BitcoinTestFramework):
1717
subsequent starts.
1818
"""
1919

20+
def add_options(self, parser):
21+
self.add_wallet_options(parser)
22+
2023
def set_test_params(self):
2124
self.setup_clean_chain = False
2225
self.num_nodes = 1

test/functional/feature_notifications.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def notify_outputname(walletname, txid):
2424

2525

2626
class NotificationsTest(BitcoinTestFramework):
27+
def add_options(self, parser):
28+
self.add_wallet_options(parser)
29+
2730
def set_test_params(self):
2831
self.num_nodes = 2
2932
self.setup_clean_chain = True

test/functional/feature_pruning.py

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def calc_usage(blockdir):
7676
return sum(os.path.getsize(blockdir + f) for f in os.listdir(blockdir) if os.path.isfile(os.path.join(blockdir, f))) / (1024. * 1024.)
7777

7878
class PruneTest(BitcoinTestFramework):
79+
def add_options(self, parser):
80+
self.add_wallet_options(parser)
81+
7982
def set_test_params(self):
8083
self.setup_clean_chain = True
8184
self.num_nodes = 6

test/functional/feature_rbf.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
MAX_REPLACEMENT_LIMIT = 100
2323
class ReplaceByFeeTest(BitcoinTestFramework):
24+
def add_options(self, parser):
25+
self.add_wallet_options(parser)
26+
2427
def set_test_params(self):
2528
self.num_nodes = 2
2629
self.extra_args = [

test/functional/feature_segwit.py

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def find_spendable_utxo(node, min_value):
7878

7979

8080
class SegWitTest(BitcoinTestFramework):
81+
def add_options(self, parser):
82+
self.add_wallet_options(parser)
83+
8184
def set_test_params(self):
8285
self.setup_clean_chain = True
8386
self.num_nodes = 3

test/functional/feature_taproot.py

+1
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,7 @@ def dump_witness(wit):
12291229

12301230
class TaprootTest(BitcoinTestFramework):
12311231
def add_options(self, parser):
1232+
self.add_wallet_options(parser)
12321233
parser.add_argument("--dumptests", dest="dump_tests", default=False, action="store_true",
12331234
help="Dump generated test cases to directory set by TEST_DUMP_DIR environment variable")
12341235

test/functional/interface_bitcoin_cli.py

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def cli_get_info_string_to_dict(cli_get_info_string):
6666

6767

6868
class TestBitcoinCli(BitcoinTestFramework):
69+
def add_options(self, parser):
70+
self.add_wallet_options(parser)
71+
6972
def set_test_params(self):
7073
self.setup_clean_chain = True
7174
self.num_nodes = 1

test/functional/interface_usdt_coinselection.py

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797

9898

9999
class CoinSelectionTracepointTest(BitcoinTestFramework):
100+
def add_options(self, parser):
101+
self.add_wallet_options(parser)
102+
100103
def set_test_params(self):
101104
self.num_nodes = 1
102105
self.setup_clean_chain = True

test/functional/mempool_compatibility.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222

2323
class MempoolCompatibilityTest(BitcoinTestFramework):
24+
def add_options(self, parser):
25+
self.add_wallet_options(parser)
26+
2427
def set_test_params(self):
2528
self.num_nodes = 2
2629
self.wallet_names = [None]

test/functional/mempool_packages.py

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929

3030
class MempoolPackagesTest(BitcoinTestFramework):
31+
def add_options(self, parser):
32+
self.add_wallet_options(parser)
33+
3134
def set_test_params(self):
3235
self.num_nodes = 2
3336
self.extra_args = [

test/functional/mempool_persist.py

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050

5151

5252
class MempoolPersistTest(BitcoinTestFramework):
53+
def add_options(self, parser):
54+
self.add_wallet_options(parser, legacy=False)
55+
5356
def set_test_params(self):
5457
self.num_nodes = 3
5558
self.extra_args = [[], ["-persistmempool=0"], []]

test/functional/mempool_unbroadcast.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
1616

1717
class MempoolUnbroadcastTest(BitcoinTestFramework):
18+
def add_options(self, parser):
19+
self.add_wallet_options(parser)
20+
1821
def set_test_params(self):
1922
self.num_nodes = 2
2023

test/functional/rpc_createmultisig.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
)
2525

2626
class RpcCreateMultiSigTest(BitcoinTestFramework):
27+
def add_options(self, parser):
28+
self.add_wallet_options(parser)
29+
2730
def set_test_params(self):
2831
self.setup_clean_chain = True
2932
self.num_nodes = 3

test/functional/rpc_fundrawtransaction.py

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def get_unspent(listunspent, amount):
3535
raise AssertionError('Could not find unspent with amount={}'.format(amount))
3636

3737
class RawTransactionsTest(BitcoinTestFramework):
38+
def add_options(self, parser):
39+
self.add_wallet_options(parser)
40+
3841
def set_test_params(self):
3942
self.num_nodes = 4
4043
self.setup_clean_chain = True

test/functional/rpc_help.py

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def process_mapping(fname):
4343

4444

4545
class HelpRpcTest(BitcoinTestFramework):
46+
def add_options(self, parser):
47+
self.add_wallet_options(parser)
48+
4649
def set_test_params(self):
4750
self.num_nodes = 1
4851
self.supports_cli = False

test/functional/rpc_invalid_address_message.py

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
INVALID_ADDRESS_2 = '1q049ldschfnwystcqnsvyfpj23mpsg3jcedq9xv'
4040

4141
class InvalidAddressErrorMessageTest(BitcoinTestFramework):
42+
def add_options(self, parser):
43+
self.add_wallet_options(parser)
44+
4245
def set_test_params(self):
4346
self.setup_clean_chain = True
4447
self.num_nodes = 1

test/functional/rpc_psbt.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
import os
4848

4949

50-
# Create one-input, one-output, no-fee transaction:
5150
class PSBTTest(BitcoinTestFramework):
51+
def add_options(self, parser):
52+
self.add_wallet_options(parser)
5253

5354
def set_test_params(self):
5455
self.num_nodes = 3

test/functional/rpc_rawtransaction.py

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def items(self):
5454

5555

5656
class RawTransactionsTest(BitcoinTestFramework):
57+
def add_options(self, parser):
58+
self.add_wallet_options(parser, descriptors=False)
59+
5760
def set_test_params(self):
5861
self.setup_clean_chain = True
5962
self.num_nodes = 3

test/functional/test_framework/test_framework.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ def parse_args(self):
194194
help="set a random seed for deterministically reproducing a previous test run")
195195
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')
196196

197-
group = parser.add_mutually_exclusive_group()
198-
group.add_argument("--descriptors", action='store_const', const=True,
199-
help="Run test using a descriptor wallet", dest='descriptors')
200-
group.add_argument("--legacy-wallet", action='store_const', const=False,
201-
help="Run test using legacy wallets", dest='descriptors')
202-
203197
self.add_options(parser)
204198
# Running TestShell in a Jupyter notebook causes an additional -f argument
205199
# To keep TestShell from failing with an "unrecognized argument" error, we add a dummy "-f" argument
@@ -212,7 +206,13 @@ def parse_args(self):
212206
config.read_file(open(self.options.configfile))
213207
self.config = config
214208

215-
if self.options.descriptors is None:
209+
if "descriptors" not in self.options:
210+
# Wallet is not required by the test at all and the value of self.options.descriptors won't matter.
211+
# It still needs to exist and be None in order for tests to work however.
212+
# So set it to None to force -disablewallet, because the wallet is not needed.
213+
self.options.descriptors = None
214+
elif self.options.descriptors is None:
215+
# Some wallet is either required or optionally used by the test.
216216
# Prefer BDB unless it isn't available
217217
if self.is_bdb_compiled():
218218
self.options.descriptors = False
@@ -221,6 +221,7 @@ def parse_args(self):
221221
else:
222222
# If neither are compiled, tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter
223223
# It still needs to exist and be None in order for tests to work however.
224+
# So set it to None, which will also set -disablewallet.
224225
self.options.descriptors = None
225226

226227
PortSeed.n = self.options.port_seed
@@ -446,6 +447,15 @@ def run_test(self):
446447

447448
# Public helper methods. These can be accessed by the subclass test scripts.
448449

450+
def add_wallet_options(self, parser, *, descriptors=True, legacy=True):
451+
group = parser.add_mutually_exclusive_group()
452+
if descriptors:
453+
group.add_argument("--descriptors", action='store_const', const=True,
454+
help="Run test using a descriptor wallet", dest='descriptors')
455+
if legacy:
456+
group.add_argument("--legacy-wallet", action='store_const', const=False,
457+
help="Run test using legacy wallets", dest='descriptors')
458+
449459
def add_nodes(self, num_nodes: int, extra_args=None, *, rpchost=None, binary=None, binary_cli=None, versions=None):
450460
"""Instantiate TestNode objects.
451461

test/functional/tool_signet_miner.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121

2222
class SignetMinerTest(BitcoinTestFramework):
23+
def add_options(self, parser):
24+
self.add_wallet_options(parser)
25+
2326
def set_test_params(self):
2427
self.chain = "signet"
2528
self.setup_clean_chain = True

test/functional/tool_wallet.py

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020

2121
class ToolWalletTest(BitcoinTestFramework):
22+
def add_options(self, parser):
23+
self.add_wallet_options(parser)
24+
2225
def set_test_params(self):
2326
self.num_nodes = 1
2427
self.setup_clean_chain = True

test/functional/wallet_abandonconflict.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222

2323
class AbandonConflictTest(BitcoinTestFramework):
24+
def add_options(self, parser):
25+
self.add_wallet_options(parser)
26+
2427
def set_test_params(self):
2528
self.num_nodes = 2
2629
self.extra_args = [["-minrelaytxfee=0.00001"], []]

test/functional/wallet_address_types.py

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
)
6767

6868
class AddressTypeTest(BitcoinTestFramework):
69+
def add_options(self, parser):
70+
self.add_wallet_options(parser)
71+
6972
def set_test_params(self):
7073
self.num_nodes = 6
7174
self.extra_args = [

test/functional/wallet_avoid_mixing_output_types.py

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def generate_payment_values(n, m):
106106

107107

108108
class AddressInputTypeGrouping(BitcoinTestFramework):
109+
def add_options(self, parser):
110+
self.add_wallet_options(parser, legacy=False)
111+
109112
def set_test_params(self):
110113
self.setup_clean_chain = True
111114
self.num_nodes = 2

test/functional/wallet_avoidreuse.py

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def assert_balances(node, mine, margin=0.001):
6363
assert_approx(got[k], v, margin)
6464

6565
class AvoidReuseTest(BitcoinTestFramework):
66+
def add_options(self, parser):
67+
self.add_wallet_options(parser)
6668

6769
def set_test_params(self):
6870
self.num_nodes = 2

test/functional/wallet_backup.py

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444

4545

4646
class WalletBackupTest(BitcoinTestFramework):
47+
def add_options(self, parser):
48+
self.add_wallet_options(parser)
49+
4750
def set_test_params(self):
4851
self.num_nodes = 4
4952
self.setup_clean_chain = True

test/functional/wallet_balance.py

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def create_transactions(node, address, amt, fees):
4646
return txs
4747

4848
class WalletTest(BitcoinTestFramework):
49+
def add_options(self, parser):
50+
self.add_wallet_options(parser)
51+
4952
def set_test_params(self):
5053
self.num_nodes = 2
5154
self.setup_clean_chain = True

test/functional/wallet_basic.py

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424

2525
class WalletTest(BitcoinTestFramework):
26+
def add_options(self, parser):
27+
self.add_wallet_options(parser)
28+
2629
def set_test_params(self):
2730
self.num_nodes = 4
2831
self.extra_args = [[

test/functional/wallet_bumpfee.py

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646

4747

4848
class BumpFeeTest(BitcoinTestFramework):
49+
def add_options(self, parser):
50+
self.add_wallet_options(parser)
51+
4952
def set_test_params(self):
5053
self.num_nodes = 2
5154
self.setup_clean_chain = True

test/functional/wallet_coinbase_category.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
)
1414

1515
class CoinbaseCategoryTest(BitcoinTestFramework):
16+
def add_options(self, parser):
17+
self.add_wallet_options(parser)
18+
1619
def set_test_params(self):
1720
self.num_nodes = 1
1821
self.setup_clean_chain = True

test/functional/wallet_create_tx.py

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515

1616
class CreateTxWalletTest(BitcoinTestFramework):
17+
def add_options(self, parser):
18+
self.add_wallet_options(parser)
19+
1720
def set_test_params(self):
1821
self.setup_clean_chain = True
1922
self.num_nodes = 1

0 commit comments

Comments
 (0)