From 2dd12f52dd6a04b8b2bb921fb94fb80a54a80e52 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 28 Nov 2022 10:58:46 -0500 Subject: [PATCH 1/9] Merge bitcoin/bitcoin#26480: test: Remove wallet option from non-wallet tests fa10f193b54650b3071bc7ee2d90fcfe40a16dc9 test: Set default in add_wallet_options if only one type can be chosen (MacroFake) 555519d082fbe5e047595f06d7f301e441bb7149 test: Remove wallet option from non-wallet tests (MacroFake) fac8d59d310fa94a8d5dd99659a76cd958d1fd1b test: Set -disablewallet when no wallet has been compiled (MacroFake) fa68937b89aa5b10b33b3f5146390cd7ad369ff7 test: Make requires_wallet private (MacroFake) Pull request description: The tests have several issues: * Some tests that are wallet-type specific offer the option to run the test with the incompatible type For example, `wallet_dump.py` offers `--descriptors` and on current master fails with `JSONRPCException: Invalid public key`. After the changes here, it fails with a clear error: `unrecognized arguments: --descriptors`. * Tests that don't use the wallet at all offer the option to run it with a wallet type. This is confusing and wastes developers time if they are "tricked" into running the test for both wallet types, even though no wallet code is executed at all. For example, `feature_addrman.py` will happily accept and run with `--descriptors` or `--legacy-wallet`. After the changes here, it no longer silently ignores the flag, but reports a clear error: `unrecognized arguments`. ACKs for top commit: achow101: ACK fa10f193b54650b3071bc7ee2d90fcfe40a16dc9 Tree-SHA512: a5784da7305f4ec58c0013f433289000d94fc3d434b00fc329ffa37b812e2cd1da0071e34c3462bf79d904808564f2ae6d3d582f6b86b26215f9b07391b58460 --- test/functional/example_test.py | 3 ++ .../feature_backwards_compatibility.py | 3 ++ test/functional/feature_bip68_sequence.py | 3 ++ test/functional/feature_config_args.py | 3 ++ test/functional/feature_filelock.py | 3 ++ test/functional/feature_init.py | 3 ++ test/functional/feature_notifications.py | 3 ++ test/functional/feature_pruning.py | 3 ++ test/functional/interface_bitcoin_cli.py | 6 ++-- .../interface_usdt_coinselection.py | 3 ++ test/functional/mempool_compatibility.py | 3 ++ test/functional/mempool_packages.py | 3 ++ test/functional/mempool_persist.py | 3 ++ test/functional/mempool_unbroadcast.py | 6 ++-- test/functional/rpc_createmultisig.py | 6 ++-- test/functional/rpc_fundrawtransaction.py | 3 ++ test/functional/rpc_help.py | 3 ++ .../functional/rpc_invalid_address_message.py | 3 ++ test/functional/rpc_psbt.py | 3 +- test/functional/rpc_rawtransaction.py | 8 +++-- .../test_framework/test_framework.py | 34 +++++++++++++------ test/functional/test_framework/test_node.py | 3 ++ test/functional/tool_wallet.py | 3 ++ test/functional/wallet_abandonconflict.py | 3 ++ test/functional/wallet_avoidreuse.py | 2 ++ test/functional/wallet_backup.py | 3 ++ test/functional/wallet_balance.py | 3 ++ test/functional/wallet_basic.py | 3 ++ test/functional/wallet_coinbase_category.py | 3 ++ test/functional/wallet_create_tx.py | 3 ++ test/functional/wallet_createwallet.py | 3 ++ test/functional/wallet_crosschain.py | 3 ++ test/functional/wallet_descriptor.py | 3 ++ test/functional/wallet_dump.py | 3 ++ test/functional/wallet_encryption.py | 3 ++ test/functional/wallet_fallbackfee.py | 3 ++ test/functional/wallet_groups.py | 3 ++ test/functional/wallet_hd.py | 3 ++ test/functional/wallet_import_rescan.py | 3 ++ test/functional/wallet_import_with_label.py | 3 ++ test/functional/wallet_importdescriptors.py | 3 ++ test/functional/wallet_importmulti.py | 3 ++ test/functional/wallet_importprunedfunds.py | 3 ++ test/functional/wallet_keypool.py | 3 ++ test/functional/wallet_keypool_topup.py | 3 ++ test/functional/wallet_labels.py | 3 ++ test/functional/wallet_listdescriptors.py | 3 ++ test/functional/wallet_listreceivedby.py | 3 ++ test/functional/wallet_listsinceblock.py | 3 ++ test/functional/wallet_listtransactions.py | 3 ++ .../wallet_multisig_descriptor_psbt.py | 3 ++ test/functional/wallet_multiwallet.py | 1 + test/functional/wallet_orphanedreward.py | 3 ++ test/functional/wallet_reorgsrestore.py | 3 ++ .../wallet_resendwallettransactions.py | 3 ++ test/functional/wallet_send.py | 3 ++ test/functional/wallet_signer.py | 3 ++ .../wallet_signmessagewithaddress.py | 3 ++ .../wallet_signrawtransactionwithwallet.py | 3 ++ test/functional/wallet_simulaterawtx.py | 3 ++ test/functional/wallet_startup.py | 3 ++ test/functional/wallet_timelock.py | 3 ++ .../wallet_transactiontime_rescan.py | 3 ++ test/functional/wallet_txn_clone.py | 1 + test/functional/wallet_txn_doublespend.py | 1 + test/functional/wallet_upgradewallet.py | 3 ++ test/functional/wallet_watchonly.py | 3 ++ 67 files changed, 219 insertions(+), 20 deletions(-) diff --git a/test/functional/example_test.py b/test/functional/example_test.py index 17ca92d00776..288959c4d3c4 100755 --- a/test/functional/example_test.py +++ b/test/functional/example_test.py @@ -79,6 +79,9 @@ class ExampleTest(BitcoinTestFramework): # Override the set_test_params(), skip_test_if_missing_module(), add_options(), setup_chain(), setup_network() # and setup_nodes() methods to customize the test setup as required. + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): """Override test parameters for your individual test. diff --git a/test/functional/feature_backwards_compatibility.py b/test/functional/feature_backwards_compatibility.py index d954278daf3d..de1e330a1c83 100755 --- a/test/functional/feature_backwards_compatibility.py +++ b/test/functional/feature_backwards_compatibility.py @@ -31,6 +31,9 @@ class BackwardsCompatibilityTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 8 diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py index c7ca1ec190f9..ed899bfa88ca 100755 --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -41,6 +41,9 @@ NOT_FINAL_ERROR = "non-BIP68-final" class BIP68Test(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 self.extra_args = [ diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index 2e8e58a6027f..9bdadfe794c1 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -12,6 +12,9 @@ class ConfArgsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/feature_filelock.py b/test/functional/feature_filelock.py index af5509a77db6..31f5225ae19c 100755 --- a/test/functional/feature_filelock.py +++ b/test/functional/feature_filelock.py @@ -13,6 +13,9 @@ class FilelockTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 diff --git a/test/functional/feature_init.py b/test/functional/feature_init.py index b4227e65fd54..ce12319933de 100755 --- a/test/functional/feature_init.py +++ b/test/functional/feature_init.py @@ -19,6 +19,9 @@ class InitStressTest(BitcoinTestFramework): subsequent starts. """ + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = False self.num_nodes = 1 diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py index 07058f8ded64..f46757f9de67 100755 --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -26,6 +26,9 @@ def notify_outputname(walletname, txid): class NotificationsTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(6, 4) diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index a58ea8c514d9..fb68cfdbe7b6 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -88,6 +88,9 @@ def calc_usage(blockdir): return sum(os.path.getsize(blockdir + f) for f in os.listdir(blockdir) if os.path.isfile(os.path.join(blockdir, f))) / (1024. * 1024.) class PruneTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 6 diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py index a81f6e25f11b..e44674dbc3c2 100755 --- a/test/functional/interface_bitcoin_cli.py +++ b/test/functional/interface_bitcoin_cli.py @@ -66,11 +66,12 @@ def cli_get_info_string_to_dict(cli_get_info_string): class TestBitcoinCli(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + 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() @@ -123,6 +124,7 @@ def run_test(self): 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) diff --git a/test/functional/interface_usdt_coinselection.py b/test/functional/interface_usdt_coinselection.py index 8148e651a2e7..cb1fe12a409b 100755 --- a/test/functional/interface_usdt_coinselection.py +++ b/test/functional/interface_usdt_coinselection.py @@ -97,6 +97,9 @@ class CoinSelectionTracepointTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True diff --git a/test/functional/mempool_compatibility.py b/test/functional/mempool_compatibility.py index b576385651e1..7a7a322992e9 100755 --- a/test/functional/mempool_compatibility.py +++ b/test/functional/mempool_compatibility.py @@ -18,6 +18,9 @@ class MempoolCompatibilityTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py index b922a7678bf4..33651108461e 100755 --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -28,6 +28,9 @@ class MempoolPackagesTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 self.extra_args = [ diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py index 0bdc8c0a7636..57d71abfe58d 100755 --- a/test/functional/mempool_persist.py +++ b/test/functional/mempool_persist.py @@ -48,6 +48,9 @@ class MempoolPersistTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, legacy=False) + def set_test_params(self): self.num_nodes = 3 self.extra_args = [[], ["-persistmempool=0"], []] diff --git a/test/functional/mempool_unbroadcast.py b/test/functional/mempool_unbroadcast.py index 0a3eb0492290..b8d7e9e0f5e3 100755 --- a/test/functional/mempool_unbroadcast.py +++ b/test/functional/mempool_unbroadcast.py @@ -15,10 +15,11 @@ MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds class MempoolUnbroadcastTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + 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 +36,7 @@ def test_broadcast(self): 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) diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index 8b7b06944734..509c8721a2d3 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -23,12 +23,13 @@ ) class RpcCreateMultiSigTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): 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 = [] @@ -49,6 +50,7 @@ def run_test(self): 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 ...') diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 1326ba893be2..400f882c215f 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -32,6 +32,9 @@ def get_unspent(listunspent, amount): raise AssertionError('Could not find unspent with amount={}'.format(amount)) class RawTransactionsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True diff --git a/test/functional/rpc_help.py b/test/functional/rpc_help.py index 30573822f260..b362cf068c3e 100755 --- a/test/functional/rpc_help.py +++ b/test/functional/rpc_help.py @@ -43,6 +43,9 @@ def process_mapping(fname): class HelpRpcTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.supports_cli = False diff --git a/test/functional/rpc_invalid_address_message.py b/test/functional/rpc_invalid_address_message.py index 18d85d677030..2f6df8570c94 100755 --- a/test/functional/rpc_invalid_address_message.py +++ b/test/functional/rpc_invalid_address_message.py @@ -18,6 +18,9 @@ INVALID_ADDRESS = 'asfah14i8fajz0123f' class InvalidAddressErrorMessageTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index ea6684ede75c..02fc6f1da642 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -39,8 +39,9 @@ import json import os -# Create one-input, one-output, no-fee transaction: class PSBTTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) def set_test_params(self): self.num_nodes = 3 diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index 7854db8a09fb..ad0c55ba82e3 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -53,6 +53,9 @@ def items(self): class RawTransactionsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, descriptors=False) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 3 @@ -64,8 +67,6 @@ def set_test_params(self): # 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): @@ -83,7 +84,8 @@ def run_test(self): self.sendrawtransaction_tests() self.sendrawtransaction_testmempoolaccept_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): diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 02a1260c2eeb..70688b689cf0 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -141,7 +141,7 @@ def __init__(self): 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 @@ -230,12 +230,6 @@ def parse_args(self): parser.add_argument("--v1transport", dest="v1transport", default=False, action="store_true", help="Explicitly use v1 transport (can be used to overwrite global --v2transport option)") - group = parser.add_mutually_exclusive_group() - group.add_argument("--descriptors", action='store_const', const=True, - help="Run test using a descriptor wallet", dest='descriptors') - group.add_argument("--legacy-wallet", action='store_const', const=False, - help="Run test using legacy wallets", dest='descriptors') - self.add_options(parser) self.options = parser.parse_args() if self.options.timeout_factor == 0: @@ -254,7 +248,13 @@ def parse_args(self): # source: https://stackoverflow.com/questions/48796169/how-to-fix-ipykernel-launcher-py-error-unrecognized-arguments-in-jupyter/56349168#56349168 parser.add_argument("-f", "--fff", help="a dummy argument to fool ipython", default="1") - if self.options.descriptors is None: + if "descriptors" not in self.options: + # Wallet is not required by the test at all and the value of self.options.descriptors won't matter. + # It still needs to exist and be None in order for tests to work however. + # So set it to None to force -disablewallet, because the wallet is not needed. + self.options.descriptors = None + elif self.options.descriptors is None: + # Some wallet is either required or optionally used by the test. # Prefer BDB unless it isn't available if self.is_bdb_compiled(): self.options.descriptors = False @@ -263,6 +263,7 @@ def parse_args(self): else: # If neither are compiled, tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter # It still needs to exist and be None in order for tests to work however. + # So set it to None, which will also set -disablewallet. self.options.descriptors = None PortSeed.n = self.options.port_seed @@ -461,7 +462,7 @@ def setup_nodes(self): """ NOTE! If this method is updated - backport changes to DashTestFramework.setup_nodes""" self.add_nodes(self.num_nodes, self.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: @@ -497,6 +498,19 @@ def run_test(self): # Public helper methods. These can be accessed by the subclass test scripts. + def add_wallet_options(self, parser, *, descriptors=True, legacy=True): + group = parser.add_mutually_exclusive_group() + kwargs = {} + if descriptors + legacy == 1: + # If only one type can be chosen, set it as default + kwargs["default"] = descriptors + if descriptors: + group.add_argument("--descriptors", action='store_const', const=True, **kwargs, + help="Run test using a descriptor wallet", dest='descriptors') + if legacy: + group.add_argument("--legacy-wallet", action='store_const', const=False, **kwargs, + help="Run test using legacy wallets", dest='descriptors') + def add_nodes(self, num_nodes: int, extra_args=None, *, rpchost=None, binary=None, binary_cli=None, versions=None): """Instantiate TestNode objects. @@ -1048,7 +1062,7 @@ def skip_if_no_bitcoind_zmq(self): 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: diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index a93a05ffb66a..7e7b6fa3b47f 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -114,6 +114,9 @@ def __init__(self, i, datadir, extra_args_from_options, *, chain, rpchost, timew if self.mocktime != 0: self.args.append(f"-mocktime={mocktime}") + if self.descriptors is None: + self.args.append("-disablewallet") + # Use valgrind, expect for previous release binaries if use_valgrind and version is None: default_suppressions_file = os.path.join( diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py index 25b2bd5cdf88..41d8c1d0ea33 100755 --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -18,6 +18,9 @@ BUFFER_SIZE = 16 * 1024 class ToolWalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True diff --git a/test/functional/wallet_abandonconflict.py b/test/functional/wallet_abandonconflict.py index 93450e665011..425fb6b0f890 100755 --- a/test/functional/wallet_abandonconflict.py +++ b/test/functional/wallet_abandonconflict.py @@ -21,6 +21,9 @@ class AbandonConflictTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 self.extra_args = [["-minrelaytxfee=0.00001"], []] diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index 7b444e05b75c..38864cba1ed3 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -63,6 +63,8 @@ def assert_balances(node, mine, margin=0.001): assert_approx(got[k], v, margin) class AvoidReuseTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) def set_test_params(self): self.num_nodes = 2 diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index 281760bd1588..2f113c042140 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -40,6 +40,9 @@ from test_framework.util import assert_equal, assert_raises_rpc_error class WalletBackupTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py index 21cb326321d1..b039f147aa3b 100755 --- a/test/functional/wallet_balance.py +++ b/test/functional/wallet_balance.py @@ -47,6 +47,9 @@ def create_transactions(node, address, amt, fees): return txs class WalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index e934422c4e1f..5d2f35ea7745 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -24,6 +24,9 @@ class WalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 4 if self.options.descriptors: diff --git a/test/functional/wallet_coinbase_category.py b/test/functional/wallet_coinbase_category.py index ad66ee8d17b2..b1037ea1342d 100755 --- a/test/functional/wallet_coinbase_category.py +++ b/test/functional/wallet_coinbase_category.py @@ -13,6 +13,9 @@ ) class CoinbaseCategoryTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True diff --git a/test/functional/wallet_create_tx.py b/test/functional/wallet_create_tx.py index 65c43cf7a74e..5e8bf17d16fe 100755 --- a/test/functional/wallet_create_tx.py +++ b/test/functional/wallet_create_tx.py @@ -11,6 +11,9 @@ class CreateTxWalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/wallet_createwallet.py b/test/functional/wallet_createwallet.py index f8ba2cab7318..f8964ecf428d 100755 --- a/test/functional/wallet_createwallet.py +++ b/test/functional/wallet_createwallet.py @@ -16,6 +16,9 @@ from test_framework.wallet_util import bytes_to_wif, generate_wif_key class CreateWalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/wallet_crosschain.py b/test/functional/wallet_crosschain.py index f25b3ef88a60..b3d860057599 100755 --- a/test/functional/wallet_crosschain.py +++ b/test/functional/wallet_crosschain.py @@ -10,6 +10,9 @@ from test_framework.util import assert_raises_rpc_error class WalletCrossChain(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py index eba75ff94108..74d096430ce9 100755 --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -12,6 +12,9 @@ class WalletDescriptorTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, legacy=False) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py index 816a812df820..e224ed64d51b 100755 --- a/test/functional/wallet_dump.py +++ b/test/functional/wallet_dump.py @@ -84,6 +84,9 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old): class WalletDumpTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, descriptors=False) + def set_test_params(self): self.num_nodes = 1 self.disable_mocktime = True diff --git a/test/functional/wallet_encryption.py b/test/functional/wallet_encryption.py index fb1459b6808f..090970834a0e 100755 --- a/test/functional/wallet_encryption.py +++ b/test/functional/wallet_encryption.py @@ -14,6 +14,9 @@ class WalletEncryptionTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_fallbackfee.py b/test/functional/wallet_fallbackfee.py index 674c37dc73c5..04b5f5593732 100755 --- a/test/functional/wallet_fallbackfee.py +++ b/test/functional/wallet_fallbackfee.py @@ -9,6 +9,9 @@ from test_framework.util import assert_raises_rpc_error class WalletRBFTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py index 4912e97cd1c3..4ee63d803a0d 100755 --- a/test/functional/wallet_groups.py +++ b/test/functional/wallet_groups.py @@ -15,6 +15,9 @@ ) class WalletGroupTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 5 diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index ef981056a5bc..211b5106d17e 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -15,6 +15,9 @@ ) class WalletHDTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 diff --git a/test/functional/wallet_import_rescan.py b/test/functional/wallet_import_rescan.py index 1a42a8611918..ba5d7ab4b116 100755 --- a/test/functional/wallet_import_rescan.py +++ b/test/functional/wallet_import_rescan.py @@ -136,6 +136,9 @@ def get_rand_amount(): class ImportRescanTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, descriptors=False) + def set_test_params(self): self.num_nodes = 2 + len(IMPORT_NODES) self.supports_cli = False diff --git a/test/functional/wallet_import_with_label.py b/test/functional/wallet_import_with_label.py index f00d5c7c6aa7..25a61ad037f3 100755 --- a/test/functional/wallet_import_with_label.py +++ b/test/functional/wallet_import_with_label.py @@ -15,6 +15,9 @@ class ImportWithLabel(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, descriptors=False) + def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py index 9d961c69885b..0d24c2565e8a 100755 --- a/test/functional/wallet_importdescriptors.py +++ b/test/functional/wallet_importdescriptors.py @@ -28,6 +28,9 @@ ) class ImportDescriptorsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, legacy=False) + def set_test_params(self): self.num_nodes = 2 self.extra_args = [[], diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py index d924a94ed342..d16503671760 100755 --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -34,6 +34,9 @@ ) class ImportMultiTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, descriptors=False) + def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index 2dee8c438d66..d701c7d95a11 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -21,6 +21,9 @@ class ImportPrunedFundsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py index 71ab9ff73cfa..2b6e68941c3f 100755 --- a/test/functional/wallet_keypool.py +++ b/test/functional/wallet_keypool.py @@ -10,6 +10,9 @@ from test_framework.util import assert_equal, assert_raises_rpc_error class KeyPoolTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.extra_args = [['-usehd=0']] diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py index 9ae09cef7801..f699615d95d1 100755 --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -21,6 +21,9 @@ class KeypoolRestoreTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 4 diff --git a/test/functional/wallet_labels.py b/test/functional/wallet_labels.py index 0b8511af038d..3b70e4132ad7 100755 --- a/test/functional/wallet_labels.py +++ b/test/functional/wallet_labels.py @@ -18,6 +18,9 @@ class WalletLabelsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 diff --git a/test/functional/wallet_listdescriptors.py b/test/functional/wallet_listdescriptors.py index e6031f9c0b75..bd54e5e1b09f 100755 --- a/test/functional/wallet_listdescriptors.py +++ b/test/functional/wallet_listdescriptors.py @@ -18,6 +18,9 @@ class ListDescriptorsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, legacy=False) + def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py index 6da3f236c89b..76f03d515a78 100755 --- a/test/functional/wallet_listreceivedby.py +++ b/test/functional/wallet_listreceivedby.py @@ -16,6 +16,9 @@ class ReceivedByTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 # whitelist peers to speed up tx relay / mempool sync diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py index 4a4167f11155..c408741635c1 100755 --- a/test/functional/wallet_listsinceblock.py +++ b/test/functional/wallet_listsinceblock.py @@ -19,6 +19,9 @@ from decimal import Decimal class ListSinceBlockTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True diff --git a/test/functional/wallet_listtransactions.py b/test/functional/wallet_listtransactions.py index c6d3c2812352..47c722aec273 100755 --- a/test/functional/wallet_listtransactions.py +++ b/test/functional/wallet_listtransactions.py @@ -17,6 +17,9 @@ class ListTransactionsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 3 # This test isn't testing txn relay/timing, so set whitelist on the diff --git a/test/functional/wallet_multisig_descriptor_psbt.py b/test/functional/wallet_multisig_descriptor_psbt.py index d2fb5482822a..ccd89379a6de 100755 --- a/test/functional/wallet_multisig_descriptor_psbt.py +++ b/test/functional/wallet_multisig_descriptor_psbt.py @@ -16,6 +16,9 @@ class WalletMultisigDescriptorPSBTTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, legacy=False) + def set_test_params(self): self.num_nodes = 3 self.setup_clean_chain = True diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index 541751768d63..d4a86a8bec60 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -51,6 +51,7 @@ def skip_test_if_missing_module(self): self.skip_if_no_wallet() def add_options(self, parser): + self.add_wallet_options(parser) parser.add_argument( '--data_wallets_dir', default=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/wallets/'), diff --git a/test/functional/wallet_orphanedreward.py b/test/functional/wallet_orphanedreward.py index 871ca02a7505..67e39fc3b4ca 100755 --- a/test/functional/wallet_orphanedreward.py +++ b/test/functional/wallet_orphanedreward.py @@ -9,6 +9,9 @@ from decimal import Decimal class OrphanedBlockRewardTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 diff --git a/test/functional/wallet_reorgsrestore.py b/test/functional/wallet_reorgsrestore.py index fbd870338cef..07a4f6b03d0f 100755 --- a/test/functional/wallet_reorgsrestore.py +++ b/test/functional/wallet_reorgsrestore.py @@ -23,6 +23,9 @@ ) class ReorgsRestoreTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 3 diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py index 50a513ea83bd..8356b89d401b 100755 --- a/test/functional/wallet_resendwallettransactions.py +++ b/test/functional/wallet_resendwallettransactions.py @@ -14,6 +14,9 @@ class ResendWalletTransactionsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py index 8ff83175abc3..cdc3ef3ee082 100755 --- a/test/functional/wallet_send.py +++ b/test/functional/wallet_send.py @@ -20,6 +20,9 @@ from test_framework.wallet_util import bytes_to_wif class WalletSendTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 # whitelist all peers to speed up tx relay / mempool sync diff --git a/test/functional/wallet_signer.py b/test/functional/wallet_signer.py index cbb59bede125..c3e09b06d290 100755 --- a/test/functional/wallet_signer.py +++ b/test/functional/wallet_signer.py @@ -18,6 +18,9 @@ class WalletSignerTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, legacy=False) + def mock_signer_path(self): path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py') if platform.system() == "Windows": diff --git a/test/functional/wallet_signmessagewithaddress.py b/test/functional/wallet_signmessagewithaddress.py index df5e36bf3dde..0ec1ced1ce87 100755 --- a/test/functional/wallet_signmessagewithaddress.py +++ b/test/functional/wallet_signmessagewithaddress.py @@ -10,6 +10,9 @@ ) class SignMessagesWithAddressTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_signrawtransactionwithwallet.py b/test/functional/wallet_signrawtransactionwithwallet.py index aaf02e7b5e7e..880ed8a594e1 100755 --- a/test/functional/wallet_signrawtransactionwithwallet.py +++ b/test/functional/wallet_signrawtransactionwithwallet.py @@ -12,6 +12,9 @@ from decimal import Decimal, getcontext class SignRawTransactionWithWalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_simulaterawtx.py b/test/functional/wallet_simulaterawtx.py index b2da65bdcfff..fbaa26453404 100755 --- a/test/functional/wallet_simulaterawtx.py +++ b/test/functional/wallet_simulaterawtx.py @@ -15,6 +15,9 @@ ) class SimulateTxTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_startup.py b/test/functional/wallet_startup.py index 742a91effe54..1e0c753e4d3a 100755 --- a/test/functional/wallet_startup.py +++ b/test/functional/wallet_startup.py @@ -13,6 +13,9 @@ class WalletStartupTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_timelock.py b/test/functional/wallet_timelock.py index a71cec6607de..57a7c3907ade 100755 --- a/test/functional/wallet_timelock.py +++ b/test/functional/wallet_timelock.py @@ -8,6 +8,9 @@ class WalletLocktimeTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/wallet_transactiontime_rescan.py b/test/functional/wallet_transactiontime_rescan.py index 07602337bd3d..268e623cd90d 100755 --- a/test/functional/wallet_transactiontime_rescan.py +++ b/test/functional/wallet_transactiontime_rescan.py @@ -17,6 +17,9 @@ class TransactionTimeRescanTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.disable_mocktime = True self.setup_clean_chain = False diff --git a/test/functional/wallet_txn_clone.py b/test/functional/wallet_txn_clone.py index 130e5d3b74f7..cc2a2488dfe4 100755 --- a/test/functional/wallet_txn_clone.py +++ b/test/functional/wallet_txn_clone.py @@ -24,6 +24,7 @@ def skip_test_if_missing_module(self): self.skip_if_no_wallet() def add_options(self, parser): + self.add_wallet_options(parser) parser.add_argument("--mineblock", dest="mine_block", default=False, action="store_true", help="Test double-spend of 1-confirmed transaction") diff --git a/test/functional/wallet_txn_doublespend.py b/test/functional/wallet_txn_doublespend.py index a33720a4af3a..c1fce47b728b 100755 --- a/test/functional/wallet_txn_doublespend.py +++ b/test/functional/wallet_txn_doublespend.py @@ -22,6 +22,7 @@ def skip_test_if_missing_module(self): self.skip_if_no_wallet() def add_options(self, parser): + self.add_wallet_options(parser) parser.add_argument("--mineblock", dest="mine_block", default=False, action="store_true", help="Test double-spend of 1-confirmed transaction") diff --git a/test/functional/wallet_upgradewallet.py b/test/functional/wallet_upgradewallet.py index 498834304f70..49c8469a599c 100755 --- a/test/functional/wallet_upgradewallet.py +++ b/test/functional/wallet_upgradewallet.py @@ -26,6 +26,9 @@ UPGRADED_KEYMETA_VERSION = 12 class UpgradeWalletTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser, descriptors=False) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 3 diff --git a/test/functional/wallet_watchonly.py b/test/functional/wallet_watchonly.py index 7532cf9a5b2b..89eaa050baca 100755 --- a/test/functional/wallet_watchonly.py +++ b/test/functional/wallet_watchonly.py @@ -14,6 +14,9 @@ class CreateWalletWatchonlyTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.supports_cli = True From 9533f86e9b17a51300fed31fd7aad05f300259c8 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 5 Jan 2026 16:05:25 +0700 Subject: [PATCH 2/9] fix: apply changes from bitcoin/bitcoin#26480 for dash specific functional tests --- test/functional/feature_addressindex.py | 2 ++ test/functional/feature_asset_locks.py | 3 +++ test/functional/feature_dip3_deterministicmns.py | 3 +++ test/functional/feature_dip3_v19.py | 3 +++ .../feature_dip4_coinbasemerkleroots.py | 3 +++ test/functional/feature_governance.py | 3 +++ test/functional/feature_governance_cl.py | 3 +++ test/functional/feature_governance_objects.py | 3 +++ test/functional/feature_llmq_chainlocks.py | 3 +++ test/functional/feature_llmq_connections.py | 3 +++ test/functional/feature_llmq_data_recovery.py | 3 +++ test/functional/feature_llmq_dkgerrors.py | 3 +++ test/functional/feature_llmq_evo.py | 3 +++ test/functional/feature_llmq_is_cl_conflicts.py | 3 +++ test/functional/feature_llmq_is_retroactive.py | 3 +++ test/functional/feature_llmq_rotation.py | 3 +++ test/functional/feature_llmq_signing.py | 1 + test/functional/feature_llmq_simplepose.py | 1 + test/functional/feature_llmq_singlenode.py | 4 +++- test/functional/feature_masternode_params.py | 16 ++++++++++------ test/functional/feature_mnehf.py | 3 +++ test/functional/feature_spentindex.py | 2 ++ test/functional/feature_txindex.py | 2 ++ test/functional/feature_unsupported_utxo_db.py | 3 +++ test/functional/interface_zmq_dash.py | 3 +++ test/functional/p2p_instantsend.py | 3 +++ test/functional/p2p_platform_ban.py | 3 +++ test/functional/p2p_quorum_data.py | 3 +++ test/functional/rpc_coinjoin.py | 3 +++ test/functional/rpc_fundrawtransaction.py | 4 +--- test/functional/rpc_masternode.py | 3 +++ test/functional/rpc_mnauth.py | 3 +++ test/functional/rpc_net.py | 3 +++ test/functional/rpc_netinfo.py | 3 +++ test/functional/rpc_quorum.py | 3 +++ test/functional/rpc_verifychainlock.py | 3 +++ test/functional/rpc_verifyislock.py | 3 +++ test/functional/rpc_wipewallettxes.py | 3 +++ test/functional/test_framework/test_framework.py | 2 +- test/functional/wallet_change_address.py | 3 +++ test/functional/wallet_conflicts.py | 3 +++ test/functional/wallet_keypool_hd.py | 2 ++ test/functional/wallet_mnemonicbits.py | 3 +++ test/functional/wallet_upgradetohd.py | 3 +++ 44 files changed, 127 insertions(+), 11 deletions(-) diff --git a/test/functional/feature_addressindex.py b/test/functional/feature_addressindex.py index a059ff9f7a73..f30fd81fa391 100755 --- a/test/functional/feature_addressindex.py +++ b/test/functional/feature_addressindex.py @@ -23,6 +23,8 @@ from test_framework.util import assert_equal class AddressIndexTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) def set_test_params(self): self.setup_clean_chain = True diff --git a/test/functional/feature_asset_locks.py b/test/functional/feature_asset_locks.py index d482d1061de4..24d9ccf27277 100755 --- a/test/functional/feature_asset_locks.py +++ b/test/functional/feature_asset_locks.py @@ -50,6 +50,9 @@ HEIGHT_DIFF_EXPIRING = 48 class AssetLocksTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(2, 0, [[ "-whitelist=127.0.0.1", diff --git a/test/functional/feature_dip3_deterministicmns.py b/test/functional/feature_dip3_deterministicmns.py index ac73dd5af055..adbbae30b555 100755 --- a/test/functional/feature_dip3_deterministicmns.py +++ b/test/functional/feature_dip3_deterministicmns.py @@ -20,6 +20,9 @@ from test_framework.util import assert_equal, force_finish_mnsync, p2p_port, softfork_active class DIP3Test(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_initial_mn = 11 # Should be >= 11 to make sure quorums are not always the same MNs self.num_nodes = 1 + self.num_initial_mn + 2 # +1 for controller, +1 for mn-qt, +1 for mn created after dip3 activation diff --git a/test/functional/feature_dip3_v19.py b/test/functional/feature_dip3_v19.py index c72c4dc314e6..1554776aadb4 100755 --- a/test/functional/feature_dip3_v19.py +++ b/test/functional/feature_dip3_v19.py @@ -45,6 +45,9 @@ def getmnlistdiff(self, base_block_hash, block_hash): class DIP3V19Test(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.extra_args = [[ '-deprecatedrpc=legacy_mn', diff --git a/test/functional/feature_dip4_coinbasemerkleroots.py b/test/functional/feature_dip4_coinbasemerkleroots.py index 5b8ec6540340..921f81e8f48b 100755 --- a/test/functional/feature_dip4_coinbasemerkleroots.py +++ b/test/functional/feature_dip4_coinbasemerkleroots.py @@ -47,6 +47,9 @@ def getmnlistdiff(self, baseBlockHash, blockHash): class LLMQCoinbaseCommitmentsTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.extra_args = [[ f'-testactivationheight=dip0008@{DIP0008_HEIGHT}', f'-testactivationheight=dip0024@{DIP0024_HEIGHT}', "-vbparams=testdummy:999999999999:999999999999" ]] * 4 self.set_dash_test_params(4, 3, extra_args = self.extra_args) diff --git a/test/functional/feature_governance.py b/test/functional/feature_governance.py index c57738e7ed87..925ac0b1ccc6 100755 --- a/test/functional/feature_governance.py +++ b/test/functional/feature_governance.py @@ -17,6 +17,9 @@ GOVERNANCE_UPDATE_MIN = 60 * 60 # src/governance/object.h class DashGovernanceTest (DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(6, 5, [[ "-budgetparams=10:10:10", diff --git a/test/functional/feature_governance_cl.py b/test/functional/feature_governance_cl.py index 1db0415abe92..c89dd3c2d020 100755 --- a/test/functional/feature_governance_cl.py +++ b/test/functional/feature_governance_cl.py @@ -12,6 +12,9 @@ from test_framework.util import assert_equal, satoshi_round class DashGovernanceTest (DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(6, 5, [["-budgetparams=10:10:10"]] * 6) diff --git a/test/functional/feature_governance_objects.py b/test/functional/feature_governance_objects.py index 1fe5a9c58539..ea0fccab748e 100755 --- a/test/functional/feature_governance_objects.py +++ b/test/functional/feature_governance_objects.py @@ -22,6 +22,9 @@ def validate_object(prepared, rpc_prepared): assert_equal(prepared["data"], rpc_prepared["data"]) class DashGovernanceTest (DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(2, 1) diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index ea070fb6e867..44861b622dff 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -19,6 +19,9 @@ import time class LLMQChainLocksTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(5, 4) self.delay_v20_and_mn_rr(height=200) diff --git a/test/functional/feature_llmq_connections.py b/test/functional/feature_llmq_connections.py index a9acd24885a4..18a9684e1a12 100755 --- a/test/functional/feature_llmq_connections.py +++ b/test/functional/feature_llmq_connections.py @@ -19,6 +19,9 @@ from test_framework.util import assert_greater_than_or_equal class LLMQConnections(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(15, 14) self.set_dash_llmq_test_params(5, 3) diff --git a/test/functional/feature_llmq_data_recovery.py b/test/functional/feature_llmq_data_recovery.py index 76a92e234027..03ae8fcc5d3d 100755 --- a/test/functional/feature_llmq_data_recovery.py +++ b/test/functional/feature_llmq_data_recovery.py @@ -27,6 +27,9 @@ class QuorumDataRecoveryTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): extra_args = [["-vbparams=testdummy:0:999999999999:0:10:8:6:5:-1"] for _ in range(7)] self.set_dash_test_params(7, 6, extra_args=extra_args) diff --git a/test/functional/feature_llmq_dkgerrors.py b/test/functional/feature_llmq_dkgerrors.py index 187bea3b8bc8..90f7a812fadd 100755 --- a/test/functional/feature_llmq_dkgerrors.py +++ b/test/functional/feature_llmq_dkgerrors.py @@ -22,6 +22,9 @@ ''' class LLMQDKGErrors(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(4, 3, [["-whitelist=127.0.0.1"]] * 4) diff --git a/test/functional/feature_llmq_evo.py b/test/functional/feature_llmq_evo.py index d4551f3ce8fc..2000b01ba219 100755 --- a/test/functional/feature_llmq_evo.py +++ b/test/functional/feature_llmq_evo.py @@ -48,6 +48,9 @@ def getmnlistdiff(self, baseBlockHash, blockHash): return self.last_mnlistdiff class LLMQEvoNodesTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): # we just need a couple of regular nodes to be ensured that they are not included in platform quorum, 2 is enough self.set_dash_test_params(3, 2, evo_count=4) diff --git a/test/functional/feature_llmq_is_cl_conflicts.py b/test/functional/feature_llmq_is_cl_conflicts.py index 4736489cb526..13d984f72e5d 100755 --- a/test/functional/feature_llmq_is_cl_conflicts.py +++ b/test/functional/feature_llmq_is_cl_conflicts.py @@ -48,6 +48,9 @@ def on_getdata(self, message): class LLMQ_IS_CL_Conflicts(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(5, 4) self.set_dash_llmq_test_params(4, 4) diff --git a/test/functional/feature_llmq_is_retroactive.py b/test/functional/feature_llmq_is_retroactive.py index c8454ea72982..42ebc2a75b16 100755 --- a/test/functional/feature_llmq_is_retroactive.py +++ b/test/functional/feature_llmq_is_retroactive.py @@ -20,6 +20,9 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): # -whitelist is needed to avoid the trickling logic on node0 self.set_dash_test_params(5, 4, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"]]) diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index 72820d54eab7..f0e3651ddbf5 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -50,6 +50,9 @@ def getmnlistdiff(self, baseBlockHash, blockHash): return self.last_mnlistdiff class LLMQQuorumRotationTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(9, 8, extra_args=[["-vbparams=testdummy:999999999999:999999999999"]] * 9) self.set_dash_llmq_test_params(4, 4) diff --git a/test/functional/feature_llmq_signing.py b/test/functional/feature_llmq_signing.py index 82782e743cad..d48a4fbbfb7e 100755 --- a/test/functional/feature_llmq_signing.py +++ b/test/functional/feature_llmq_signing.py @@ -26,6 +26,7 @@ def set_test_params(self): self.set_dash_llmq_test_params(5, 3) def add_options(self, parser): + self.add_wallet_options(parser) parser.add_argument("--spork21", dest="spork21", default=False, action="store_true", help="Test with spork21 enabled") diff --git a/test/functional/feature_llmq_simplepose.py b/test/functional/feature_llmq_simplepose.py index 94b85bdb40fa..274e71556cab 100755 --- a/test/functional/feature_llmq_simplepose.py +++ b/test/functional/feature_llmq_simplepose.py @@ -31,6 +31,7 @@ def set_test_params(self): self.delay_v20_and_mn_rr(height=9999) def add_options(self, parser): + self.add_wallet_options(parser) parser.add_argument("--disable-spork23", dest="disable_spork23", default=False, action="store_true", help="Test with spork23 disabled") diff --git a/test/functional/feature_llmq_singlenode.py b/test/functional/feature_llmq_singlenode.py index 70f2b9ae22e5..a84b9a3c8e95 100755 --- a/test/functional/feature_llmq_singlenode.py +++ b/test/functional/feature_llmq_singlenode.py @@ -32,12 +32,14 @@ q_type=100 class LLMQSigningTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(1, 0, [["-llmqtestinstantsenddip0024=llmq_test_instantsend", "-peertimeout=300000000"]], evo_count=2) self.set_dash_llmq_test_params(1, 1) - def mine_single_node_quorum(self): node = self.nodes[0] quorums = node.quorum('list')['llmq_test'] diff --git a/test/functional/feature_masternode_params.py b/test/functional/feature_masternode_params.py index 735ed7a2191c..e53e1fcb18d2 100755 --- a/test/functional/feature_masternode_params.py +++ b/test/functional/feature_masternode_params.py @@ -18,6 +18,9 @@ class MasternodeParamsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 @@ -77,12 +80,13 @@ def run_test(self): self.stop_node(1) # Check debug log for parameter interaction messages during startup - with self.nodes[1].assert_debug_log(["parameter interaction: -masternodeblsprivkey set -> setting -disablewallet=1"]): - self.start_node(1, extra_args=[ - f"-masternodeblsprivkey={bls_key}", - "-peerblockfilters=0", - "-blockfilterindex=0" - ]) + if self.is_wallet_compiled(): + with self.nodes[1].assert_debug_log(["parameter interaction: -masternodeblsprivkey set -> setting -disablewallet=1"]): + self.start_node(1, extra_args=[ + f"-masternodeblsprivkey={bls_key}", + "-peerblockfilters=0", + "-blockfilterindex=0" + ]) # Note: The peerblockfilters and blockfilterindex messages won't be in the log # when explicitly disabled, only when auto-enabled diff --git a/test/functional/feature_mnehf.py b/test/functional/feature_mnehf.py index 836821d86c2f..952ee95ca40e 100755 --- a/test/functional/feature_mnehf.py +++ b/test/functional/feature_mnehf.py @@ -26,6 +26,9 @@ ) class MnehfTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): extra_args = [["-vbparams=testdummy:0:999999999999:0:4:4:4:5:1", "-persistmempool=0"]] * 4 self.set_dash_test_params(4, 3, extra_args=extra_args) diff --git a/test/functional/feature_spentindex.py b/test/functional/feature_spentindex.py index 17f2b1202754..71fd9bb968ad 100755 --- a/test/functional/feature_spentindex.py +++ b/test/functional/feature_spentindex.py @@ -25,6 +25,8 @@ class SpentIndexTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) def set_test_params(self): self.setup_clean_chain = True diff --git a/test/functional/feature_txindex.py b/test/functional/feature_txindex.py index f6366d26f1e1..183d08de93b2 100755 --- a/test/functional/feature_txindex.py +++ b/test/functional/feature_txindex.py @@ -21,6 +21,8 @@ class TxIndexTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) def set_test_params(self): self.setup_clean_chain = True diff --git a/test/functional/feature_unsupported_utxo_db.py b/test/functional/feature_unsupported_utxo_db.py index e57b1567ed54..36f970b36435 100755 --- a/test/functional/feature_unsupported_utxo_db.py +++ b/test/functional/feature_unsupported_utxo_db.py @@ -14,6 +14,9 @@ class UnsupportedUtxoDbTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 diff --git a/test/functional/interface_zmq_dash.py b/test/functional/interface_zmq_dash.py index 510cc636b8cc..f6f42702bc27 100755 --- a/test/functional/interface_zmq_dash.py +++ b/test/functional/interface_zmq_dash.py @@ -105,6 +105,9 @@ def on_getdata(self, message): class DashZMQTest (DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(5, 4) diff --git a/test/functional/p2p_instantsend.py b/test/functional/p2p_instantsend.py index 2d3b2fa2dd4f..3eafe072421a 100755 --- a/test/functional/p2p_instantsend.py +++ b/test/functional/p2p_instantsend.py @@ -13,6 +13,9 @@ ''' class InstantSendTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(8, 4) # set sender, receiver, isolated nodes diff --git a/test/functional/p2p_platform_ban.py b/test/functional/p2p_platform_ban.py index cb9cb362dbf1..bec2f5d0b2ea 100755 --- a/test/functional/p2p_platform_ban.py +++ b/test/functional/p2p_platform_ban.py @@ -19,6 +19,9 @@ def __init__(self): class PlatformBanMessagesTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(1, 0, [[]], evo_count=3) diff --git a/test/functional/p2p_quorum_data.py b/test/functional/p2p_quorum_data.py index a85616ad8aa2..8bc3e781f88e 100755 --- a/test/functional/p2p_quorum_data.py +++ b/test/functional/p2p_quorum_data.py @@ -119,6 +119,9 @@ def get_qdata(self): class QuorumDataMessagesTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): extra_args = [["-llmq-data-recovery=0", "-deprecatedrpc=banscore"]] * 4 self.set_dash_test_params(4, 3, extra_args=extra_args) diff --git a/test/functional/rpc_coinjoin.py b/test/functional/rpc_coinjoin.py index 7fe1a1da0368..578dc1b22c9d 100755 --- a/test/functional/rpc_coinjoin.py +++ b/test/functional/rpc_coinjoin.py @@ -25,6 +25,9 @@ COINJOIN_TARGET_MIN = 2 class CoinJoinTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 400f882c215f..6aa83edd22ac 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -32,9 +32,6 @@ def get_unspent(listunspent, amount): raise AssertionError('Could not find unspent with amount={}'.format(amount)) class RawTransactionsTest(BitcoinTestFramework): - def add_options(self, parser): - self.add_wallet_options(parser) - def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True @@ -46,6 +43,7 @@ def skip_test_if_missing_module(self): self.skip_if_no_wallet() def add_options(self, parser): + self.add_wallet_options(parser) parser.add_argument("--nohd", dest="nohd", default=False, action="store_true", help="Test with -nohd enabled") diff --git a/test/functional/rpc_masternode.py b/test/functional/rpc_masternode.py index fa9799f7a7a8..d15c9e90bb97 100755 --- a/test/functional/rpc_masternode.py +++ b/test/functional/rpc_masternode.py @@ -12,6 +12,9 @@ ''' class RPCMasternodeTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(4, 3) diff --git a/test/functional/rpc_mnauth.py b/test/functional/rpc_mnauth.py index 9e7c0699df79..2e47bbf06cf6 100755 --- a/test/functional/rpc_mnauth.py +++ b/test/functional/rpc_mnauth.py @@ -19,6 +19,9 @@ class FakeMNAUTHTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(2, 1) diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py index b70f1147fb9f..5813ebc3dab5 100755 --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -43,6 +43,9 @@ def assert_net_servicesnames(servicesflag, servicenames): class NetTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(3, 1) self.supports_cli = False diff --git a/test/functional/rpc_netinfo.py b/test/functional/rpc_netinfo.py index 80edba30dc92..fe45b1ca7b31 100755 --- a/test/functional/rpc_netinfo.py +++ b/test/functional/rpc_netinfo.py @@ -149,6 +149,9 @@ def destroy_mn(self, test: BitcoinTestFramework): test.log.debug(f"Destroyed EvoNode with collateral_txid={self.mn.collateral_txid}, collateral_vout={self.mn.collateral_vout}, provider_txid={old_protx_hash}") class NetInfoTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 2 self.extra_args = [[ diff --git a/test/functional/rpc_quorum.py b/test/functional/rpc_quorum.py index 998049cf320b..3dfbd18d8d50 100755 --- a/test/functional/rpc_quorum.py +++ b/test/functional/rpc_quorum.py @@ -15,6 +15,9 @@ ''' class RPCMasternodeTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.set_dash_test_params(4, 3) diff --git a/test/functional/rpc_verifychainlock.py b/test/functional/rpc_verifychainlock.py index 43d9a5565f7f..a3418007f10c 100755 --- a/test/functional/rpc_verifychainlock.py +++ b/test/functional/rpc_verifychainlock.py @@ -17,6 +17,9 @@ class RPCVerifyChainLockTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): # -whitelist is needed to avoid the trickling logic on node0 self.set_dash_test_params(5, 3, [["-whitelist=127.0.0.1"], [], [], [], []]) diff --git a/test/functional/rpc_verifyislock.py b/test/functional/rpc_verifyislock.py index 6dc7078e313a..ad647f7f5648 100755 --- a/test/functional/rpc_verifyislock.py +++ b/test/functional/rpc_verifyislock.py @@ -15,6 +15,9 @@ ''' class RPCVerifyISLockTest(DashTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): # -whitelist is needed to avoid the trickling logic on node0 self.set_dash_test_params(6, 5, [["-whitelist=127.0.0.1"], [], [], [], [], []]) diff --git a/test/functional/rpc_wipewallettxes.py b/test/functional/rpc_wipewallettxes.py index 0a594f6288d7..4dbaa113b2c8 100755 --- a/test/functional/rpc_wipewallettxes.py +++ b/test/functional/rpc_wipewallettxes.py @@ -9,6 +9,9 @@ class WipeWalletTxesTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 70688b689cf0..ec83abde50ff 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1811,7 +1811,7 @@ def setup_nodes(self): self.log.info("Creating and starting %s simple nodes", num_simple_nodes) for i in range(0, num_simple_nodes): self.create_simple_node(self.extra_args) - if self.requires_wallet: + if self._requires_wallet: self.import_deterministic_coinbase_privkeys() required_balance = EVONODE_COLLATERAL * self.evo_count required_balance += MASTERNODE_COLLATERAL * (self.mn_count - self.evo_count) + 100 diff --git a/test/functional/wallet_change_address.py b/test/functional/wallet_change_address.py index a9a4a8696de0..68a4aaca991e 100755 --- a/test/functional/wallet_change_address.py +++ b/test/functional/wallet_change_address.py @@ -14,6 +14,9 @@ class WalletChangeAddressTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 3 diff --git a/test/functional/wallet_conflicts.py b/test/functional/wallet_conflicts.py index 8baba57c2980..802b718cd5e2 100755 --- a/test/functional/wallet_conflicts.py +++ b/test/functional/wallet_conflicts.py @@ -15,6 +15,9 @@ ) class TxConflicts(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 3 diff --git a/test/functional/wallet_keypool_hd.py b/test/functional/wallet_keypool_hd.py index 78f66161c419..cb1b5751ab80 100755 --- a/test/functional/wallet_keypool_hd.py +++ b/test/functional/wallet_keypool_hd.py @@ -15,6 +15,8 @@ from test_framework.util import assert_equal, assert_raises_rpc_error class KeyPoolTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/wallet_mnemonicbits.py b/test/functional/wallet_mnemonicbits.py index 744fee87b8c6..2720d17f7a9a 100755 --- a/test/functional/wallet_mnemonicbits.py +++ b/test/functional/wallet_mnemonicbits.py @@ -11,6 +11,9 @@ ) class WalletMnemonicbitsTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/wallet_upgradetohd.py b/test/functional/wallet_upgradetohd.py index 3fed935df804..fae83ebd99e6 100755 --- a/test/functional/wallet_upgradetohd.py +++ b/test/functional/wallet_upgradetohd.py @@ -20,6 +20,9 @@ class WalletUpgradeToHDTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.num_nodes = 1 self.extra_args = [['-usehd=0']] From 65886256f61474d8abd74a48357b72b83640a895 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 30 Nov 2022 10:22:48 +0100 Subject: [PATCH 3/9] partial Merge bitcoin/bitcoin#26600: test: Set wallet type in test_runner when only one type is allowed BACKPORT NOTE: some tests doesn't exist yet, such as wallet_taproot.py fadb8696dd0f7569e429fb6568a66866d67a2ce6 test: Set wallet type in test_runner when only one type is allowed (MarcoFalke) Pull request description: Currently devs are free to set or not set the wallet type in the test_runner when only one type is allowed to be set. This is inconsistent and causes review comments such as: * https://github.com/bitcoin/bitcoin/pull/24865#discussion_r1009752111 ACKs for top commit: achow101: ACK fadb8696dd0f7569e429fb6568a66866d67a2ce6 Tree-SHA512: 1ca0946df07b5bf6778fea957d74393757781c324d554fec2f7d03bf1915033e644d9a4c3d77e0b24090ab593d7ed3cb3c9169666bc39fff423706fceaa1af80 --- test/functional/test_framework/test_framework.py | 4 +++- test/functional/test_runner.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index ec83abde50ff..e4fe6ec55387 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -499,11 +499,13 @@ def run_test(self): # Public helper methods. These can be accessed by the subclass test scripts. def add_wallet_options(self, parser, *, descriptors=True, legacy=True): - group = parser.add_mutually_exclusive_group() kwargs = {} if descriptors + legacy == 1: # If only one type can be chosen, set it as default kwargs["default"] = descriptors + group = parser.add_mutually_exclusive_group( + # If only one type is allowed, require it to be set in test_runner.py + required=os.getenv("REQUIRE_WALLET_TYPE_SET") == "1" and "default" in kwargs) if descriptors: group.add_argument("--descriptors", action='store_const', const=True, **kwargs, help="Run test using a descriptor wallet", dest='descriptors') diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index fcbc405d2d9b..49c3dafce92e 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -27,6 +27,8 @@ import logging import unittest +os.environ["REQUIRE_WALLET_TYPE_SET"] = "1" + # Formatting. Default colors to empty strings. DEFAULT, BOLD, GREEN, RED = ("", ""), ("", ""), ("", ""), ("", "") try: @@ -185,7 +187,7 @@ 'wallet_avoidreuse.py --legacy-wallet', 'wallet_avoidreuse.py --descriptors', 'mempool_reorg.py', - 'mempool_persist.py', + 'mempool_persist.py --descriptors', 'p2p_block_sync.py --v1transport', 'p2p_block_sync.py --v2transport', 'wallet_multiwallet.py --legacy-wallet', @@ -265,7 +267,7 @@ 'feature_assumevalid.py', 'example_test.py', 'wallet_txn_doublespend.py --legacy-wallet', - 'wallet_multisig_descriptor_psbt.py', + 'wallet_multisig_descriptor_psbt.py --descriptors', 'wallet_txn_doublespend.py --descriptors', 'feature_backwards_compatibility.py --legacy-wallet', 'feature_backwards_compatibility.py --descriptors', From 70155f0ab58ca809860b93db0578b78ef6fac2c9 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 9 Dec 2022 09:25:41 +0100 Subject: [PATCH 4/9] Merge bitcoin/bitcoin#26660: test: Use last release in compatibility tests fabb24cbef6ccccf5e82ac52ca2aafd47c34455a test: Use last release in compatibility tests (MarcoFalke) Pull request description: In compatibility tests it makes sense to always use the last release without the new feature, as it is likely more in use than any even older previous release. ACKs for top commit: Sjors: utACK fabb24c Tree-SHA512: beb854f4d28ba313282e1e0303abb0e09377828b138bde5a3e209337210b6b4c24855ab90a68f8789387001e4ca33b15cc37dbc9b7809929f4e7d1b69833a527 --- test/functional/mempool_compatibility.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/functional/mempool_compatibility.py b/test/functional/mempool_compatibility.py index 7a7a322992e9..11be7e797eca 100755 --- a/test/functional/mempool_compatibility.py +++ b/test/functional/mempool_compatibility.py @@ -7,7 +7,7 @@ NOTE: The test is designed to prevent cases when compatibility is broken accidentally. In case we need to break mempool compatibility we can continue to use the test by just bumping the version number. -The previous release v0.15.0.0 is required by this test, see test/README.md. +Previous releases are required by this test, see test/README.md. """ import os @@ -29,7 +29,7 @@ def skip_test_if_missing_module(self): def setup_network(self): self.add_nodes(self.num_nodes, versions=[ - 18020200, # oldest version with getmempoolinfo.loaded (used to avoid intermittent issues) + 19030000, # Last release with previous mempool format None, ]) self.extra_args = [ @@ -45,6 +45,7 @@ def run_test(self): self.log.info("Test that mempool.dat is compatible between versions") old_node, new_node = self.nodes + assert "unbroadcastcount" not in old_node.getmempoolinfo() new_wallet = MiniWallet(new_node) self.generate(new_wallet, 1, sync_fun=self.no_op) self.generate(new_node, 100, sync_fun=self.no_op) From 32ed7b5ac09d73d8b44c23dc180cd3fc18c4cdea Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 5 Jan 2026 18:03:26 +0700 Subject: [PATCH 5/9] chore: remove unused hashes for v19.1.0 for previous releases (substituted by v19.3.0) --- test/get_previous_releases.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/get_previous_releases.py b/test/get_previous_releases.py index e900c5baeb29..e2985fe9b34e 100755 --- a/test/get_previous_releases.py +++ b/test/get_previous_releases.py @@ -50,12 +50,6 @@ "8a288189bd4b7c23bb1f917256290dd606d9d47a533dcede0c6190a8f4722e1a": {"tag": "v19.3.0", "tarball": "dashcore-19.3.0-win64.zip"}, "c2f3ff5631094abe16af8e476d1197be8685ee20601deda5cad0c34fc879c3de": {"tag": "v19.3.0", "tarball": "dashcore-19.3.0-x86_64-linux-gnu.tar.gz"}, # - "2870149fda49e731fdf67951408e8b9a1f21f4d91693add0287fe6abb7f8e5b4": {"tag": "v19.1.0", "tarball": "dashcore-19.1.0-aarch64-linux-gnu.tar.gz"}, - "900f6209831f1a21be7ed51edd48a6312fdfb8759fac94b77b23d77484254356": {"tag": "v19.1.0", "tarball": "dashcore-19.1.0-osx64.tar.gz"}, - "4ff370e904f08f9b31727535c5ccdde616d7cdee2fb9396aa887910fc87702ff": {"tag": "v19.1.0", "tarball": "dashcore-19.1.0-osx.dmg"}, - "49fb6cc79429cd46e57b9b1197c863dac5ca56a17004596d9cc364f5fcf395f8": {"tag": "v19.1.0", "tarball": "dashcore-19.1.0-riscv64-linux-gnu.tar.gz"}, - "4aad6aedd3b45ae8c5279ad6ee886e7d80a1faa59be9bae882bdd6df68992990": {"tag": "v19.1.0", "tarball": "dashcore-19.1.0-x86_64-linux-gnu.tar.gz"}, - # "d7907726666e9266f5eae830789a1c36cf8c84b43bc0c0fab907317a5cc03f09": {"tag": "v18.2.2", "tarball": "dashcore-18.2.2-aarch64-linux-gnu.tar.gz"}, "b70c5fb7c916f093840b9adb6f0287488843e0e69b403e99ed0bc93d34e24f85": {"tag": "v18.2.2", "tarball": "dashcore-18.2.2-osx.dmg"}, "9b376e99400a3b0cb8e777477cf07567c36ed65018e4becbd98eebfbcca3efee": {"tag": "v18.2.2", "tarball": "dashcore-18.2.2-osx64.tar.gz"}, @@ -322,7 +316,7 @@ def main(args) -> int: help='target directory.', default='releases') all_tags = sorted([*set([v['tag'] for v in SHA256_SUMS.values()])]) parser.add_argument('tags', nargs='*', default=all_tags, - help='release tags. e.g.: v19.1.0 v19.0.0-rc.9 ' + help='release tags. e.g.: v19.3.0 v19.0.0-rc.9 ' '(if not specified, the full list needed for ' 'backwards compatibility tests will be used)' ) From 6604838ebc37c5bd19fc6c2618b2c015f66b6c1f Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 9 Dec 2022 16:33:58 +0100 Subject: [PATCH 6/9] Merge bitcoin/bitcoin#26601: test: Move wallet tests to wallet_*.py fa7d71acccab4e5b416c9dd1e2080a9652107f84 test: Move rpc_fundrawtransaction.py to wallet_fundrawtransaction.py (MarcoFalke) fa933d6985830382c7e2da740bc363bf6a52c4ae test: Move feature_backwards_compatibility.py to wallet_backwards_compatibility.py (MarcoFalke) Pull request description: The tests only tests the wallet and it doesn't make sense to extend it for other stuff, so clarify that. ACKs for top commit: fanquake: ACK fa7d71acccab4e5b416c9dd1e2080a9652107f84 pablomartin4btc: re-ACK https://github.com/bitcoin/bitcoin/commit/fa7d71acccab4e5b416c9dd1e2080a9652107f84 Tree-SHA512: 9dc131ed8ff119bd6d43d04ecc5c96d02f2d6fdc3d0805492774a414c0fbe6a984da7631154122a080c54ddd25fc5a5bdd52b282c918fce4932057ba72c2bf71 --- test/functional/test_framework/test_node.py | 2 +- test/functional/test_runner.py | 10 +++++----- ...patibility.py => wallet_backwards_compatibility.py} | 3 --- ...drawtransaction.py => wallet_fundrawtransaction.py} | 0 4 files changed, 6 insertions(+), 9 deletions(-) rename test/functional/{feature_backwards_compatibility.py => wallet_backwards_compatibility.py} (98%) rename test/functional/{rpc_fundrawtransaction.py => wallet_fundrawtransaction.py} (100%) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 7e7b6fa3b47f..fcff08b46f81 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -380,7 +380,7 @@ def stop_node(self, expected_stderr='', *, wait=0, wait_until_stopped=True): return self.log.debug("Stopping node") try: - # Do not use wait argument when testing older nodes, e.g. in feature_backwards_compatibility.py + # Do not use wait argument when testing older nodes, e.g. in wallet_backwards_compatibility.py if self.version_is_at_least(180000): self.stop(wait=wait) else: diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 49c3dafce92e..d0d47a8a91b2 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -105,9 +105,9 @@ 'mining_getblocktemplate_longpoll.py', # FIXME: "socket.error: [Errno 54] Connection reset by peer" on my Mac, same as https://github.com/bitcoin/bitcoin/issues/6651 'feature_maxuploadtarget.py', 'feature_block.py', # NOTE: needs dash_hash to pass - 'rpc_fundrawtransaction.py --legacy-wallet', - 'rpc_fundrawtransaction.py --legacy-wallet --nohd', - 'rpc_fundrawtransaction.py --descriptors', + 'wallet_fundrawtransaction.py --legacy-wallet', + 'wallet_fundrawtransaction.py --legacy-wallet --nohd', + 'wallet_fundrawtransaction.py --descriptors', 'p2p_quorum_data.py', # vv Tests less than 2m vv 'p2p_instantsend.py', @@ -269,8 +269,8 @@ 'wallet_txn_doublespend.py --legacy-wallet', 'wallet_multisig_descriptor_psbt.py --descriptors', 'wallet_txn_doublespend.py --descriptors', - 'feature_backwards_compatibility.py --legacy-wallet', - 'feature_backwards_compatibility.py --descriptors', + 'wallet_backwards_compatibility.py --legacy-wallet', + 'wallet_backwards_compatibility.py --descriptors', 'wallet_txn_clone.py --mineblock', 'rpc_getblockfilter.py', 'rpc_getblockfrompeer.py', diff --git a/test/functional/feature_backwards_compatibility.py b/test/functional/wallet_backwards_compatibility.py similarity index 98% rename from test/functional/feature_backwards_compatibility.py rename to test/functional/wallet_backwards_compatibility.py index de1e330a1c83..e2866ad1ebe1 100755 --- a/test/functional/feature_backwards_compatibility.py +++ b/test/functional/wallet_backwards_compatibility.py @@ -7,9 +7,6 @@ Test various backwards compatibility scenarios. Requires previous releases binaries, see test/README.md. -v0.15.0.0 is not required by this test, but it is used in wallet_upgradewallet.py. -Due to a hardfork in regtest, it can't be used to sync nodes. - Due to RPC changes introduced in various versions the below tests won't work for older versions without some patches or workarounds. diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/wallet_fundrawtransaction.py similarity index 100% rename from test/functional/rpc_fundrawtransaction.py rename to test/functional/wallet_fundrawtransaction.py From ad98049854fbe26774c7a54d0d03febe2756c6fa Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 14 Dec 2022 09:15:58 +0100 Subject: [PATCH 7/9] Merge bitcoin/bitcoin#26689: test: add add_wallet_options to TestShell bcb71234065e525e9f3cccceaaab320f2ec3741b test: add add_wallet_options to TestShell (josibake) Pull request description: following https://github.com/bitcoin/bitcoin/pull/26480/commits/555519d082fbe5e047595f06d7f301e441bb7149, `TestShell` now always runs with `-disablewallet`. simple fix is to add `add_wallet_options` to `add_options`; looks like testshell was overlooked when adding in the `add_wallet_options` call to the functional tests in #26480 ACKs for top commit: amitiuttarwar: ACK bcb71234065e525e9f3cccceaaab320f2ec3741b Tree-SHA512: db554a8b3c8ff5bd10cab9592b316035a92f86a0a0ae8ff914de9687bbbb6fc2235bdf82c4cd40e4071782f8b6edf91aad372e82ed3b826c9d8ae39dbe3dbf57 --- test/functional/test_framework/test_shell.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/functional/test_framework/test_shell.py b/test/functional/test_framework/test_shell.py index 26df128f1fe4..2d8935dfe6de 100644 --- a/test/functional/test_framework/test_shell.py +++ b/test/functional/test_framework/test_shell.py @@ -16,6 +16,9 @@ class TestShell: start a single TestShell at a time.""" class __TestShell(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): pass From 88913fb47972aba701a9b6536a382a9f19b216a8 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 3 Jan 2023 22:08:39 +0100 Subject: [PATCH 8/9] Merge bitcoin/bitcoin#26257: script, test: python linter flake8 E275 fixup, update dependencies 1e5e87cec32260a6dfd03f11040aed8b7bb4064e script: update python linter dependencies (Jon Atack) 459cb637aca80f744a8399e84bc78fab60de0b5c script, test: fix python linter E275 errors with flake8 5.0.4 (Jon Atack) Pull request description: It is helpful to be able to run the python linter locally to review PRs and check local diffs and work. Fix the errors raised by `./test/lint/lint-python.py` when run locally with flake8 5.0.4, which enforces rule E275 more strictly than previous versions, and update our python linter CI dependencies. ACKs for top commit: kristapsk: ACK 1e5e87cec32260a6dfd03f11040aed8b7bb4064e Tree-SHA512: c7da09396144b9fed4ce6405c0763b2e3e5651d49a5220b053da465aceca09f754fb70a8ab9647278ce2028dde803bea461a3cd93fb39868ead39d06187cd8af --- ci/lint/04_install.sh | 5 +++-- contrib/containers/ci/ci-slim.Dockerfile | 5 +++-- contrib/linearize/linearize-hashes.py | 2 +- contrib/seeds/generate-seeds.py | 4 ++-- test/functional/feature_coinstatsindex.py | 6 +++--- test/functional/feature_index_prune.py | 6 +++--- test/functional/interface_usdt_utxocache.py | 4 ++-- test/functional/interface_usdt_validation.py | 2 +- test/functional/mocks/invalid_signer.py | 2 +- test/functional/mocks/signer.py | 2 +- test/functional/p2p_addr_relay.py | 2 +- test/functional/p2p_blocksonly.py | 2 +- test/functional/p2p_getaddr_caching.py | 14 +++++++------- test/functional/p2p_message_capture.py | 4 ++-- test/functional/rpc_blockchain.py | 2 +- test/functional/test_framework/crypto/siphash.py | 4 ++-- test/functional/test_framework/key.py | 8 ++++---- test/functional/wallet_avoidreuse.py | 2 +- test/functional/wallet_importdescriptors.py | 4 ++-- test/functional/wallet_reorgsrestore.py | 4 ++-- test/functional/wallet_send.py | 4 ++-- test/functional/wallet_signer.py | 6 +++--- 22 files changed, 48 insertions(+), 46 deletions(-) diff --git a/ci/lint/04_install.sh b/ci/lint/04_install.sh index b6f67f5cf468..de46380242b1 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/04_install.sh @@ -33,9 +33,10 @@ if [ -z "${SKIP_PYTHON_INSTALL}" ]; then python3 --version fi +# NOTE: BUMP ALSO contrib/containers/ci//ci-slim.Dockerfile ${CI_RETRY_EXE} pip3 install codespell==2.2.1 -${CI_RETRY_EXE} pip3 install flake8==4.0.1 -${CI_RETRY_EXE} pip3 install lief==0.13.1 +${CI_RETRY_EXE} pip3 install flake8==5.0.4 +${CI_RETRY_EXE} pip3 install lief==0.13.2 ${CI_RETRY_EXE} pip3 install mypy==0.981 ${CI_RETRY_EXE} pip3 install pyzmq==24.0.1 ${CI_RETRY_EXE} pip3 install vulture==2.6 diff --git a/contrib/containers/ci/ci-slim.Dockerfile b/contrib/containers/ci/ci-slim.Dockerfile index 82c5e96f8029..8dba44625927 100644 --- a/contrib/containers/ci/ci-slim.Dockerfile +++ b/contrib/containers/ci/ci-slim.Dockerfile @@ -75,9 +75,10 @@ RUN set -ex; \ ENV UV_SYSTEM_PYTHON=1 # Install Python packages +# NOTE: if versions are changed, update ci/lint/04_install.sh RUN uv pip install --system --break-system-packages \ - codespell==2.1.0 \ - flake8==4.0.1 \ + codespell==2.2.1 \ + flake8==5.0.4 \ jinja2 \ lief==0.13.2 \ multiprocess \ diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py index 94571cd9616c..2e53d6e6e052 100755 --- a/contrib/linearize/linearize-hashes.py +++ b/contrib/linearize/linearize-hashes.py @@ -78,7 +78,7 @@ def get_block_hashes(settings, max_blocks_per_call=10000): if rpc.response_is_error(resp_obj): print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr) sys.exit(1) - assert(resp_obj['id'] == x) # assume replies are in-sequence + assert resp_obj['id'] == x # assume replies are in-sequence if settings['rev_hash_bytes'] == 'true': resp_obj['result'] = bytes.fromhex(resp_obj['result'])[::-1].hex() print(resp_obj['result']) diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index c35827ed5d78..2d92718ba73f 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -63,13 +63,13 @@ def name_to_bip155(addr): if i == 0 or i == (len(addr)-1): # skip empty component at beginning or end continue x += 1 # :: skips to suffix - assert(x < 2) + assert x < 2 else: # two bytes per component val = int(comp, 16) sub[x].append(val >> 8) sub[x].append(val & 0xff) nullbytes = 16 - len(sub[0]) - len(sub[1]) - assert((x == 0 and nullbytes == 0) or (x == 1 and nullbytes > 0)) + assert (x == 0 and nullbytes == 0) or (x == 1 and nullbytes > 0) addr_bytes = bytes(sub[0] + ([0] * nullbytes) + sub[1]) if addr_bytes[0] == 0xfc: # Assume that seeds with fc00::/8 addresses belong to CJDNS, diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py index 48f4d12bf32d..cad3bc886a2a 100755 --- a/test/functional/feature_coinstatsindex.py +++ b/test/functional/feature_coinstatsindex.py @@ -236,7 +236,7 @@ def _test_coin_stats_index(self): self.generate(index_node, 1, sync_fun=self.no_op) res10 = index_node.gettxoutsetinfo('muhash') - assert(res8['txouts'] < res10['txouts']) + assert res8['txouts'] < res10['txouts'] self.log.info("Test that the index works with -reindex") @@ -286,12 +286,12 @@ def _test_reorg_index(self): res2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=112) assert_equal(res["bestblock"], block) assert_equal(res["muhash"], res2["muhash"]) - assert(res["muhash"] != res_invalid["muhash"]) + assert res["muhash"] != res_invalid["muhash"] # Test that requesting reorged out block by hash is still returning correct results res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=reorg_block) assert_equal(res_invalid2["muhash"], res_invalid["muhash"]) - assert(res["muhash"] != res_invalid2["muhash"]) + assert res["muhash"] != res_invalid2["muhash"] # Add another block, so we don't depend on reconsiderblock remembering which # blocks were touched by invalidateblock diff --git a/test/functional/feature_index_prune.py b/test/functional/feature_index_prune.py index 1f39a0dd327b..7cb0dac0d469 100755 --- a/test/functional/feature_index_prune.py +++ b/test/functional/feature_index_prune.py @@ -67,7 +67,7 @@ def run_test(self): for node in filter_nodes: assert_greater_than(len(node.getblockfilter(tip)['filter']), 0) for node in stats_nodes: - assert(node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash']) + assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash'] self.mine_batches(500) self.sync_index(height=700) @@ -85,14 +85,14 @@ def run_test(self): for node in filter_nodes: assert_greater_than(len(node.getblockfilter(tip)['filter']), 0) for node in stats_nodes: - assert(node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash']) + assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=tip)['muhash'] self.log.info("check if we can access the blockfilter and coinstats of a pruned block") height_hash = self.nodes[0].getblockhash(2) for node in filter_nodes: assert_greater_than(len(node.getblockfilter(height_hash)['filter']), 0) for node in stats_nodes: - assert(node.gettxoutsetinfo(hash_type="muhash", hash_or_height=height_hash)['muhash']) + assert node.gettxoutsetinfo(hash_type="muhash", hash_or_height=height_hash)['muhash'] # mine and sync index up to a height that will later be the pruneheight self.generate(self.nodes[0], 51) diff --git a/test/functional/interface_usdt_utxocache.py b/test/functional/interface_usdt_utxocache.py index 76bddc392ac9..1d343c6007f7 100755 --- a/test/functional/interface_usdt_utxocache.py +++ b/test/functional/interface_usdt_utxocache.py @@ -368,8 +368,8 @@ def handle_utxocache_flush(_, data, __): assert_equal(expected["mode"], FLUSHMODE_NAME[event.mode]) possible_cache_sizes.remove(event.size) # fails if size not in set # sanity checks only - assert(event.memory > 0) - assert(event.duration > 0) + assert event.memory > 0 + assert event.duration > 0 handle_flush_succeeds += 1 bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush) diff --git a/test/functional/interface_usdt_validation.py b/test/functional/interface_usdt_validation.py index 0fe56abe0d51..b309da8518e6 100755 --- a/test/functional/interface_usdt_validation.py +++ b/test/functional/interface_usdt_validation.py @@ -109,7 +109,7 @@ def handle_blockconnected(_, data, __): assert_equal(len([tx["vin"] for tx in block["tx"]]), event.inputs) assert_equal(0, event.sigops) # no sigops in coinbase tx # only plausibility checks - assert(event.duration > 0) + assert event.duration > 0 del expected_blocks[block_hash] blocks_checked += 1 diff --git a/test/functional/mocks/invalid_signer.py b/test/functional/mocks/invalid_signer.py index d3523e443950..b46c71e5836c 100755 --- a/test/functional/mocks/invalid_signer.py +++ b/test/functional/mocks/invalid_signer.py @@ -10,7 +10,7 @@ def perform_pre_checks(): mock_result_path = os.path.join(os.getcwd(), "mock_result") - if(os.path.isfile(mock_result_path)): + if os.path.isfile(mock_result_path): with open(mock_result_path, "r", encoding="utf8") as f: mock_result = f.read() if mock_result[0]: diff --git a/test/functional/mocks/signer.py b/test/functional/mocks/signer.py index 727b66484498..8cfabd2a47b7 100755 --- a/test/functional/mocks/signer.py +++ b/test/functional/mocks/signer.py @@ -10,7 +10,7 @@ def perform_pre_checks(): mock_result_path = os.path.join(os.getcwd(), "mock_result") - if(os.path.isfile(mock_result_path)): + if os.path.isfile(mock_result_path): with open(mock_result_path, "r", encoding="utf8") as f: mock_result = f.read() if mock_result[0]: diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 083f3ef4f1b2..f36cdb3061eb 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -48,7 +48,7 @@ def __init__(self, test_addr_contents=False, send_getaddr=True): def on_addr(self, message): for addr in message.addrs: self.num_ipv4_received += 1 - if(self.test_addr_contents): + if self.test_addr_contents: # relay_tests checks the content of the addr messages match # expectations based on the message creation in setup_addr_msg assert_equal(addr.nServices, 2049) diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py index 3018a598190a..28bdb3e05d0e 100755 --- a/test/functional/p2p_blocksonly.py +++ b/test/functional/p2p_blocksonly.py @@ -105,7 +105,7 @@ def blocks_relay_conn_tests(self): self.nodes[0].setmocktime(int(time.time()) + 60) conn.sync_send_with_ping() - assert(int(txid, 16) not in conn.get_invs()) + assert int(txid, 16) not in conn.get_invs() def check_p2p_inv_violation(self, peer): self.log.info("Check that tx-invs from P2P are rejected and result in disconnect") diff --git a/test/functional/p2p_getaddr_caching.py b/test/functional/p2p_getaddr_caching.py index 58f8040918ab..a0f2eb55bc86 100755 --- a/test/functional/p2p_getaddr_caching.py +++ b/test/functional/p2p_getaddr_caching.py @@ -58,7 +58,7 @@ def run_test(self): # Need to make sure we hit MAX_ADDR_TO_SEND records in the addr response later because # only a fraction of all known addresses can be cached and returned. - assert(len(self.nodes[0].getnodeaddresses(0)) > int(MAX_ADDR_TO_SEND / (MAX_PCT_ADDR_TO_SEND / 100))) + assert len(self.nodes[0].getnodeaddresses(0)) > int(MAX_ADDR_TO_SEND / (MAX_PCT_ADDR_TO_SEND / 100)) last_response_on_local_bind = None last_response_on_onion_bind1 = None @@ -83,9 +83,9 @@ def run_test(self): if i > 0: # Responses from different binds should be unique - assert(last_response_on_local_bind != addr_receiver_onion1.get_received_addrs()) - assert(last_response_on_local_bind != addr_receiver_onion2.get_received_addrs()) - assert(last_response_on_onion_bind1 != addr_receiver_onion2.get_received_addrs()) + assert last_response_on_local_bind != addr_receiver_onion1.get_received_addrs() + assert last_response_on_local_bind != addr_receiver_onion2.get_received_addrs() + assert last_response_on_onion_bind1 != addr_receiver_onion2.get_received_addrs() # Responses on from the same bind should be the same assert_equal(last_response_on_local_bind, addr_receiver_local.get_received_addrs()) assert_equal(last_response_on_onion_bind1, addr_receiver_onion1.get_received_addrs()) @@ -117,9 +117,9 @@ def run_test(self): addr_receiver_onion2.wait_until(addr_receiver_onion2.addr_received) # new response is different - assert(set(last_response_on_local_bind) != set(addr_receiver_local.get_received_addrs())) - assert(set(last_response_on_onion_bind1) != set(addr_receiver_onion1.get_received_addrs())) - assert(set(last_response_on_onion_bind2) != set(addr_receiver_onion2.get_received_addrs())) + assert set(last_response_on_local_bind) != set(addr_receiver_local.get_received_addrs()) + assert set(last_response_on_onion_bind1) != set(addr_receiver_onion1.get_received_addrs()) + assert set(last_response_on_onion_bind2) != set(addr_receiver_onion2.get_received_addrs()) if __name__ == '__main__': AddrTest().main() diff --git a/test/functional/p2p_message_capture.py b/test/functional/p2p_message_capture.py index 8a3861dce6c1..90971ad56908 100755 --- a/test/functional/p2p_message_capture.py +++ b/test/functional/p2p_message_capture.py @@ -36,7 +36,7 @@ def mini_parser(dat_file): """ with open(dat_file, 'rb') as f_in: # This should have at least one message in it - assert(os.fstat(f_in.fileno()).st_size >= TIME_SIZE + LENGTH_SIZE + MSGTYPE_SIZE) + assert os.fstat(f_in.fileno()).st_size >= TIME_SIZE + LENGTH_SIZE + MSGTYPE_SIZE while True: tmp_header_raw = f_in.read(TIME_SIZE + LENGTH_SIZE + MSGTYPE_SIZE) if not tmp_header_raw: @@ -44,7 +44,7 @@ def mini_parser(dat_file): tmp_header = BytesIO(tmp_header_raw) tmp_header.read(TIME_SIZE) # skip the timestamp field msgtype = tmp_header.read(MSGTYPE_SIZE).rstrip(b'\x00') - assert(msgtype in MESSAGEMAP) + assert msgtype in MESSAGEMAP length: int = int.from_bytes(tmp_header.read(LENGTH_SIZE), "little") data = f_in.read(length) assert_equal(len(data), length) diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 87b588fdd025..2f74a60003ba 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -363,7 +363,7 @@ def _test_gettxoutsetinfo(self): # hash_type muhash should return a different UTXO set hash. res6 = node.gettxoutsetinfo(hash_type='muhash') assert 'muhash' in res6 - assert(res['hash_serialized_2'] != res6['muhash']) + assert res['hash_serialized_2'] != res6['muhash'] # muhash should not be returned unless requested. for r in [res, res2, res3, res4, res5]: diff --git a/test/functional/test_framework/crypto/siphash.py b/test/functional/test_framework/crypto/siphash.py index 5ad245cf1b15..884dbcab4694 100644 --- a/test/functional/test_framework/crypto/siphash.py +++ b/test/functional/test_framework/crypto/siphash.py @@ -31,7 +31,7 @@ def siphash_round(v0, v1, v2, v3): def siphash(k0, k1, data): - assert(type(data) == bytes) + assert type(data) == bytes v0 = 0x736f6d6570736575 ^ k0 v1 = 0x646f72616e646f6d ^ k1 v2 = 0x6c7967656e657261 ^ k0 @@ -61,5 +61,5 @@ def siphash(k0, k1, data): def siphash256(k0, k1, num): - assert(type(num) == int) + assert type(num) == int return siphash(k0, k1, num.to_bytes(32, 'little')) diff --git a/test/functional/test_framework/key.py b/test/functional/test_framework/key.py index 4a3973f36d83..c0fd494ca6a6 100644 --- a/test/functional/test_framework/key.py +++ b/test/functional/test_framework/key.py @@ -129,7 +129,7 @@ def __init__(self): def set(self, secret, compressed): """Construct a private key object with given 32-byte secret and compressed flag.""" - assert(len(secret) == 32) + assert len(secret) == 32 secret = int.from_bytes(secret, 'big') self.valid = (secret > 0 and secret < ORDER) if self.valid: @@ -142,7 +142,7 @@ def generate(self, compressed=True): def get_bytes(self): """Retrieve the 32-byte representation of this key.""" - assert(self.valid) + assert self.valid return self.secret.to_bytes(32, 'big') @property @@ -155,7 +155,7 @@ def is_compressed(self): def get_pubkey(self): """Compute an ECPubKey object for this secret key.""" - assert(self.valid) + assert self.valid ret = ECPubKey() ret.p = self.secret * secp256k1.G ret.compressed = self.compressed @@ -166,7 +166,7 @@ def sign_ecdsa(self, msg, low_s=True, rfc6979=False): See https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm for the ECDSA signer algorithm.""" - assert(self.valid) + assert self.valid z = int.from_bytes(msg, 'big') # Note: no RFC6979 by default, but a simple random nonce (some tests rely on distinct transactions for the same operation) if rfc6979: diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index 38864cba1ed3..0d25df114ca0 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -192,7 +192,7 @@ def test_sending_from_reused_address_without_avoid_reuse(self): # getbalances should show no used, 10 btc trusted assert_balances(self.nodes[1], mine={"used": 0, "trusted": 10}) # node 0 should not show a used entry, as it does not enable avoid_reuse - assert("used" not in self.nodes[0].getbalances()["mine"]) + assert "used" not in self.nodes[0].getbalances()["mine"] self.nodes[1].sendtoaddress(retaddr, 5) self.generate(self.nodes[0], 1) diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py index 0d24c2565e8a..a5d69c06f77d 100755 --- a/test/functional/wallet_importdescriptors.py +++ b/test/functional/wallet_importdescriptors.py @@ -458,8 +458,8 @@ def run_test(self): assert_equal(addr, '91cA4fLGaDCr6b9W2c5j1ph9PDpq9WbEhk') # Derived at m/84'/0'/0'/1 change_addr = wmulti_pub.getrawchangeaddress() # uses receive 2 assert_equal(change_addr, '8y2sLiPQnB81bAeiRvwbjozJXnCCNH2nHb') - assert(send_txid in self.nodes[0].getrawmempool(True)) - assert(send_txid in (x['txid'] for x in wmulti_pub.listunspent(0))) + assert send_txid in self.nodes[0].getrawmempool(True) + assert send_txid in (x['txid'] for x in wmulti_pub.listunspent(0)) assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 999) # generate some utxos for next tests diff --git a/test/functional/wallet_reorgsrestore.py b/test/functional/wallet_reorgsrestore.py index 07a4f6b03d0f..32104d78b134 100755 --- a/test/functional/wallet_reorgsrestore.py +++ b/test/functional/wallet_reorgsrestore.py @@ -94,11 +94,11 @@ def run_test(self): tx_after_reorg = self.nodes[1].gettransaction(txid) # Check that normal confirmed tx is confirmed again but with different blockhash assert_equal(tx_after_reorg["confirmations"], 2) - assert(tx_before_reorg["blockhash"] != tx_after_reorg["blockhash"]) + assert tx_before_reorg["blockhash"] != tx_after_reorg["blockhash"] conflicted_after_reorg = self.nodes[1].gettransaction(conflicted_txid) # Check that conflicted tx is confirmed again with blockhash different than previously conflicting tx assert_equal(conflicted_after_reorg["confirmations"], 1) - assert(conflicting["blockhash"] != conflicted_after_reorg["blockhash"]) + assert conflicting["blockhash"] != conflicted_after_reorg["blockhash"] if __name__ == '__main__': ReorgsRestoreTest().main() diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py index cdc3ef3ee082..289fa5468fe1 100755 --- a/test/functional/wallet_send.py +++ b/test/functional/wallet_send.py @@ -267,11 +267,11 @@ def run_test(self): self.log.info("Don't broadcast...") res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, add_to_wallet=False) - assert(res["hex"]) + assert res["hex"] self.log.info("Return PSBT...") res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, psbt=True) - assert(res["psbt"]) + assert res["psbt"] self.log.info("Create transaction that spends to address, but don't broadcast...") self.test_send(from_wallet=w0, to_wallet=w1, amount=1, add_to_wallet=False) diff --git a/test/functional/wallet_signer.py b/test/functional/wallet_signer.py index c3e09b06d290..d42c2fa1839f 100755 --- a/test/functional/wallet_signer.py +++ b/test/functional/wallet_signer.py @@ -150,7 +150,7 @@ def test_valid_signer(self): mock_psbt_signed = mock_wallet.walletprocesspsbt(psbt=mock_psbt, sign=True, sighashtype="ALL", bip32derivs=True) mock_psbt_final = mock_wallet.finalizepsbt(mock_psbt_signed["psbt"]) mock_tx = mock_psbt_final["hex"] - assert(mock_wallet.testmempoolaccept([mock_tx])[0]["allowed"]) + assert mock_wallet.testmempoolaccept([mock_tx])[0]["allowed"] # # Create a new wallet and populate with specific public keys, in order # # to work with the mock signed PSBT. @@ -179,7 +179,7 @@ def test_valid_signer(self): # assert_equal(result[1], {'success': True}) assert_equal(hww.getwalletinfo()["txcount"], 1) - assert(hww.testmempoolaccept([mock_tx])[0]["allowed"]) + assert hww.testmempoolaccept([mock_tx])[0]["allowed"] with open(os.path.join(self.nodes[1].cwd, "mock_psbt"), "w", encoding="utf8") as f: f.write(mock_psbt_signed["psbt"]) @@ -187,7 +187,7 @@ def test_valid_signer(self): self.log.info('Test send using hww1') res = hww.send(outputs={dest:0.5},options={"add_to_wallet": False}) - assert(res["complete"]) + assert res["complete"] assert_equal(res["hex"], mock_tx) # # Handle error thrown by script From b4f82b334dfe8fe31f50d9f44f77e877d791b047 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 4 Jan 2023 13:53:19 +0100 Subject: [PATCH 9/9] Merge bitcoin/bitcoin#26802: test: Use same Python executable for subprocesses as for `all-lint.py` f6eadaa413f20c1853cf1bea5141560cd5e4b15a Use same Python executable for subprocesses as for all-lint.py (Kristaps Kaupe) Pull request description: Before this all linters were ran by `/usr/bin/env python3`, no matter what was used to run `test/lint/all-lint.py`. This change allows to use non-default Python executable for `test/lint/all-lint.py` and then all subprocesses will also use same Python interpreter (for example, `python3.10 ./test/lint/all-lint.py`). See https://github.com/bitcoin/bitcoin/issues/26792#issuecomment-1369558866 as use case. ACKs for top commit: fanquake: ACK f6eadaa413f20c1853cf1bea5141560cd5e4b15a - did not test Tree-SHA512: 4da3b5581a0dd8ab9a6387829495019091a93a7ceaf2135d65d40a1983fd11a0b92b20891ef30d2a132abb0a690cd9b2f7eb5fcc38df06a340394ef449d640af --- test/lint/all-lint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lint/all-lint.py b/test/lint/all-lint.py index e8d7299f2a1d..9d987a0a7980 100755 --- a/test/lint/all-lint.py +++ b/test/lint/all-lint.py @@ -12,6 +12,7 @@ from pathlib import Path from shutil import which from subprocess import run +from sys import executable exit_code = 0 mod_path = Path(__file__).parent @@ -28,7 +29,7 @@ remove(logfile) else: for lint in lints: - result = run([lint]) + result = run([executable, lint]) if result.returncode != 0: print(f"^---- failure generated from {lint.split('/')[-1]}") exit_code |= result.returncode