mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
e197f976e1
* Merge #16509: test: Adapt test framework for chains other than "regtest" faf36838bdba7393960fce6ad0c56dc1f93f5870 test: Avoid hardcoding the chain name in combine_logs (MarcoFalke) fa8a1d7ba30040f8c74f93fc41a61276c255a6a6 test: Adapt test framework for chains other than "regtest" (MarcoFalke) 68f546635d5de2ccfedadeabc7bc79e12e5eca6a test: Fix “local variable 'e' is assigned to but never used” (Ben Woosley) Pull request description: This is required for various work in progress: * testchains #8994 * signet #16411 * some of my locally written tests While it will be unused in the master branch as of now, it will make all of those pull requests shorter. Thus review for non-regtest tests can focus on the actual changes and not some test framework changes. ACKs for top commit: jonatack: ACK faf36838bdba7393960fce6ad0c56dc1f93f5870, ran tests and reviewed the code. Tree-SHA512: 35add66c12cab68f2fac8f7c7d47c604d3f24eae9336ff78f83e2c92b3dc08a25e7f4217199bac5393dd3fb72f945bba9c001d6fbb8efd298c88858075fcb3d6 * Add devnet support for tests * test: make sure devnet can connect to each other and start * Partial merge bitcoin/bitcoin#16681: Tests: Use self.chain instead of 'regtest' in almost all current tests, revert one TODO while at it Co-authored-by: MarcoFalke <falke.marco@gmail.com> Co-authored-by: Jorge Timón <jtimon@jtimon.cc>
56 lines
2.4 KiB
Python
Executable File
56 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2017 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test various command line arguments and configuration file parameters."""
|
|
|
|
import os
|
|
import re
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
|
|
class ConfArgsTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 1
|
|
|
|
def run_test(self):
|
|
self.stop_node(0)
|
|
# Remove the -datadir argument so it doesn't override the config file
|
|
self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]
|
|
|
|
default_data_dir = self.nodes[0].datadir
|
|
new_data_dir = os.path.join(default_data_dir, 'newdatadir')
|
|
new_data_dir_2 = os.path.join(default_data_dir, 'newdatadir2')
|
|
|
|
# Check that using -datadir argument on non-existent directory fails
|
|
self.nodes[0].datadir = new_data_dir
|
|
self.nodes[0].assert_start_raises_init_error(['-datadir=' + new_data_dir], 'Error: Specified data directory "' + re.escape(new_data_dir) + '" does not exist.')
|
|
|
|
# Check that using non-existent datadir in conf file fails
|
|
conf_file = os.path.join(default_data_dir, "dash.conf")
|
|
|
|
# datadir needs to be set before [chain] 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(conf_file_contents)
|
|
|
|
self.nodes[0].assert_start_raises_init_error(['-conf=' + conf_file], 'Error reading configuration file: specified data directory "' + re.escape(new_data_dir) + '" does not exist.')
|
|
|
|
# Create the directory and ensure the config file now works
|
|
os.mkdir(new_data_dir)
|
|
self.start_node(0, ['-conf='+conf_file, '-wallet=w1'])
|
|
self.stop_node(0)
|
|
assert os.path.exists(os.path.join(new_data_dir, self.chain, 'wallets', 'w1'))
|
|
|
|
# Ensure command line argument overrides datadir in conf
|
|
os.mkdir(new_data_dir_2)
|
|
self.nodes[0].datadir = new_data_dir_2
|
|
self.start_node(0, ['-datadir='+new_data_dir_2, '-conf='+conf_file, '-wallet=w2'])
|
|
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'wallets', 'w2'))
|
|
|
|
if __name__ == '__main__':
|
|
ConfArgsTest().main()
|