Bitcoin Core 32.99.0
P2P Digital Currency
dbwrapper_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2012-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <dbwrapper.h>
6#include <test/util/common.h>
7#include <test/util/random.h>
9#include <uint256.h>
10#include <util/byte_units.h>
11#include <util/string.h>
12
13#include <fstream>
14#include <memory>
15#include <ranges>
16
17#include <boost/test/unit_test.hpp>
18
19using util::ToString;
20
22
24{
25 // Perform tests both obfuscated and non-obfuscated.
26 for (const bool obfuscate : {false, true}) {
27 constexpr size_t CACHE_SIZE{1_MiB};
28 const fs::path path{m_args.GetDataDirBase() / "dbwrapper"};
29
30 Obfuscation obfuscation;
31 std::vector<std::pair<uint8_t, uint256>> key_values{};
32
33 // Write values
34 {
35 CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .wipe_data = true, .obfuscate = obfuscate}};
36 BOOST_CHECK_EQUAL(obfuscate, !dbw.IsEmpty());
37
38 // Ensure that we're doing real obfuscation when obfuscate=true
39 obfuscation = dbwrapper_private::GetObfuscation(dbw);
41
42 for (uint8_t k{0}; k < 10; ++k) {
43 uint8_t key{k};
44 uint256 value{m_rng.rand256()};
45 dbw.Write(key, value);
46 key_values.emplace_back(key, value);
47 }
48 }
49
50 // Verify that the obfuscation key is never obfuscated
51 {
52 CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .obfuscate = false}};
54 }
55
56 // Read back the values
57 {
58 CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .obfuscate = obfuscate}};
59
60 // Ensure obfuscation is read back correctly
63
64 // Verify all written values
65 for (const auto& [key, expected_value] : key_values) {
66 uint256 read_value{};
67 BOOST_CHECK(dbw.Read(key, read_value));
68 BOOST_CHECK_EQUAL(read_value, expected_value);
69 }
70 }
71 }
72}
73
74BOOST_AUTO_TEST_CASE(dbwrapper_basic_data)
75{
76 // Perform tests both obfuscated and non-obfuscated.
77 for (bool obfuscate : {false, true}) {
78 fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_1_obfuscate_true" : "dbwrapper_1_obfuscate_false");
79 CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = false, .wipe_data = true, .obfuscate = obfuscate});
80
81 uint256 res;
82 uint32_t res_uint_32;
83 bool res_bool;
84
85 // Ensure that we're doing real obfuscation when obfuscate=true
87
88 //Simulate block raw data - "b + block hash"
89 std::string key_block = "b" + m_rng.rand256().ToString();
90
91 uint256 in_block = m_rng.rand256();
92 dbw.Write(key_block, in_block);
93 BOOST_CHECK(dbw.Read(key_block, res));
94 BOOST_CHECK_EQUAL(res.ToString(), in_block.ToString());
95
96 //Simulate file raw data - "f + file_number"
97 std::string key_file = strprintf("f%04x", m_rng.rand32());
98
99 uint256 in_file_info = m_rng.rand256();
100 dbw.Write(key_file, in_file_info);
101 BOOST_CHECK(dbw.Read(key_file, res));
102 BOOST_CHECK_EQUAL(res.ToString(), in_file_info.ToString());
103
104 //Simulate transaction raw data - "t + transaction hash"
105 std::string key_transaction = "t" + m_rng.rand256().ToString();
106
107 uint256 in_transaction = m_rng.rand256();
108 dbw.Write(key_transaction, in_transaction);
109 BOOST_CHECK(dbw.Read(key_transaction, res));
110 BOOST_CHECK_EQUAL(res.ToString(), in_transaction.ToString());
111
112 //Simulate UTXO raw data - "c + transaction hash"
113 std::string key_utxo = "c" + m_rng.rand256().ToString();
114
115 uint256 in_utxo = m_rng.rand256();
116 dbw.Write(key_utxo, in_utxo);
117 BOOST_CHECK(dbw.Read(key_utxo, res));
118 BOOST_CHECK_EQUAL(res.ToString(), in_utxo.ToString());
119
120 //Simulate last block file number - "l"
121 uint8_t key_last_blockfile_number{'l'};
122 uint32_t lastblockfilenumber = m_rng.rand32();
123 dbw.Write(key_last_blockfile_number, lastblockfilenumber);
124 BOOST_CHECK(dbw.Read(key_last_blockfile_number, res_uint_32));
125 BOOST_CHECK_EQUAL(lastblockfilenumber, res_uint_32);
126
127 //Simulate Is Reindexing - "R"
128 uint8_t key_IsReindexing{'R'};
129 bool isInReindexing = m_rng.randbool();
130 dbw.Write(key_IsReindexing, isInReindexing);
131 BOOST_CHECK(dbw.Read(key_IsReindexing, res_bool));
132 BOOST_CHECK_EQUAL(isInReindexing, res_bool);
133
134 //Simulate last block hash up to which UXTO covers - 'B'
135 uint8_t key_lastblockhash_uxto{'B'};
136 uint256 lastblock_hash = m_rng.rand256();
137 dbw.Write(key_lastblockhash_uxto, lastblock_hash);
138 BOOST_CHECK(dbw.Read(key_lastblockhash_uxto, res));
139 BOOST_CHECK_EQUAL(lastblock_hash, res);
140
141 //Simulate file raw data - "F + filename_number + filename"
142 std::string file_option_tag = "F";
143 uint8_t filename_length = m_rng.randbits(8);
144 std::string filename = "randomfilename";
145 std::string key_file_option = strprintf("%s%01x%s", file_option_tag, filename_length, filename);
146
147 bool in_file_bool = m_rng.randbool();
148 dbw.Write(key_file_option, in_file_bool);
149 BOOST_CHECK(dbw.Read(key_file_option, res_bool));
150 BOOST_CHECK_EQUAL(res_bool, in_file_bool);
151 }
152}
153
154// Test batch operations
155BOOST_AUTO_TEST_CASE(dbwrapper_batch)
156{
157 // Perform tests both obfuscated and non-obfuscated.
158 for (const bool obfuscate : {false, true}) {
159 fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_batch_obfuscate_true" : "dbwrapper_batch_obfuscate_false");
160 CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = obfuscate});
161
162 uint8_t key{'i'};
163 uint256 in = m_rng.rand256();
164 uint8_t key2{'j'};
165 uint256 in2 = m_rng.rand256();
166 uint8_t key3{'k'};
167 uint256 in3 = m_rng.rand256();
168
169 uint256 res;
170 CDBBatch batch(dbw);
171
172 batch.Write(key, in);
173 batch.Write(key2, in2);
174 batch.Write(key3, in3);
175
176 // Remove key3 before it's even been written
177 batch.Erase(key3);
178
179 dbw.WriteBatch(batch);
180
181 BOOST_CHECK(dbw.Read(key, res));
183 BOOST_CHECK(dbw.Read(key2, res));
184 BOOST_CHECK_EQUAL(res.ToString(), in2.ToString());
185
186 // key3 should've never been written
187 BOOST_CHECK(dbw.Read(key3, res) == false);
188
189 batch.Clear();
190 batch.Write(key3, in3);
191 dbw.WriteBatch(batch);
192
193 BOOST_CHECK(dbw.Read(key3, res));
194 BOOST_CHECK_EQUAL(res.ToString(), in3.ToString());
195 }
196}
197
198// Verify that Read() returns false (without throwing) when the stored value
199// fails to be deserialized
200BOOST_AUTO_TEST_CASE(dbwrapper_read_returns_false_on_deserialization_error)
201{
202 for (const bool obfuscate : {false, true}) {
203 const fs::path path{m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_deser_obf" : "dbwrapper_deser_noobf")};
204 CDBWrapper dbw({.path = path, .cache_bytes = 1 << 20, .wipe_data = true, .obfuscate = obfuscate});
205
206 constexpr uint8_t key{'X'};
207
208 // Write a single byte. uint256 requires 32 bytes, so reading this key
209 // as uint256 must trigger a deserialization error inside Read()
210 dbw.Write(key, uint8_t{0xFF});
211 BOOST_CHECK(dbw.Exists(key));
212
213 // Read() must catch the deserialization exception and return false,
214 // the same as if the key were absent
215 uint256 result;
216 BOOST_CHECK(!dbw.Read(key, result));
217 }
218}
219
220// Verify Read() throws dbwrapper_error due to an internal db error
221BOOST_AUTO_TEST_CASE(dbwrapper_read_throws_on_db_error)
222{
223 const fs::path path{m_args.GetDataDirBase() / "dbwrapper_db_error"};
224 constexpr uint8_t key{'Y'};
225
226 const auto make_db = [] (const fs::path& path, const bool force_compact) {
227 return CDBWrapper({.path = path, .cache_bytes = 1 << 20, .obfuscate = false,
228 .options = {.force_compact = force_compact}});
229 };
230
231 // Write a value and close the database
232 make_db(path, /*force_compact=*/false).Write(key, m_rng.rand256());
233
234 // Force compaction to ensure the data is written into the .ldb files
235 // rather than left in the WAL.
236 (void)make_db(path, /*force_compact=*/true);
237
238 // Corrupt every table so any subsequent Read() fails
239 for (const auto& entry : fs::directory_iterator(path)) {
240 if (entry.path().extension() == ".ldb") {
241 std::ofstream{entry.path(), std::ios::binary | std::ios::trunc}
242 .write("\xff", 1);
243 }
244 }
245
246 // Read() should detect the issue now and throw
247 const auto db{make_db(path, /*force_compact=*/false)};
248 uint256 result;
249 BOOST_CHECK_EXCEPTION(db.Read(key, result), dbwrapper_error, HasReason("Fatal LevelDB error"));
250
251 // TryRead() must return DatabaseError (without throwing).
252 CDBWrapper::ReadStatus status = db.TryRead(key, result);
253 BOOST_REQUIRE(!status);
255 BOOST_CHECK(status.error().err_msg.find("Fatal LevelDB error") != std::string::npos);
256}
257
258// Exercise TryRead() return values directly: found, absent and DeserializationError.
259// DatabaseError is tested inside 'dbwrapper_read_throws_on_db_error' test
260BOOST_AUTO_TEST_CASE(dbwrapper_tryread)
261{
262 for (const bool obfuscate : {false, true}) {
263 const fs::path path{m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_tryread_obf" : "dbwrapper_tryread_noobf")};
264 CDBWrapper dbw({.path = path, .cache_bytes = 1 << 20, .wipe_data = true, .obfuscate = obfuscate});
265
266 constexpr uint8_t key_ok{'A'};
267 constexpr uint8_t key_missing{'B'};
268 constexpr uint8_t key_bad{'C'};
269
270 uint256 written_value{m_rng.rand256()};
271 dbw.Write(key_ok, written_value);
272 dbw.Write(key_bad, uint8_t{0xFF});
273
274 // Found: key exists, value deserializes correctly
275 {
276 uint256 read_value;
277 CDBWrapper::ReadStatus status = dbw.TryRead(key_ok, read_value);
278 BOOST_REQUIRE(status);
279 BOOST_CHECK(status.value());
280 BOOST_CHECK_EQUAL(read_value, written_value);
281 }
282
283 // Absent: key does not exist
284 {
285 uint256 read_value;
286 CDBWrapper::ReadStatus status = dbw.TryRead(key_missing, read_value);
287 BOOST_REQUIRE(status);
288 BOOST_CHECK(!status.value());
289 }
290
291 // DeserializationError: key exists but stored value is too short
292 {
293 uint256 read_value;
294 CDBWrapper::ReadStatus status = dbw.TryRead(key_bad, read_value);
295 BOOST_REQUIRE(!status);
297 BOOST_CHECK(!status.error().err_msg.empty());
298 }
299 }
300}
301
302BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
303{
304 // Perform tests both obfuscated and non-obfuscated.
305 for (const bool obfuscate : {false, true}) {
306 fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_iterator_obfuscate_true" : "dbwrapper_iterator_obfuscate_false");
307 CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = obfuscate});
308
309 // The two keys are intentionally chosen for ordering
310 uint8_t key{'j'};
311 uint256 in = m_rng.rand256();
312 dbw.Write(key, in);
313 uint8_t key2{'k'};
314 uint256 in2 = m_rng.rand256();
315 dbw.Write(key2, in2);
316
317 std::unique_ptr<CDBIterator> it(dbw.NewIterator());
318
319 // Be sure to seek past the obfuscation key (if it exists)
320 it->Seek(key);
321
322 // A failed key decode must not consume the current iterator entry.
323 uint16_t key_too_large{0};
324 BOOST_CHECK(!it->GetKey(key_too_large));
325
326 uint8_t key_res;
327
328 BOOST_REQUIRE(it->GetKey(key_res));
329 BOOST_CHECK_EQUAL(key_res, key);
330 // A failed value decode must not leave the iterator's scratch stream dirty.
331 std::pair<uint256, uint8_t> value_too_large;
332 BOOST_CHECK(!it->GetValue(value_too_large));
333
334 uint256 val_res;
335 BOOST_REQUIRE(it->GetValue(val_res));
336 BOOST_CHECK_EQUAL(val_res.ToString(), in.ToString());
337
338 it->Seek(key2);
339
340 BOOST_REQUIRE(it->GetKey(key_res));
341 BOOST_CHECK_EQUAL(key_res, key2);
342 BOOST_REQUIRE(it->GetValue(val_res));
343 BOOST_CHECK_EQUAL(val_res.ToString(), in2.ToString());
344
345 it->Seek(key);
346
347 BOOST_REQUIRE(it->GetKey(key_res));
348 BOOST_CHECK_EQUAL(key_res, key);
349 BOOST_REQUIRE(it->GetValue(val_res));
350 BOOST_CHECK_EQUAL(val_res.ToString(), in.ToString());
351
352 it->Next();
353
354 BOOST_REQUIRE(it->GetKey(key_res));
355 BOOST_CHECK_EQUAL(key_res, key2);
356 BOOST_REQUIRE(it->GetValue(val_res));
357 BOOST_CHECK_EQUAL(val_res.ToString(), in2.ToString());
358
359 it->Next();
360 BOOST_CHECK_EQUAL(it->Valid(), false);
361 }
362}
363
364// Test that we do not obfuscation if there is existing data.
365BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
366{
367 // We're going to share this fs::path between two wrappers
368 fs::path ph = m_args.GetDataDirBase() / "existing_data_no_obfuscate";
369 fs::create_directories(ph);
370
371 // Set up a non-obfuscated wrapper to write some initial data.
372 std::unique_ptr<CDBWrapper> dbw = std::make_unique<CDBWrapper>(DBParams{.path = ph, .cache_bytes = 1 << 10, .memory_only = false, .wipe_data = false, .obfuscate = false});
373 uint8_t key{'k'};
374 uint256 in = m_rng.rand256();
375 uint256 res;
376
377 dbw->Write(key, in);
378 BOOST_CHECK(dbw->Read(key, res));
380
381 // Call the destructor to free leveldb LOCK
382 dbw.reset();
383
384 // Now, set up another wrapper that wants to obfuscate the same directory
385 CDBWrapper odbw({.path = ph, .cache_bytes = 1 << 10, .memory_only = false, .wipe_data = false, .obfuscate = true});
386
387 // Check that the key/val we wrote with unobfuscated wrapper exists and
388 // is readable.
389 uint256 res2;
390 BOOST_CHECK(odbw.Read(key, res2));
391 BOOST_CHECK_EQUAL(res2.ToString(), in.ToString());
392
393 BOOST_CHECK(!odbw.IsEmpty());
394 BOOST_CHECK(!dbwrapper_private::GetObfuscation(odbw)); // The key should be an empty string
395
396 uint256 in2 = m_rng.rand256();
397 uint256 res3;
398
399 // Check that we can write successfully
400 odbw.Write(key, in2);
401 BOOST_CHECK(odbw.Read(key, res3));
402 BOOST_CHECK_EQUAL(res3.ToString(), in2.ToString());
403}
404
405// Ensure that we start obfuscating during a reindex.
406BOOST_AUTO_TEST_CASE(existing_data_reindex)
407{
408 // We're going to share this fs::path between two wrappers
409 fs::path ph = m_args.GetDataDirBase() / "existing_data_reindex";
410 fs::create_directories(ph);
411
412 // Set up a non-obfuscated wrapper to write some initial data.
413 std::unique_ptr<CDBWrapper> dbw = std::make_unique<CDBWrapper>(DBParams{.path = ph, .cache_bytes = 1 << 10, .memory_only = false, .wipe_data = false, .obfuscate = false});
414 uint8_t key{'k'};
415 uint256 in = m_rng.rand256();
416 uint256 res;
417
418 dbw->Write(key, in);
419 BOOST_CHECK(dbw->Read(key, res));
421
422 // Call the destructor to free leveldb LOCK
423 dbw.reset();
424
425 // Simulate a -reindex by wiping the existing data store
426 CDBWrapper odbw({.path = ph, .cache_bytes = 1 << 10, .memory_only = false, .wipe_data = true, .obfuscate = true});
427
428 // Check that the key/val we wrote with unobfuscated wrapper doesn't exist
429 uint256 res2;
430 BOOST_CHECK(!odbw.Read(key, res2));
432
433 uint256 in2 = m_rng.rand256();
434 uint256 res3;
435
436 // Check that we can write successfully
437 odbw.Write(key, in2);
438 BOOST_CHECK(odbw.Read(key, res3));
439 BOOST_CHECK_EQUAL(res3.ToString(), in2.ToString());
440}
441
442BOOST_AUTO_TEST_CASE(iterator_ordering)
443{
444 fs::path ph = m_args.GetDataDirBase() / "iterator_ordering";
445 CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = false});
446 for (int x=0x00; x<256; ++x) {
447 uint8_t key = x;
448 uint32_t value = x*x;
449 if (!(x & 1)) dbw.Write(key, value);
450 }
451
452 // Check that creating an iterator creates a snapshot
453 std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());
454
455 for (unsigned int x=0x00; x<256; ++x) {
456 uint8_t key = x;
457 uint32_t value = x*x;
458 if (x & 1) dbw.Write(key, value);
459 }
460
461 for (const int seek_start : {0x00, 0x80}) {
462 it->Seek((uint8_t)seek_start);
463 for (unsigned int x=seek_start; x<255; ++x) {
464 uint8_t key;
465 uint32_t value;
466 BOOST_CHECK(it->Valid());
467 if (!it->Valid()) // Avoid spurious errors about invalid iterator's key and value in case of failure
468 break;
469 BOOST_CHECK(it->GetKey(key));
470 if (x & 1) {
471 BOOST_CHECK_EQUAL(key, x + 1);
472 continue;
473 }
474 BOOST_CHECK(it->GetValue(value));
475 BOOST_CHECK_EQUAL(key, x);
476 BOOST_CHECK_EQUAL(value, x*x);
477 it->Next();
478 }
479 BOOST_CHECK(!it->Valid());
480 }
481}
482
484 // Used to make two serialized objects the same while letting them have different lengths
485 // This is a terrible idea
486 std::string str;
488 explicit StringContentsSerializer(const std::string& inp) : str(inp) {}
489
490 template<typename Stream>
491 void Serialize(Stream& s) const
492 {
493 for (size_t i = 0; i < str.size(); i++) {
494 s << uint8_t(str[i]);
495 }
496 }
497
498 template<typename Stream>
500 {
501 str.clear();
502 uint8_t c{0};
503 while (!s.empty()) {
504 s >> c;
505 str.push_back(c);
506 }
507 }
508};
509
510BOOST_AUTO_TEST_CASE(iterator_string_ordering)
511{
512 fs::path ph = m_args.GetDataDirBase() / "iterator_string_ordering";
513 CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = false});
514 for (int x = 0; x < 10; ++x) {
515 for (int y = 0; y < 10; ++y) {
516 std::string key{ToString(x)};
517 for (int z = 0; z < y; ++z)
518 key += key;
519 uint32_t value = x*x;
520 dbw.Write(StringContentsSerializer{key}, value);
521 }
522 }
523
524 std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());
525 for (const int seek_start : {0, 5}) {
526 it->Seek(StringContentsSerializer{ToString(seek_start)});
527 for (unsigned int x = seek_start; x < 10; ++x) {
528 for (int y = 0; y < 10; ++y) {
529 std::string exp_key{ToString(x)};
530 for (int z = 0; z < y; ++z)
531 exp_key += exp_key;
533 uint32_t value;
534 BOOST_CHECK(it->Valid());
535 if (!it->Valid()) // Avoid spurious errors about invalid iterator's key and value in case of failure
536 break;
537 BOOST_CHECK(it->GetKey(key));
538 BOOST_CHECK(it->GetValue(value));
539 BOOST_CHECK_EQUAL(key.str, exp_key);
540 BOOST_CHECK_EQUAL(value, x*x);
541 it->Next();
542 }
543 }
544 BOOST_CHECK(!it->Valid());
545 }
546}
547
549{
550 // Attempt to create a database with a UTF8 character in the path.
551 // On Windows this test will fail if the directory is created using
552 // the ANSI CreateDirectoryA call and the code page isn't UTF8.
553 // It will succeed if created with CreateDirectoryW.
554 fs::path ph = m_args.GetDataDirBase() / "test_runner_₿_🏃_20191128_104644";
555 CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB});
556
557 fs::path lockPath = ph / "LOCK";
558 BOOST_CHECK(fs::exists(lockPath));
559}
560
561
Batch of changes queued to be written to a CDBWrapper.
Definition: dbwrapper.h:89
void Erase(const K &key)
Definition: dbwrapper.h:122
void Write(const K &key, const V &value)
Definition: dbwrapper.h:113
void Clear()
Definition: dbwrapper.cpp:195
bool Read(const K &key, V &value) const
Wrapper around TryRead() that preserves the original Read() semantics: returns true on success,...
Definition: dbwrapper.h:287
void Write(const K &key, const V &value, bool fSync=false)
Definition: dbwrapper.h:299
ReadStatus TryRead(const K &key, V &value) const
Read and deserialize a value from the database, with explicit error discrimination.
Definition: dbwrapper.h:249
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
Definition: common.h:19
std::string ToString() const
Definition: uint256.cpp:21
256-bit opaque blob.
Definition: uint256.h:196
The util::Expected class provides a standard way for low-level functions to return either error value...
Definition: expected.h:44
constexpr const T & value() const &LIFETIMEBOUND
Definition: expected.h:59
constexpr const E & error() const &noexcept LIFETIMEBOUND
Definition: expected.h:86
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(dbwrapper)
static bool exists(const path &p)
Definition: fs.h:94
BOOST_CHECK_EQUAL(headers.FindFirst("key"), "value")
BOOST_CHECK_EXCEPTION(HTTPHeaders{}.Read(reader), std::runtime_error, HasReason{"Empty HTTP header name"})
const Obfuscation & GetObfuscation(const CDBWrapper &w)
Work around circular dependency, as well as for testing in dbwrapper_tests.
Definition: dbwrapper.cpp:434
SocketId Stream
Definition: util.h:30
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:250
#define BOOST_CHECK(expr)
Definition: object.cpp:16
Basic testing setup.
Definition: setup_common.h:58
@ DeserializationError
Key exists but value could not be deserialized.
@ DatabaseError
Unexpected internal DB error.
Application-specific storage settings.
Definition: dbwrapper.h:42
fs::path path
Location in the filesystem where leveldb data will be stored.
Definition: dbwrapper.h:44
StringContentsSerializer()=default
void Serialize(Stream &s) const
StringContentsSerializer(const std::string &inp)
CDBWrapper db
Definition: dbwrapper.cpp:371
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1172