Skip to content

Commit 171cd05

Browse files
author
MarcoFalke
committed
Merge #20034: test: Get rid of default wallet hacks
c1585bc test: Get rid of default wallet hacks (Russell Yanofsky) ed3acda test, refactor: add default_wallet_name and wallet_data_filename variables (Russell Yanofsky) Pull request description: Changes: - Get rid of setup_nodes (`-wallet`, `-nowallet`, `-disablewallet`) argument rewriting - Get rid of hardcoded wallet `""` names and `-wallet=""` args Motivation: - Simplify test framework behavior so it's easier to write new tests without having arguments mangled by the framework - Make tests more readable, replacing unexplained `""` string literals with `default_wallet_name` references - Make it trivial to update default wallet name and wallet data filename for sqlite #19077 testing - Stop relying on `-wallet` arguments to create wallets, so it is easy to change `-wallet` option in the future to only load existing wallets not create new ones (to avoid accidental wallet creation, and encourage use of wallet encryption and descriptor features) ACKs for top commit: MarcoFalke: ACK c1585bc, only effective change is adding documentation 🎵 Tree-SHA512: f62dec7cbdacb5f330aa0e1eec89ab4d065540d91495bbedcb375eda1c080b45ce9edb310ce253c44c4839f1b4cc2c7df9816c58402d5d43f94a437e301ea8bc
2 parents d993522 + c1585bc commit 171cd05

27 files changed

+94
-92
lines changed

test/functional/feature_backwards_compatibility.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ def set_test_params(self):
3636
self.num_nodes = 6
3737
# Add new version after each release:
3838
self.extra_args = [
39-
["-addresstype=bech32", "-wallet="], # Pre-release: use to mine blocks
39+
["-addresstype=bech32"], # Pre-release: use to mine blocks
4040
["-nowallet", "-walletrbf=1", "-addresstype=bech32"], # Pre-release: use to receive coins, swap wallets, etc
4141
["-nowallet", "-walletrbf=1", "-addresstype=bech32"], # v0.19.1
4242
["-nowallet", "-walletrbf=1", "-addresstype=bech32"], # v0.18.1
4343
["-nowallet", "-walletrbf=1", "-addresstype=bech32"], # v0.17.2
4444
["-nowallet", "-walletrbf=1", "-addresstype=bech32", "-wallet=wallet.dat"], # v0.16.3
4545
]
46+
self.wallet_names = [self.default_wallet_name]
4647

4748
def skip_test_if_missing_module(self):
4849
self.skip_if_no_wallet()
@@ -59,6 +60,7 @@ def setup_nodes(self):
5960
])
6061

6162
self.start_nodes()
63+
self.import_deterministic_coinbase_privkeys()
6264

6365
def run_test(self):
6466
self.nodes[0].generatetoaddress(101, self.nodes[0].getnewaddress())

test/functional/feature_config_args.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def set_test_params(self):
1414
self.setup_clean_chain = True
1515
self.num_nodes = 1
1616
self.supports_cli = False
17+
self.wallet_names = []
1718

1819
def test_config_file_parser(self):
1920
# Assume node is stopped

test/functional/feature_dbcrash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def set_test_params(self):
5656
# Set -maxmempool=0 to turn off mempool memory sharing with dbcache
5757
# Set -rpcservertimeout=900 to reduce socket disconnects in this
5858
# long-running test
59-
self.base_args = ["-limitdescendantsize=0", "-maxmempool=0", "-rpcservertimeout=900", "-dbbatchsize=200000", "-wallet="]
59+
self.base_args = ["-limitdescendantsize=0", "-maxmempool=0", "-rpcservertimeout=900", "-dbbatchsize=200000"]
6060

6161
# Set different crash ratios and cache sizes. Note that not all of
6262
# -dbcache goes to the in-memory coins cache.
@@ -66,7 +66,7 @@ def set_test_params(self):
6666

6767
# Node3 is a normal node with default args, except will mine full blocks
6868
# and non-standard txs (e.g. txs with "dust" outputs)
69-
self.node3_args = ["-blockmaxweight=4000000", "-acceptnonstdtxn", "-wallet="]
69+
self.node3_args = ["-blockmaxweight=4000000", "-acceptnonstdtxn"]
7070
self.extra_args = [self.node0_args, self.node1_args, self.node2_args, self.node3_args]
7171

7272
def skip_test_if_missing_module(self):

test/functional/feature_fee_estimation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def set_test_params(self):
145145
# mine non-standard txs (e.g. txs with "dust" outputs)
146146
# Force fSendTrickle to true (via whitelist.noban)
147147
self.extra_args = [
148-
["-acceptnonstdtxn", "[email protected]", "-wallet="],
149-
["-acceptnonstdtxn", "[email protected]", "-blockmaxweight=68000", "-wallet="],
150-
["-acceptnonstdtxn", "[email protected]", "-blockmaxweight=32000", "-wallet="],
148+
["-acceptnonstdtxn", "[email protected]"],
149+
["-acceptnonstdtxn", "[email protected]", "-blockmaxweight=68000"],
150+
["-acceptnonstdtxn", "[email protected]", "-blockmaxweight=32000"],
151151
]
152152

153153
def skip_test_if_missing_module(self):

test/functional/feature_filelock.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def set_test_params(self):
1515

1616
def setup_network(self):
1717
self.add_nodes(self.num_nodes, extra_args=None)
18-
self.nodes[0].start(['-wallet='])
18+
self.nodes[0].start()
1919
self.nodes[0].wait_for_rpc_connection()
2020

2121
def run_test(self):
@@ -27,10 +27,11 @@ def run_test(self):
2727
self.nodes[1].assert_start_raises_init_error(extra_args=['-datadir={}'.format(self.nodes[0].datadir), '-noserver'], expected_msg=expected_msg)
2828

2929
if self.is_wallet_compiled():
30+
self.nodes[0].createwallet(self.default_wallet_name)
3031
wallet_dir = os.path.join(datadir, 'wallets')
3132
self.log.info("Check that we can't start a second bitcoind instance using the same wallet")
3233
expected_msg = "Error: Error initializing wallet database environment"
33-
self.nodes[1].assert_start_raises_init_error(extra_args=['-walletdir={}'.format(wallet_dir), '-wallet=', '-noserver'], expected_msg=expected_msg, match=ErrorMatch.PARTIAL_REGEX)
34+
self.nodes[1].assert_start_raises_init_error(extra_args=['-walletdir={}'.format(wallet_dir), '-wallet=' + self.default_wallet_name, '-noserver'], expected_msg=expected_msg, match=ErrorMatch.PARTIAL_REGEX)
3435

3536
if __name__ == '__main__':
3637
FilelockTest().main()

test/functional/feature_notifications.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def setup_network(self):
4545
"-blocknotify=echo > {}".format(os.path.join(self.blocknotify_dir, '%s'))],
4646
["-blockversion=211",
4747
"-rescan",
48-
"-wallet={}".format(self.wallet),
4948
"-walletnotify=echo > {}".format(os.path.join(self.walletnotify_dir, notify_outputname('%w', '%s')))]]
49+
self.wallet_names = [self.default_wallet_name, self.wallet]
5050
super().setup_network()
5151

5252
def run_test(self):

test/functional/feature_pruning.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ def set_test_params(self):
8181

8282
# Create nodes 0 and 1 to mine.
8383
# Create node 2 to test pruning.
84-
self.full_node_default_args = ["-maxreceivebuffer=20000", "-checkblocks=5", "-wallet="]
84+
self.full_node_default_args = ["-maxreceivebuffer=20000", "-checkblocks=5"]
8585
# Create nodes 3 and 4 to test manual pruning (they will be re-started with manual pruning later)
8686
# Create nodes 5 to test wallet in prune mode, but do not connect
8787
self.extra_args = [
8888
self.full_node_default_args,
8989
self.full_node_default_args,
90-
["-wallet=", "-maxreceivebuffer=20000", "-prune=550"],
91-
["-wallet=", "-maxreceivebuffer=20000"],
92-
["-wallet=", "-maxreceivebuffer=20000"],
93-
["-wallet=", "-prune=550"],
90+
["-maxreceivebuffer=20000", "-prune=550"],
91+
["-maxreceivebuffer=20000"],
92+
["-maxreceivebuffer=20000"],
93+
["-prune=550"],
9494
]
9595
self.rpc_timeout = 120
9696

@@ -112,8 +112,7 @@ def setup_network(self):
112112
def setup_nodes(self):
113113
self.add_nodes(self.num_nodes, self.extra_args)
114114
self.start_nodes()
115-
for n in self.nodes:
116-
n.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase', rescan=False)
115+
self.import_deterministic_coinbase_privkeys()
117116

118117
def create_big_chain(self):
119118
# Start by creating some coinbases we can spend later

test/functional/feature_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SettingsTest(BitcoinTestFramework):
1717
def set_test_params(self):
1818
self.setup_clean_chain = True
1919
self.num_nodes = 1
20+
self.wallet_names = []
2021

2122
def run_test(self):
2223
node, = self.nodes

test/functional/interface_bitcoin_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def run_test(self):
9595
assert_equal(self.nodes[0].cli.getwalletinfo(), wallet_info)
9696

9797
# Setup to test -getinfo, -generate, and -rpcwallet= with multiple wallets.
98-
wallets = ['', 'Encrypted', 'secret']
98+
wallets = [self.default_wallet_name, 'Encrypted', 'secret']
9999
amounts = [BALANCE + Decimal('9.999928'), Decimal(9), Decimal(31)]
100100
self.nodes[0].createwallet(wallet_name=wallets[1])
101101
self.nodes[0].createwallet(wallet_name=wallets[2])

test/functional/mempool_compatibility.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
class MempoolCompatibilityTest(BitcoinTestFramework):
2222
def set_test_params(self):
2323
self.num_nodes = 2
24+
self.wallet_names = [None, self.default_wallet_name]
2425

2526
def skip_test_if_missing_module(self):
2627
self.skip_if_no_wallet()
@@ -31,7 +32,7 @@ def setup_network(self):
3132
150200, # oldest version supported by the test framework
3233
None,
3334
])
34-
self.start_nodes([[], ["-wallet="]])
35+
self.start_nodes()
3536
self.import_deterministic_coinbase_privkeys()
3637

3738
def run_test(self):

0 commit comments

Comments
 (0)