Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_config_args.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017-2019 The Bitcoin Core developers | # Copyright (c) 2017-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test various command line arguments and configuration file parameters.""" | """Test various command line arguments and configuration file parameters.""" | ||||
import os | import os | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
class ConfArgsTest(BitcoinTestFramework): | class ConfArgsTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
def skip_test_if_missing_module(self): | |||||
self.skip_if_no_wallet() | |||||
def test_config_file_parser(self): | def test_config_file_parser(self): | ||||
# Assume node is stopped | # Assume node is stopped | ||||
inc_conf_file_path = os.path.join( | inc_conf_file_path = os.path.join( | ||||
self.nodes[0].datadir, 'include.conf') | self.nodes[0].datadir, 'include.conf') | ||||
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf: | with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf: | ||||
conf.write('includeconf={}\n'.format(inc_conf_file_path)) | conf.write('includeconf={}\n'.format(inc_conf_file_path)) | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert os.path.exists(os.path.join( | assert os.path.exists(os.path.join( | ||||
new_data_dir, 'regtest', 'wallets', 'w1')) | new_data_dir, 'regtest', 'wallets', 'w1')) | ||||
# Ensure command line argument overrides datadir in conf | # Ensure command line argument overrides datadir in conf | ||||
os.mkdir(new_data_dir_2) | os.mkdir(new_data_dir_2) | ||||
self.nodes[0].datadir = new_data_dir_2 | self.nodes[0].datadir = new_data_dir_2 | ||||
self.start_node(0, ['-datadir=' + new_data_dir_2, | self.start_node(0, ['-datadir=' + new_data_dir_2, | ||||
'-conf=' + conf_file, '-wallet=w2']) | '-conf=' + conf_file, '-wallet=w2']) | ||||
assert os.path.exists(os.path.join( | assert os.path.exists( | ||||
new_data_dir_2, 'regtest', 'wallets', 'w2')) | os.path.join( | ||||
new_data_dir_2, | |||||
'regtest', | |||||
'blocks')) | |||||
if self.is_wallet_compiled(): | |||||
assert os.path.exists( | |||||
os.path.join( | |||||
new_data_dir_2, | |||||
'regtest', | |||||
'wallets', | |||||
'w2')) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ConfArgsTest().main() | ConfArgsTest().main() |