upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/selftest.cpp
diff options
context:
space:
mode:
authorNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-13 17:23:36 -0300
committerNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-13 17:59:25 -0300
commitc0f886f0683ebd1321751355ddc0c757496320c9 (patch)
tree1f8cbd81a74985155e09104d89a3d320cdfc4851 /src/selftest.cpp
parent4660b7ba94b071e8e7cc69c06e04b5ff64f12dd4 (diff)
tests: assert encryptwallet purges BDB logs
Diffstat (limited to 'src/selftest.cpp')
-rw-r--r--src/selftest.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp
index 3f3cb16..8a448f0 100644
--- a/src/selftest.cpp
+++ b/src/selftest.cpp
@@ -966,6 +966,50 @@ static bool CopyFileLocal(const string& strSrc, const string& strDst)
966 return fOk; 966 return fOk;
967} 967}
968 968
969static bool DirectoryHasFileWithPrefix(const string& strDir, const string& strPrefix)
970{
971#ifdef _WIN32
972 WIN32_FIND_DATAA findData;
973 string pattern = strDir + "\\*";
974 HANDLE hFind = FindFirstFileA(pattern.c_str(), &findData);
975 if (hFind == INVALID_HANDLE_VALUE)
976 return false;
977 bool fFound = false;
978 do
979 {
980 if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
981 {
982 string name = findData.cFileName;
983 if (name.compare(0, strPrefix.size(), strPrefix) == 0)
984 {
985 fFound = true;
986 break;
987 }
988 }
989 }
990 while (FindNextFileA(hFind, &findData));
991 FindClose(hFind);
992 return fFound;
993#else
994 DIR* dir = opendir(strDir.c_str());
995 if (!dir)
996 return false;
997 bool fFound = false;
998 struct dirent* ent;
999 while ((ent = readdir(dir)) != NULL)
1000 {
1001 string name = ent->d_name;
1002 if (name.compare(0, strPrefix.size(), strPrefix) == 0)
1003 {
1004 fFound = true;
1005 break;
1006 }
1007 }
1008 closedir(dir);
1009 return fFound;
1010#endif
1011}
1012
969static string QuoteCommandArg(const string& str) 1013static string QuoteCommandArg(const string& str)
970{ 1014{
971 string out = "\""; 1015 string out = "\"";
@@ -1310,6 +1354,20 @@ static int RunWalletPortabilitySelfTest()
1310 FileContainsText(strBackupAudit, "recovery phrase: present") && 1354 FileContainsText(strBackupAudit, "recovery phrase: present") &&
1311 FileContainsText(strBackupAudit, "SLIP-0044 BITFLASH"), 1355 FileContainsText(strBackupAudit, "SLIP-0044 BITFLASH"),
1312 "a /backupwallet copy opens in a new datadir") ? 0 : 1; 1356 "a /backupwallet copy opens in a new datadir") ? 0 : 1;
1357
1358 string strPassFile = tmp + "/encrypt-pass.txt";
1359 string strEncryptOut = tmp + "/encryptwallet.txt";
1360 nFail += Check(WriteTextFile(strPassFile, "portable-test-passphrase\n"),
1361 "an encryption passphrase file can be written") ? 0 : 1;
1362 vector<string> vEncryptArgs;
1363 vEncryptArgs.push_back("-datadir=" + strOriginal);
1364 vEncryptArgs.push_back("-nomanagedtor");
1365 vEncryptArgs.push_back("-nogui");
1366 vEncryptArgs.push_back("-encryptwallet=@" + strPassFile);
1367 int nEncryptRet = RunBitflashChild(strExe, vEncryptArgs, NULL, &strEncryptOut);
1368 nFail += Check(nEncryptRet == 0 &&
1369 !DirectoryHasFileWithPrefix(strOriginal + "/database", "log."),
1370 "the encryptwallet command purges Berkeley DB environment logs") ? 0 : 1;
1313 } 1371 }
1314 catch (const std::exception& e) 1372 catch (const std::exception& e)
1315 { 1373 {