aboutsummaryrefslogtreecommitdiff
path: root/src/test/util_tests.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-05-24 11:05:48 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-05-24 11:05:58 +0200
commit599000903e09e5ae3784d15ae078a2e1ed89ab12 (patch)
treee9d0903834c15386d3f4a9daec918cc11c1e775c /src/test/util_tests.cpp
parent778b9201799357d38276374093e6c14c8bd50fb9 (diff)
parentaca0e5dcdb174ef7e88b76910d6fffd633688235 (diff)
downloadbitcoin-599000903e09e5ae3784d15ae078a2e1ed89ab12.tar.xz
Merge bitcoin/bitcoin#21850: Remove `GetDataDir(net_specific)` function
aca0e5dcdb174ef7e88b76910d6fffd633688235 Remove `GetDataDir(bool fNetSpecific = true)` function (Kiminuo) b3e67f20a02bcf43f20873029ce30617c95eb9da scripted-diff: Replace `GetDataDir(true)` calls with `gArgs.GetDataDirNet()` calls (Kiminuo) 4c3a5dcbfc3010965332ad568c3a70618c930ef3 scripted-diff: Replace `GetDataDir()` calls with `gArgs.GetDataDirNet()` calls (Kiminuo) 13bd8bb0536f008118b1de921654925ed9ce1da7 Make `ArgsManager.GetDataDirPath` private and drop needless suffix (Kiminuo) 4d8189f62076d47be182e709857774bc3921b334 scripted-diff: Change `ArgsManager.GetDataDirPath()` to `ArgsManager.GetDataDirBase()` in tests (Kiminuo) 0f53df47d5b8319fc71f3b87c15a115ff797fb50 Add `ArgsManager.GetDataDirBase()` and `ArgsManager.GetDataDirNet()` as an intended replacement for `ArgsManager.GetDataDirPath(net_identifier)` (Kiminuo) 716de29dd8672d28bfe0a08424e9958fe61054d2 Make `m_cached_blocks_path` mutable. Make `ArgsManager::GetBlocksDirPath()` const. (Kiminuo) Pull request description: This PR is a follow up PR to #21244. The PR attempts to move us an inch towards the [goal](https://github.com/bitcoin/bitcoin/pull/21244#discussion_r615307465) by removing `GetDataDir(net_specific)` and replacing it by `gArgs.GetDataDir(net_specific)` calls. The approach of this PR attempts to be similar to the one chosen in "De-globalize ChainstateManager" (#20158). The goal is to pass `ArgsManager` to functions (or ideally to have `ArgsManager` as a member of a class where needed; inspiration from here: #21789) instead of having it as a global variable (i.e. `gArgs`). **Notes:** * First commit makes `m_cached_blocks_path` `mutable` as was suggested [here](https://github.com/bitcoin/bitcoin/pull/21244#discussion_r615274095) but not fully applied in #21244. (`m_cached_datadir_path` and `m_cached_network_datadir_path` were marked as `mutable` in #21244) This commit can be in a separate PR too. * Other commits deal with removing of `GetDataDir(net_specific)` function. * This was originally part of #21244 but it was [left]((https://github.com/bitcoin/bitcoin/pull/21244#pullrequestreview-633779754)) for a follow up PR. * I think that the proposed changes show nicely where there is reliance on `gArgs` which is IMO a good thing. If you know about a better approach how to do this, please share it here. ACKs for top commit: hebasto: ACK aca0e5dcdb174ef7e88b76910d6fffd633688235 MarcoFalke: re-ACK aca0e5dcdb174ef7e88b76910d6fffd633688235 👃 Tree-SHA512: deec4d88edb32d7f4c818c3a74ffbb64709685819b88242dcf5dbaa1fb611f3ce2b29d2576ddb9e0dc5e75288e43538968224008c0a80e7149fc81c309f7c9da
Diffstat (limited to 'src/test/util_tests.cpp')
-rw-r--r--src/test/util_tests.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 534d28e5de..aa95bc37e5 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -53,23 +53,23 @@ BOOST_AUTO_TEST_CASE(util_datadir)
ArgsManager args;
args.ForceSetArg("-datadir", m_path_root.string());
- const fs::path dd_norm = args.GetDataDirPath();
+ const fs::path dd_norm = args.GetDataDirBase();
args.ForceSetArg("-datadir", dd_norm.string() + "/");
args.ClearPathCache();
- BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
+ BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
args.ForceSetArg("-datadir", dd_norm.string() + "/.");
args.ClearPathCache();
- BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
+ BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
args.ForceSetArg("-datadir", dd_norm.string() + "/./");
args.ClearPathCache();
- BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
+ BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
args.ForceSetArg("-datadir", dd_norm.string() + "/.//");
args.ClearPathCache();
- BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
+ BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
}
BOOST_AUTO_TEST_CASE(util_check)
@@ -1159,10 +1159,10 @@ BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
// Test error logging, and remove previously written setting.
{
ASSERT_DEBUG_LOG("Failed renaming settings file");
- fs::remove(args1.GetDataDirPath() / "settings.json");
- fs::create_directory(args1.GetDataDirPath() / "settings.json");
+ fs::remove(args1.GetDataDirBase() / "settings.json");
+ fs::create_directory(args1.GetDataDirBase() / "settings.json");
args2.WriteSettingsFile();
- fs::remove(args1.GetDataDirPath() / "settings.json");
+ fs::remove(args1.GetDataDirBase() / "settings.json");
}
}
@@ -1810,7 +1810,7 @@ static constexpr char ExitCommand = 'X';
BOOST_AUTO_TEST_CASE(test_LockDirectory)
{
- fs::path dirname = m_args.GetDataDirPath() / "lock_dir";
+ fs::path dirname = m_args.GetDataDirBase() / "lock_dir";
const std::string lockname = ".lock";
#ifndef WIN32
// Revert SIGCHLD to default, otherwise boost.test will catch and fail on
@@ -1899,7 +1899,7 @@ BOOST_AUTO_TEST_CASE(test_LockDirectory)
BOOST_AUTO_TEST_CASE(test_DirIsWritable)
{
// Should be able to write to the data dir.
- fs::path tmpdirname = m_args.GetDataDirPath();
+ fs::path tmpdirname = m_args.GetDataDirBase();
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true);
// Should not be able to write to a non-existent dir.