Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_config_args.py
Show All 27 Lines | def run_test(self): | ||||
# Check that using -datadir argument on non-existent directory fails | # Check that using -datadir argument on non-existent directory fails | ||||
self.nodes[0].datadir = new_data_dir | self.nodes[0].datadir = new_data_dir | ||||
self.assert_start_raises_init_error( | self.assert_start_raises_init_error( | ||||
0, ['-datadir='+new_data_dir], | 0, ['-datadir='+new_data_dir], | ||||
'Error: Specified data directory "' + new_data_dir + '" does not exist.') | 'Error: Specified data directory "' + new_data_dir + '" does not exist.') | ||||
# Check that using non-existent datadir in conf file fails | # Check that using non-existent datadir in conf file fails | ||||
conf_file = os.path.join(default_data_dir, "bitcoin.conf") | conf_file = os.path.join(default_data_dir, "bitcoin.conf") | ||||
with open(conf_file, 'a', encoding='utf8') as f: | |||||
# datadir needs to be set before [regtest] section | |||||
conf_file_contents = open(conf_file, encoding='utf8').read() | |||||
with open(conf_file, 'w', encoding='utf8') as f: | |||||
f.write("datadir=" + new_data_dir + "\n") | f.write("datadir=" + new_data_dir + "\n") | ||||
f.write(conf_file_contents) | |||||
self.assert_start_raises_init_error( | self.assert_start_raises_init_error( | ||||
0, ['-conf='+conf_file], | 0, ['-conf='+conf_file], | ||||
'Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.') | 'Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.') | ||||
# Create the directory and ensure the config file now works | # Create the directory and ensure the config file now works | ||||
os.mkdir(new_data_dir) | os.mkdir(new_data_dir) | ||||
self.start_node(0, ['-conf='+conf_file, '-wallet=w1']) | self.start_node(0, ['-conf='+conf_file, '-wallet=w1']) | ||||
time.sleep(5) | time.sleep(5) | ||||
Show All 15 Lines |