Skip to content

Commit 1cb52ba

Browse files
committed
Modify "util_datadir" unit test to not use gArgs.
1 parent 1add318 commit 1cb52ba

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/test/util_tests.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,27 @@ BOOST_FIXTURE_TEST_SUITE(util_tests, BasicTestingSetup)
4949

5050
BOOST_AUTO_TEST_CASE(util_datadir)
5151
{
52-
ClearDatadirCache();
53-
const fs::path dd_norm = GetDataDir();
52+
// Use local args variable instead of m_args to avoid making assumptions about test setup
53+
ArgsManager args;
54+
args.ForceSetArg("-datadir", m_path_root.string());
55+
56+
const fs::path dd_norm = args.GetDataDirPath();
5457

55-
gArgs.ForceSetArg("-datadir", dd_norm.string() + "/");
58+
args.ForceSetArg("-datadir", dd_norm.string() + "/");
5659
ClearDatadirCache();
57-
BOOST_CHECK_EQUAL(dd_norm, GetDataDir());
60+
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
5861

59-
gArgs.ForceSetArg("-datadir", dd_norm.string() + "/.");
62+
args.ForceSetArg("-datadir", dd_norm.string() + "/.");
6063
ClearDatadirCache();
61-
BOOST_CHECK_EQUAL(dd_norm, GetDataDir());
64+
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
6265

63-
gArgs.ForceSetArg("-datadir", dd_norm.string() + "/./");
66+
args.ForceSetArg("-datadir", dd_norm.string() + "/./");
6467
ClearDatadirCache();
65-
BOOST_CHECK_EQUAL(dd_norm, GetDataDir());
68+
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
6669

67-
gArgs.ForceSetArg("-datadir", dd_norm.string() + "/.//");
70+
args.ForceSetArg("-datadir", dd_norm.string() + "/.//");
6871
ClearDatadirCache();
69-
BOOST_CHECK_EQUAL(dd_norm, GetDataDir());
72+
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
7073
}
7174

7275
BOOST_AUTO_TEST_CASE(util_check)

0 commit comments

Comments
 (0)