Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
501node.args = node_args503def test_acceptstalefeeestimates_arg_support(self):504self.log.info("Test -acceptstalefeeestimates option support")505conf_file = self.nodes[0].datadir_path / "bitcoin.conf"506for chain, chain_name in {("main", ""), ("test", "testnet3"), ("signet", "signet"), ("testnet4", "testnet4")}:507util.write_config(conf_file, n=0, chain=chain_name, extra_config='acceptstalefeeestimates=1\n')508self.nodes[0].assert_start_raises_init_error(expected_msg=f'Error: acceptstalefeeestimates is not supported on {chain} chain.')509util.write_config(conf_file, n=0, chain="regtest") # Reset to regtest511def test_testnet3_deprecation_msg(self):512self.log.info("Test testnet3 deprecation warning")513t3_warning_log = "Warning: Support for testnet3 is deprecated and will be removed in an upcoming release. Consider switching to testnet4."515self.log.debug("Testnet3 node will log the deprecation warning")516self.nodes[0].chain = 'testnet3'517self.nodes[0].replace_in_config([('regtest=', 'testnet='), ('[regtest]', '[test]')])518with self.nodes[0].assert_debug_log([t3_warning_log]):519self.start_node(0)520self.stop_node(0)522self.log.debug("Testnet4 node will not log the deprecation warning")523self.nodes[0].chain = 'testnet4'524self.nodes[0].replace_in_config([('testnet=', 'testnet4='), ('[test]', '[testnet4]')])525with self.nodes[0].assert_debug_log([], unexpected_msgs=[t3_warning_log]):526self.start_node(0)527self.stop_node(0)529self.log.debug("Reset to regtest")530self.nodes[0].chain = 'regtest'531self.nodes[0].replace_in_config([('testnet4=', 'regtest='), ('[testnet4]', '[regtest]')])533def run_test(self):534self.test_log_buffer()535self.test_args_log()536self.test_empty_addnode()537self.test_seed_peers()538self.test_networkactive()539self.test_connect_with_seednode()540self.test_privatebroadcast()542self.test_dir_config()543self.test_negated_config()544self.test_config_file_parser()545self.test_config_file_log()546self.test_invalid_command_line_options()547self.test_ignored_conf()548self.test_ignored_default_conf()549self.test_acceptstalefeeestimates_arg_support()550self.test_testnet3_deprecation_msg()552# Remove the -datadir argument so it doesn't override the config file553self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]555default_data_dir = self.nodes[0].datadir_path556new_data_dir = default_data_dir / 'newdatadir'557new_data_dir_2 = default_data_dir / 'newdatadir2'559# Check that using -datadir argument on non-existent directory fails560self.nodes[0].datadir_path = new_data_dir561self.nodes[0].assert_start_raises_init_error([f'-datadir={new_data_dir}'], f'Error: Specified data directory "{new_data_dir}" does not exist.')563# Check that using non-existent datadir in conf file fails564conf_file = default_data_dir / "bitcoin.conf"566# datadir needs to be set before [chain] section567with open(conf_file) as f:568conf_file_contents = f.read()569with open(conf_file, 'w') as f:570f.write(f"datadir={new_data_dir}\n")571f.write(conf_file_contents)573self.nodes[0].assert_start_raises_init_error([f'-conf={conf_file}'], f'Error: Error reading configuration file: specified data directory "{new_data_dir}" does not exist.')575# Check that an explicitly specified config file that cannot be opened fails576none_existent_conf_file = default_data_dir / "none_existent_bitcoin.conf"577self.nodes[0].assert_start_raises_init_error(['-conf=' + f'{none_existent_conf_file}'], 'Error: Error reading configuration file: specified config file "' + f'{none_existent_conf_file}' + '" could not be opened.')579# Create the directory and ensure the config file now works580new_data_dir.mkdir()581self.start_node(0, [f'-conf={conf_file}'])582self.stop_node(0)583assert (new_data_dir / self.chain / 'blocks').exists()585# Ensure command line argument overrides datadir in conf586new_data_dir_2.mkdir()587self.nodes[0].datadir_path = new_data_dir_2588self.start_node(0, [f'-datadir={new_data_dir_2}', f'-conf={conf_file}'])589assert (new_data_dir_2 / self.chain / 'blocks').exists()592if __name__ == '__main__':593ConfArgsTest(__file__).main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.