aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-10-02 17:07:29 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-10-02 17:07:35 +0200
commit171cd05ae3413e18fd6382572c86f2bb21ab2fd9 (patch)
tree4b78357634c5812cc4656fcc1031cc6eb09b4e1d /test/functional/test_framework
parentd9935222d53a2a625da992ca51cce7b79d78ca9a (diff)
parentc1585bca8dae01dee6a1dd8eadae2f8b100503df (diff)
downloadbitcoin-171cd05ae3413e18fd6382572c86f2bb21ab2fd9.tar.xz
Merge #20034: test: Get rid of default wallet hacks
c1585bca8dae01dee6a1dd8eadae2f8b100503df test: Get rid of default wallet hacks (Russell Yanofsky) ed3acda33b75d1b546ee696a63def239bcdd62de 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 c1585bca8dae01dee6a1dd8eadae2f8b100503df, only effective change is adding documentation 🎵 Tree-SHA512: f62dec7cbdacb5f330aa0e1eec89ab4d065540d91495bbedcb375eda1c080b45ce9edb310ce253c44c4839f1b4cc2c7df9816c58402d5d43f94a437e301ea8bc
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-xtest/functional/test_framework/test_framework.py37
1 files changed, 16 insertions, 21 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index f41f5129b8..2824d80434 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -102,8 +102,16 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.rpc_timeout = 60 # Wait for up to 60 seconds for the RPC server to respond
self.supports_cli = True
self.bind_to_localhost_only = True
- self.set_test_params()
self.parse_args()
+ self.default_wallet_name = ""
+ self.wallet_data_filename = "wallet.dat"
+ # Optional list of wallet names that can be set in set_test_params to
+ # create and import keys to. If unset, default is len(nodes) *
+ # [default_wallet_name]. If wallet names are None, wallet creation is
+ # skipped. If list is truncated, wallet creation is skipped and keys
+ # are not imported.
+ self.wallet_names = None
+ self.set_test_params()
if self.options.timeout_factor == 0 :
self.options.timeout_factor = 99999
self.rpc_timeout = int(self.rpc_timeout * self.options.timeout_factor) # optionally, increase timeout by a factor
@@ -362,23 +370,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def setup_nodes(self):
"""Override this method to customize test node setup"""
extra_args = [[]] * self.num_nodes
- wallets = [[]] * self.num_nodes
if hasattr(self, "extra_args"):
extra_args = self.extra_args
- wallets = [[x for x in eargs if x.startswith('-wallet=')] for eargs in extra_args]
- extra_args = [x + ['-nowallet'] for x in extra_args]
self.add_nodes(self.num_nodes, extra_args)
self.start_nodes()
- for i, n in enumerate(self.nodes):
- n.extra_args.pop()
- if '-wallet=0' in n.extra_args or '-nowallet' in n.extra_args or '-disablewallet' in n.extra_args or not self.is_wallet_compiled():
- continue
- if '-wallet=' not in wallets[i] and not any([x.startswith('-wallet=') for x in wallets[i]]):
- wallets[i].append('-wallet=')
- for w in wallets[i]:
- wallet_name = w.split('=', 1)[1]
- n.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors)
- self.import_deterministic_coinbase_privkeys()
+ if self.is_wallet_compiled():
+ self.import_deterministic_coinbase_privkeys()
if not self.setup_clean_chain:
for n in self.nodes:
assert_equal(n.getblockchaininfo()["blocks"], 199)
@@ -394,13 +391,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
assert_equal(chain_info["initialblockdownload"], False)
def import_deterministic_coinbase_privkeys(self):
- for n in self.nodes:
- try:
- n.getwalletinfo()
- except JSONRPCException as e:
- assert str(e).startswith('Method not found')
- continue
-
+ wallet_names = [self.default_wallet_name] * len(self.nodes) if self.wallet_names is None else self.wallet_names
+ assert len(wallet_names) <= len(self.nodes)
+ for wallet_name, n in zip(wallet_names, self.nodes):
+ if wallet_name is not None:
+ n.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors, load_on_startup=True)
n.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase')
def run_test(self):