Skip to content

Commit

Permalink
Fix feature_config_args.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil committed Oct 26, 2024
1 parent 0f40292 commit d68a76e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_config_file_log(self):
# datadir= line pointing at the node datadir.
node = self.nodes[0]
conf_text = node.bitcoinconf.read_text()
conf_path = default_datadir / "bitcoin.conf"
conf_path = default_datadir / "qtum.conf"
conf_path.write_text(f"datadir={node.datadir_path}\n{conf_text}")

# Drop the node -datadir= argument during this test, because if it is
Expand Down Expand Up @@ -326,14 +326,14 @@ def test_ignored_conf(self):
with tempfile.NamedTemporaryFile(dir=self.options.tmpdir, mode="wt", delete=False) as temp_conf:
temp_conf.write(f"datadir={node.datadir_path}\n")
node.assert_start_raises_init_error([f"-conf={temp_conf.name}"], re.escape(
f'Error: Data directory "{node.datadir_path}" contains a "bitcoin.conf" file which is ignored, because a '
f'Error: Data directory "{node.datadir_path}" contains a "qtum.conf" file which is ignored, because a '
f'different configuration file "{temp_conf.name}" from command line argument "-conf={temp_conf.name}" '
f'is being used instead.') + r"[\s\S]*", match=ErrorMatch.FULL_REGEX)

# Test that passing a redundant -conf command line argument pointing to
# the same bitcoin.conf that would be loaded anyway does not trigger an
# error.
self.start_node(0, [f'-conf={node.datadir_path}/bitcoin.conf'])
self.start_node(0, [f'-conf={node.datadir_path}/qtum.conf'])
self.stop_node(0)

def test_ignored_default_conf(self):
Expand All @@ -355,22 +355,22 @@ def test_ignored_default_conf(self):
# startup error because the node datadir contains a different
# bitcoin.conf that would be ignored.
node = self.nodes[0]
(default_datadir / "bitcoin.conf").write_text(f"datadir={node.datadir_path}\n")
(default_datadir / "qtum.conf").write_text(f"datadir={node.datadir_path}\n")

# Drop the node -datadir= argument during this test, because if it is
# specified it would take precedence over the datadir setting in the
# config file.
node_args = node.args
node.args = [arg for arg in node.args if not arg.startswith("-datadir=")]
node.assert_start_raises_init_error([], re.escape(
f'Error: Data directory "{node.datadir_path}" contains a "bitcoin.conf" file which is ignored, because a '
f'different configuration file "{default_datadir}/bitcoin.conf" from data directory "{default_datadir}" '
f'Error: Data directory "{node.datadir_path}" contains a "qtum.conf" file which is ignored, because a '
f'different configuration file "{default_datadir}/qtum.conf" from data directory "{default_datadir}" '
f'is being used instead.') + r"[\s\S]*", env=env, match=ErrorMatch.FULL_REGEX)
node.args = node_args

def test_acceptstalefeeestimates_arg_support(self):
self.log.info("Test -acceptstalefeeestimates option support")
conf_file = self.nodes[0].datadir_path / "bitcoin.conf"
conf_file = self.nodes[0].datadir_path / "qtum.conf"
for chain, chain_name in {("main", ""), ("test", "testnet3"), ("signet", "signet")}:
util.write_config(conf_file, n=0, chain=chain_name, extra_config='acceptstalefeeestimates=1\n')
self.nodes[0].assert_start_raises_init_error(expected_msg=f'Error: acceptstalefeeestimates is not supported on {chain} chain.')
Expand Down
3 changes: 3 additions & 0 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None

# add environment variable LIBC_FATAL_STDERR_=1 so that libc errors are written to stderr and not the terminal
subp_env = dict(os.environ, LIBC_FATAL_STDERR_="1")
if env is not None:
subp_env.update(env)

if not any(arg.startswith('-staking=') for arg in extra_args):
extra_args.append('-staking=0')

Expand Down
6 changes: 3 additions & 3 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@ def get_temp_default_datadir(temp_dir: pathlib.Path) -> tuple[dict, pathlib.Path
temp_dir, as well as the complete path it would return."""
if platform.system() == "Windows":
env = dict(APPDATA=str(temp_dir))
datadir = temp_dir / "Bitcoin"
datadir = temp_dir / "Qtum"
else:
env = dict(HOME=str(temp_dir))
if platform.system() == "Darwin":
datadir = temp_dir / "Library/Application Support/Bitcoin"
datadir = temp_dir / "Library/Application Support/Qtum"
else:
datadir = temp_dir / ".bitcoin"
datadir = temp_dir / ".qtum"
return env, datadir


Expand Down

0 comments on commit d68a76e

Please sign in to comment.