diff options
| author | Bitflash <admin@bitflash.network> | 2026-08-17 11:08:42 -0300 |
|---|---|---|
| committer | Bitflash <admin@bitflash.network> | 2026-08-17 11:08:42 -0300 |
| commit | 8e91ff3a57a085663312a6e1821ec4cb1c152144 (patch) | |
| tree | d511b288e1d0f555723114a9502c897b07cb048a /src/selftest.cpp | |
| parent | f7033201689c6eb70f16b242b9f90be548f67aa5 (diff) | |
| parent | a72fc5fa0c9811ff5a57af90bf4440023c94ac5a (diff) | |
Merge pull request 'wallet: add typed SQLite wallet records' (#56) from wallet-storage-backend-stage into main
Diffstat (limited to 'src/selftest.cpp')
| -rw-r--r-- | src/selftest.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp index 14bf45a..4b1e733 100644 --- a/src/selftest.cpp +++ b/src/selftest.cpp | |||
| @@ -1115,6 +1115,57 @@ static int RunWalletSQLiteSelfTest() | |||
| 1115 | nFail += Check(!ssReadDefault.fail() && vchReadPubKey == vchPubKey, | 1115 | nFail += Check(!ssReadDefault.fail() && vchReadPubKey == vchPubKey, |
| 1116 | "SQLite wallet preserves public key blobs") ? 0 : 1; | 1116 | "SQLite wallet preserves public key blobs") ? 0 : 1; |
| 1117 | } | 1117 | } |
| 1118 | |||
| 1119 | { | ||
| 1120 | CWalletDBSQLite db; | ||
| 1121 | nFail += Check(db.Open(strPath, strError), | ||
| 1122 | "SQLite wallet reopens for typed records") ? 0 : 1; | ||
| 1123 | |||
| 1124 | nFail += Check(db.WriteTypedRecord(make_pair(string("setting"), | ||
| 1125 | string("sqlite-typed")), | ||
| 1126 | (int64)777, strError), | ||
| 1127 | "SQLite wallet writes a typed setting record") ? 0 : 1; | ||
| 1128 | |||
| 1129 | int64 nTypedRead = 0; | ||
| 1130 | nFail += Check(db.ReadTypedRecord(make_pair(string("setting"), | ||
| 1131 | string("sqlite-typed")), | ||
| 1132 | nTypedRead, strError) && | ||
| 1133 | nTypedRead == 777, | ||
| 1134 | "SQLite wallet reads a typed setting record") ? 0 : 1; | ||
| 1135 | |||
| 1136 | nFail += Check(!db.WriteTypedRecord(make_pair(string("setting"), | ||
| 1137 | string("sqlite-typed")), | ||
| 1138 | (int64)888, strError, false), | ||
| 1139 | "SQLite wallet refuses typed overwrite when asked") ? 0 : 1; | ||
| 1140 | |||
| 1141 | nTypedRead = 0; | ||
| 1142 | nFail += Check(db.ReadTypedRecord(make_pair(string("setting"), | ||
| 1143 | string("sqlite-typed")), | ||
| 1144 | nTypedRead, strError) && | ||
| 1145 | nTypedRead == 777, | ||
| 1146 | "SQLite wallet preserves the old typed value after overwrite refusal") ? 0 : 1; | ||
| 1147 | |||
| 1148 | nFail += Check(db.EraseTypedRecord(make_pair(string("setting"), | ||
| 1149 | string("sqlite-typed")), | ||
| 1150 | strError), | ||
| 1151 | "SQLite wallet erases a typed record") ? 0 : 1; | ||
| 1152 | |||
| 1153 | nTypedRead = 0; | ||
| 1154 | nFail += Check(!db.ReadTypedRecord(make_pair(string("setting"), | ||
| 1155 | string("sqlite-typed")), | ||
| 1156 | nTypedRead, strError), | ||
| 1157 | "SQLite wallet typed erase removes the record") ? 0 : 1; | ||
| 1158 | |||
| 1159 | nFail += Check(db.WriteTypedRecord(string("defaultkey"), vchPubKey, | ||
| 1160 | strError), | ||
| 1161 | "SQLite wallet writes a typed defaultkey record") ? 0 : 1; | ||
| 1162 | |||
| 1163 | vector<unsigned char> vchTypedPubKey; | ||
| 1164 | nFail += Check(db.ReadTypedRecord(string("defaultkey"), vchTypedPubKey, | ||
| 1165 | strError) && | ||
| 1166 | vchTypedPubKey == vchPubKey, | ||
| 1167 | "SQLite wallet reads a typed defaultkey record") ? 0 : 1; | ||
| 1168 | } | ||
| 1118 | } | 1169 | } |
| 1119 | catch (const std::exception& e) | 1170 | catch (const std::exception& e) |
| 1120 | { | 1171 | { |