Skip to content

Commit 1e7564e

Browse files
committed
Merge bitcoin/bitcoin#24251: Re-enable windows path tests disabled by #20744
d216bc8 Re-enable walletinit_verify_walletdir_no_trailing2 test disabled in #20744 (Ryan Ofsky) 80cd64e Re-enable util_datadir check disabled in #20744 (Ryan Ofsky) Pull request description: Reenable some broken tests as discussed bitcoin/bitcoin#20744 (comment) and bitcoin/bitcoin#20744 (comment) Fix windows test cases broken in #20744, by passing normalized path arguments to fs::equivalent, fs::exists, and fs::is_directory, instead of non-normalized arguments. Also re-enable the tests. It is possible these changes also fix real init behavior on windows when -datadir or -walletdir paths with trailing dots or dashes are used, but it's not clear because I only tested on wine. ACKs for top commit: hebasto: ACK d216bc8, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 2099ddfa1a3ad70f7ac2ff413929414a1851d257b280da25c0f5cefb46fd1372b580a1f1ee5280681a1c16e6031f119185cadd4f7a6121298562cf001f711068
2 parents b23e037 + d216bc8 commit 1e7564e

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/test/util_tests.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,9 @@ BOOST_AUTO_TEST_CASE(util_datadir)
7171
args.ClearPathCache();
7272
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
7373

74-
#ifndef WIN32
75-
// Windows does not consider "datadir/.//" to be a valid directory path.
7674
args.ForceSetArg("-datadir", fs::PathToString(dd_norm) + "/.//");
7775
args.ClearPathCache();
7876
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
79-
#endif
8077
}
8178

8279
BOOST_AUTO_TEST_CASE(util_check)

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ fs::path StripRedundantLastElementsOfPath(const fs::path& path)
253253
result = result.parent_path();
254254
}
255255

256-
assert(fs::equivalent(result, path));
256+
assert(fs::equivalent(result, path.lexically_normal()));
257257
return result;
258258
}
259259
} // namespace

src/wallet/load.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ bool VerifyWallets(WalletContext& context)
3131
fs::path wallet_dir = fs::PathFromString(args.GetArg("-walletdir", ""));
3232
std::error_code error;
3333
// The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory
34+
// It also lets the fs::exists and fs::is_directory checks below pass on windows, since they return false
35+
// if a path has trailing slashes, and it strips trailing slashes.
3436
fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error);
35-
if (error || !fs::exists(wallet_dir)) {
37+
if (error || !fs::exists(canonical_wallet_dir)) {
3638
chain.initError(strprintf(_("Specified -walletdir \"%s\" does not exist"), fs::PathToString(wallet_dir)));
3739
return false;
38-
} else if (!fs::is_directory(wallet_dir)) {
40+
} else if (!fs::is_directory(canonical_wallet_dir)) {
3941
chain.initError(strprintf(_("Specified -walletdir \"%s\" is not a directory"), fs::PathToString(wallet_dir)));
4042
return false;
4143
// The canonical path transforms relative paths into absolute ones, so we check the non-canonical version

src/wallet/test/init_tests.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
7373
BOOST_CHECK_EQUAL(walletdir, expected_path);
7474
}
7575

76-
#ifndef WIN32
77-
// Windows does not consider "datadir/wallets//" to be a valid directory path.
7876
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
7977
{
8078
SetWalletDir(m_walletdir_path_cases["trailing2"]);
@@ -84,7 +82,6 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
8482
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
8583
BOOST_CHECK_EQUAL(walletdir, expected_path);
8684
}
87-
#endif
8885

8986
BOOST_AUTO_TEST_SUITE_END()
9087
} // namespace wallet

0 commit comments

Comments
 (0)