MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / VerifyIterator

Function VerifyIterator

src/test/fuzz/dbwrapper.cpp:142–168  ·  view source on GitHub ↗

Verify that the DB iterator matches the oracle, handling the obfuscation * metadata entry (stored under a non-uint16_t key) when obfuscation is on. */

Source from the content-addressed store, hash-verified

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. */
142void 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. */
171constexpr size_t MAX_READ_WORKERS{8};

Callers 1

TestDbWrapperFunction · 0.85

Calls 11

MakeValueFunction · 0.85
lower_boundMethod · 0.80
NewIteratorMethod · 0.45
beginMethod · 0.45
SeekMethod · 0.45
SeekToFirstMethod · 0.45
ValidMethod · 0.45
NextMethod · 0.45
GetKeyMethod · 0.45
endMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected