Verify that the DB iterator matches the oracle, handling the obfuscation * metadata entry (stored under a non-uint16_t key) when obfuscation is on. */
| 140 | /** Verify that the DB iterator matches the oracle, handling the obfuscation |
| 141 | * metadata entry (stored under a non-uint16_t key) when obfuscation is on. */ |
| 142 | void VerifyIterator(CDBWrapper& dbw, const Oracle& oracle, |
| 143 | bool obfuscate, std::optional<uint16_t> seek_key = std::nullopt) |
| 144 | { |
| 145 | const std::unique_ptr<CDBIterator> it{dbw.NewIterator()}; |
| 146 | auto oracle_it{seek_key ? oracle.lower_bound(*seek_key) : oracle.begin()}; |
| 147 | if (seek_key) { |
| 148 | it->Seek(*seek_key); |
| 149 | } else { |
| 150 | it->SeekToFirst(); |
| 151 | } |
| 152 | for (; it->Valid(); it->Next()) { |
| 153 | uint16_t db_key; |
| 154 | assert(it->GetKey(db_key)); |
| 155 | if (oracle_it != oracle.end() && db_key == oracle_it->first) { |
| 156 | std::vector<uint8_t> db_value; |
| 157 | assert(it->GetValue(db_value)); |
| 158 | assert(db_value == MakeValue(db_key, oracle_it->second)); |
| 159 | ++oracle_it; |
| 160 | } else { |
| 161 | assert(obfuscate); |
| 162 | std::string key_str; |
| 163 | assert(it->GetKey(key_str)); |
| 164 | assert(key_str == OBFUSCATION_KEY); |
| 165 | } |
| 166 | } |
| 167 | assert(oracle_it == oracle.end()); |
| 168 | } |
| 169 | |
| 170 | /** Maximum number of concurrent reader threads in dbwrapper_concurrent_reads. */ |
| 171 | constexpr size_t MAX_READ_WORKERS{8}; |
no test coverage detected