diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 76ffdc598a..a11716a7f1 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -49,24 +49,27 @@ BOOST_FIXTURE_TEST_SUITE(util_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(util_datadir) { - ClearDatadirCache(); - const fs::path dd_norm = GetDataDir(); + // Use local args variable instead of m_args to avoid making assumptions about test setup + ArgsManager args; + args.ForceSetArg("-datadir", m_path_root.string()); + + const fs::path dd_norm = args.GetDataDirPath(); - gArgs.ForceSetArg("-datadir", dd_norm.string() + "/"); + args.ForceSetArg("-datadir", dd_norm.string() + "/"); ClearDatadirCache(); - BOOST_CHECK_EQUAL(dd_norm, GetDataDir()); + BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); - gArgs.ForceSetArg("-datadir", dd_norm.string() + "/."); + args.ForceSetArg("-datadir", dd_norm.string() + "/."); ClearDatadirCache(); - BOOST_CHECK_EQUAL(dd_norm, GetDataDir()); + BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); - gArgs.ForceSetArg("-datadir", dd_norm.string() + "/./"); + args.ForceSetArg("-datadir", dd_norm.string() + "/./"); ClearDatadirCache(); - BOOST_CHECK_EQUAL(dd_norm, GetDataDir()); + BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); - gArgs.ForceSetArg("-datadir", dd_norm.string() + "/.//"); + args.ForceSetArg("-datadir", dd_norm.string() + "/.//"); ClearDatadirCache(); - BOOST_CHECK_EQUAL(dd_norm, GetDataDir()); + BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath()); } BOOST_AUTO_TEST_CASE(util_check)