Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_includeconf.py
Show All 9 Lines | 1. adding includeconf to the configuration file causes the includeconf | ||||
file to be loaded in the correct order. | file to be loaded in the correct order. | ||||
2. includeconf cannot be used as a command line argument. | 2. includeconf cannot be used as a command line argument. | ||||
3. includeconf cannot be used recursively (ie includeconf can only | 3. includeconf cannot be used recursively (ie includeconf can only | ||||
be used from the base config file). | be used from the base config file). | ||||
4. multiple includeconf arguments can be specified in the main config | 4. multiple includeconf arguments can be specified in the main config | ||||
file. | file. | ||||
""" | """ | ||||
import os | import os | ||||
import tempfile | |||||
from test_framework.test_framework import BitcoinTestFramework, assert_equal | from test_framework.test_framework import BitcoinTestFramework | ||||
class IncludeConfTest(BitcoinTestFramework): | class IncludeConfTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = False | self.setup_clean_chain = False | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
def setup_chain(self): | def setup_chain(self): | ||||
Show All 13 Lines | def run_test(self): | ||||
"-includeconf works from config file. subversion should end with 'main; relative)/'") | "-includeconf works from config file. subversion should end with 'main; relative)/'") | ||||
subversion = self.nodes[0].getnetworkinfo()["subversion"] | subversion = self.nodes[0].getnetworkinfo()["subversion"] | ||||
assert subversion.endswith("main; relative)/") | assert subversion.endswith("main; relative)/") | ||||
self.log.info( | self.log.info( | ||||
"-includeconf cannot be used as command-line arg. subversion should still end with 'main; relative)/'") | "-includeconf cannot be used as command-line arg. subversion should still end with 'main; relative)/'") | ||||
self.stop_node(0) | self.stop_node(0) | ||||
with tempfile.SpooledTemporaryFile(max_size=2**16) as log_stderr: | |||||
self.start_node( | self.start_node(0, extra_args=["-includeconf=relative2.conf"]) | ||||
0, extra_args=["-includeconf=relative2.conf"], stderr=log_stderr) | |||||
subversion = self.nodes[0].getnetworkinfo()["subversion"] | subversion = self.nodes[0].getnetworkinfo()["subversion"] | ||||
assert subversion.endswith("main; relative)/") | assert subversion.endswith("main; relative)/") | ||||
log_stderr.seek(0) | self.stop_node( | ||||
stderr = log_stderr.read().decode('utf-8').strip() | 0, expected_stderr="warning: -includeconf cannot be used from commandline; ignoring -includeconf=relative2.conf") | ||||
assert_equal( | |||||
stderr, 'warning: -includeconf cannot be used from commandline; ignoring -includeconf=relative2.conf') | |||||
self.log.info( | self.log.info( | ||||
"-includeconf cannot be used recursively. subversion should end with 'main; relative)/'") | "-includeconf cannot be used recursively. subversion should end with 'main; relative)/'") | ||||
with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "a", encoding="utf8") as f: | with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "a", encoding="utf8") as f: | ||||
f.write("includeconf=relative2.conf\n") | f.write("includeconf=relative2.conf\n") | ||||
self.restart_node(0) | self.start_node(0) | ||||
subversion = self.nodes[0].getnetworkinfo()["subversion"] | subversion = self.nodes[0].getnetworkinfo()["subversion"] | ||||
assert subversion.endswith("main; relative)/") | assert subversion.endswith("main; relative)/") | ||||
self.log.info( | self.log.info( | ||||
"multiple -includeconf args can be used from the base config file. subversion should end with 'main; relative; relative2)/'") | "multiple -includeconf args can be used from the base config file. subversion should end with 'main; relative; relative2)/'") | ||||
with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "w", encoding="utf8") as f: | with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "w", encoding="utf8") as f: | ||||
f.write("uacomment=relative\n") | f.write("uacomment=relative\n") | ||||
Show All 12 Lines |