mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
Merge #13367: qa: Increase includeconf test coverage
fa4760fbb3 qa: Increase includeconf test coverage (MarcoFalke)
Pull request description:
This adds some missing `return false` for error conditions and adds test coverage [1] for those.
Also, extend recursion warning when the chain was set in one of the includeconfs.
[1] See the red lines in https://marcofalke.github.io/btc_cov/total.coverage/src/util.cpp.gcov.html for missing coverage.
Tree-SHA512: d32563c9bb277879895a173e699034db5ecdb4061a1ec8890c566d61e36a09efa5eda19a029baf952ff6d568f8b9684a13a0bb90827850075470975e2088fee4
This commit is contained in:
@@ -41,14 +41,9 @@ class IncludeConfTest(BitcoinTestFramework):
|
||||
subversion = self.nodes[0].getnetworkinfo()["subversion"]
|
||||
assert subversion.endswith("main; relative)/")
|
||||
|
||||
self.log.info("-includeconf cannot be used as command-line arg. subversion should still end with 'main; relative)/'")
|
||||
self.log.info("-includeconf cannot be used as command-line arg")
|
||||
self.stop_node(0)
|
||||
|
||||
self.start_node(0, extra_args=["-includeconf=relative2.conf"])
|
||||
|
||||
subversion = self.nodes[0].getnetworkinfo()["subversion"]
|
||||
assert subversion.endswith("main; relative)/")
|
||||
self.stop_node(0, expected_stderr="warning: -includeconf cannot be used from commandline; ignoring -includeconf=relative2.conf")
|
||||
self.nodes[0].assert_start_raises_init_error(extra_args=["-includeconf=relative2.conf"], expected_msg="Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf=relative2.conf")
|
||||
|
||||
self.log.info("-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:
|
||||
@@ -59,8 +54,18 @@ class IncludeConfTest(BitcoinTestFramework):
|
||||
assert subversion.endswith("main; relative)/")
|
||||
self.stop_node(0, expected_stderr="warning: -includeconf cannot be used from included files; ignoring -includeconf=relative2.conf")
|
||||
|
||||
self.log.info("-includeconf cannot contain invalid arg")
|
||||
with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "w", encoding="utf8") as f:
|
||||
f.write("foo=bar\n")
|
||||
self.nodes[0].assert_start_raises_init_error(expected_msg="Error reading configuration file: Invalid configuration value foo")
|
||||
|
||||
self.log.info("-includeconf cannot be invalid path")
|
||||
os.remove(os.path.join(self.options.tmpdir, "node0", "relative.conf"))
|
||||
self.nodes[0].assert_start_raises_init_error(expected_msg="Error reading configuration file: Failed to include configuration file relative.conf")
|
||||
|
||||
self.log.info("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:
|
||||
# Restore initial file contents
|
||||
f.write("uacomment=relative\n")
|
||||
|
||||
with open(os.path.join(self.options.tmpdir, "node0", "bitcoin.conf"), "a", encoding='utf8') as f:
|
||||
|
||||
Reference in New Issue
Block a user