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:
authorBitflash <admin@bitflash.network>2026-08-14 11:00:38 -0300
committerBitflash <admin@bitflash.network>2026-08-14 11:00:38 -0300
commitbf62d480ae5d76c04d1a8b27750f51596473cc85 (patch)
tree4ae8be0412c40ae57fee600f44c02dcdd110497c /src/selftest.cpp
parentf10b52126b8a7408d7228b679b7270254feb0eda (diff)
parentdaf65cd1957eb529be31baf0614b741ff11e7771 (diff)
Merge pull request 'tests: prove encrypted rewrite keeps public wallet records' (#42) from wallet-rewrite-public-record-test into main
Diffstat (limited to 'src/selftest.cpp')
-rw-r--r--src/selftest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp
index 5e5bab6..638aa66 100644
--- a/src/selftest.cpp
+++ b/src/selftest.cpp
@@ -1134,6 +1134,13 @@ static int RunWalletEncryptSelfTest()
1134 TopUpKeyPool(); 1134 TopUpKeyPool();
1135 1135
1136 vector<unsigned char> vchDefaultPubKey = keyUser.GetPubKey(); 1136 vector<unsigned char> vchDefaultPubKey = keyUser.GetPubKey();
1137 CKey publicLabelKey;
1138 publicLabelKey.MakeNewKey();
1139 string strPublicLabelAddress = PubKeyToAddress(publicLabelKey.GetPubKey());
1140 nFail += Check(CWalletDB().WriteName(strPublicLabelAddress, "rewrite-public-name") &&
1141 CWalletDB().WriteSetting("rewrite-public-setting", (int64)424242),
1142 "public wallet records can be written before encryption") ? 0 : 1;
1143
1137 CPrivKey vchDefaultPrivKey; 1144 CPrivKey vchDefaultPrivKey;
1138 nFail += Check(GetWalletPrivKey(vchDefaultPubKey, vchDefaultPrivKey, strError), 1145 nFail += Check(GetWalletPrivKey(vchDefaultPubKey, vchDefaultPrivKey, strError),
1139 "the default private key is readable before encryption") ? 0 : 1; 1146 "the default private key is readable before encryption") ? 0 : 1;
@@ -1161,6 +1168,7 @@ static int RunWalletEncryptSelfTest()
1161#else 1168#else
1162 string strExe = cwd + "/bitflash-node"; 1169 string strExe = cwd + "/bitflash-node";
1163#endif 1170#endif
1171 string strStorageAudit = tmp + "/encrypted-storage-audit.txt";
1164 string strWrongDump = tmp + "/wrong-pass-dump.txt"; 1172 string strWrongDump = tmp + "/wrong-pass-dump.txt";
1165 string strRightDump = tmp + "/right-pass-dump.txt"; 1173 string strRightDump = tmp + "/right-pass-dump.txt";
1166 string strLiteralDump = tmp + "/literal-pass-dump.txt"; 1174 string strLiteralDump = tmp + "/literal-pass-dump.txt";
@@ -1173,6 +1181,18 @@ static int RunWalletEncryptSelfTest()
1173 WriteTextFile(strRightPassFile, "btf-test-passphrase\n"), 1181 WriteTextFile(strRightPassFile, "btf-test-passphrase\n"),
1174 "passphrase files can be written for restarted commands") ? 0 : 1; 1182 "passphrase files can be written for restarted commands") ? 0 : 1;
1175 1183
1184 vector<string> vStorageAuditArgs;
1185 vStorageAuditArgs.push_back("-datadir=" + tmp);
1186 vStorageAuditArgs.push_back("-walletstorageaudit");
1187 vStorageAuditArgs.push_back("-nogui");
1188 int nStorageAuditRet = RunBitflashChild(strExe, vStorageAuditArgs, NULL, &strStorageAudit);
1189 nFail += Check(nStorageAuditRet == 0 &&
1190 FileContainsText(strStorageAudit, "address book labels: 3"),
1191 "the encrypted rewrite keeps address-book records") ? 0 : 1;
1192 nFail += Check(nStorageAuditRet == 0 &&
1193 FileContainsText(strStorageAudit, "settings: 1"),
1194 "the encrypted rewrite keeps wallet setting records") ? 0 : 1;
1195
1176 vector<string> vWrongArgs; 1196 vector<string> vWrongArgs;
1177 vWrongArgs.push_back("-datadir=" + tmp); 1197 vWrongArgs.push_back("-datadir=" + tmp);
1178 vWrongArgs.push_back("-walletpassphrase=@" + strWrongPassFile); 1198 vWrongArgs.push_back("-walletpassphrase=@" + strWrongPassFile);