test: Make requires_wallet private

The bool is only used to call a public helper, which some tests already
do. So use the public helper in all tests consistently and make the
confusingly named bool private.
This commit is contained in:
MacroFake 2022-11-10 10:12:39 +01:00
parent 9dce30194b
commit fa68937b89
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
5 changed files with 8 additions and 12 deletions

View File

@ -69,8 +69,6 @@ class TestBitcoinCli(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
if self.is_specified_wallet_compiled():
self.requires_wallet = True
def skip_test_if_missing_module(self):
self.skip_if_no_cli()
@ -114,6 +112,7 @@ class TestBitcoinCli(BitcoinTestFramework):
self.log.info("Test -getinfo returns expected network and blockchain info")
if self.is_specified_wallet_compiled():
self.import_deterministic_coinbase_privkeys()
self.nodes[0].encryptwallet(password)
cli_get_info_string = self.nodes[0].cli('-getinfo').send_cli()
cli_get_info = cli_get_info_string_to_dict(cli_get_info_string)

View File

@ -17,8 +17,6 @@ MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
class MempoolUnbroadcastTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
if self.is_wallet_compiled():
self.requires_wallet = True
def run_test(self):
self.wallet = MiniWallet(self.nodes[0])
@ -35,6 +33,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
self.log.info("Generate transactions that only node 0 knows about")
if self.is_wallet_compiled():
self.import_deterministic_coinbase_privkeys()
# generate a wallet txn
addr = node.getnewaddress()
wallet_tx_hsh = node.sendtoaddress(addr, 0.0001)

View File

@ -28,8 +28,6 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
self.setup_clean_chain = True
self.num_nodes = 3
self.supports_cli = False
if self.is_bdb_compiled():
self.requires_wallet = True
def get_keys(self):
self.pub = []
@ -50,6 +48,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
self.wallet = MiniWallet(test_node=node0)
if self.is_bdb_compiled():
self.import_deterministic_coinbase_privkeys()
self.check_addmultisigaddress_errors()
self.log.info('Generating blocks ...')

View File

@ -65,8 +65,6 @@ class RawTransactionsTest(BitcoinTestFramework):
# whitelist all peers to speed up tx relay / mempool sync
for args in self.extra_args:
args.append("-whitelist=noban@127.0.0.1")
self.requires_wallet = self.is_specified_wallet_compiled()
self.supports_cli = False
def setup_network(self):
@ -85,7 +83,8 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sendrawtransaction_testmempoolaccept_tests()
self.decoderawtransaction_tests()
self.transaction_version_number_tests()
if self.requires_wallet and not self.options.descriptors:
if self.is_specified_wallet_compiled() and not self.options.descriptors:
self.import_deterministic_coinbase_privkeys()
self.raw_multisig_transaction_legacy_tests()
def getrawtransaction_tests(self):

View File

@ -113,7 +113,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.wallet_names = None
# By default the wallet is not required. Set to true by skip_if_no_wallet().
# When False, we ignore wallet_names regardless of what it is.
self.requires_wallet = False
self._requires_wallet = False
# Disable ThreadOpenConnections by default, so that adding entries to
# addrman will not result in automatic connections to them.
self.disable_autoconnect = True
@ -412,7 +412,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
extra_args = self.extra_args
self.add_nodes(self.num_nodes, extra_args)
self.start_nodes()
if self.requires_wallet:
if self._requires_wallet:
self.import_deterministic_coinbase_privkeys()
if not self.setup_clean_chain:
for n in self.nodes:
@ -866,7 +866,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def skip_if_no_wallet(self):
"""Skip the running test if wallet has not been compiled."""
self.requires_wallet = True
self._requires_wallet = True
if not self.is_wallet_compiled():
raise SkipTest("wallet has not been compiled.")
if self.options.descriptors: