34 auto const integrityWarning =
35 "reducing the data integrity guarantees from the "
36 "default [sqlite] behavior is not recommended for "
37 "nodes storing large amounts of history, because of the "
38 "difficulty inherent in rebuilding corrupted data.";
45 if (BEAST_EXPECT(s.globalPragma->size() == 3))
47 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
48 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
49 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
60 auto& section = p->section(
"sqlite");
61 section.set(
"safety_level",
"high");
63 p->LEDGER_HISTORY = 100'000'000;
74 if (BEAST_EXPECT(s.globalPragma->size() == 3))
76 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
77 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
78 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
89 auto& section = p->section(
"sqlite");
90 section.set(
"safety_level",
"low");
92 p->LEDGER_HISTORY = 100'000'000;
103 if (BEAST_EXPECT(s.globalPragma->size() == 3))
105 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=memory;");
106 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=off;");
107 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=memory;");
118 auto& section = p->section(
"sqlite");
119 section.set(
"journal_mode",
"off");
120 section.set(
"synchronous",
"extra");
121 section.set(
"temp_store",
"default");
133 BEAST_EXPECT(!found);
135 if (BEAST_EXPECT(s.globalPragma->size() == 3))
137 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
138 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
139 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
150 auto& section = p->section(
"sqlite");
151 section.set(
"journal_mode",
"off");
152 section.set(
"synchronous",
"extra");
153 section.set(
"temp_store",
"default");
155 p->LEDGER_HISTORY = 50'000'000;
168 if (BEAST_EXPECT(s.globalPragma->size() == 3))
170 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
171 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
172 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
178 auto const expected =
179 "Failed to initialize SQL databases: "
180 "Configuration file may not define both \"safety_level\" and "
186 auto& section = p->section(
"sqlite");
187 section.set(
"safety_level",
"low");
188 section.set(
"journal_mode",
"off");
189 section.set(
"synchronous",
"extra");
190 section.set(
"temp_store",
"default");
210 auto const expected =
211 "Failed to initialize SQL databases: Configuration file may "
212 "not define both \"safety_level\" and \"journal_mode\"";
217 auto& section = p->section(
"sqlite");
218 section.set(
"safety_level",
"high");
219 section.set(
"journal_mode",
"off");
239 auto const expected =
240 "Failed to initialize SQL databases: Configuration file may "
241 "not define both \"safety_level\" and \"synchronous\"";
246 auto& section = p->section(
"sqlite");
247 section.set(
"safety_level",
"low");
248 section.set(
"synchronous",
"extra");
268 auto const expected =
269 "Failed to initialize SQL databases: Configuration file may "
270 "not define both \"safety_level\" and \"temp_store\"";
275 auto& section = p->section(
"sqlite");
276 section.set(
"safety_level",
"high");
277 section.set(
"temp_store",
"default");
297 auto const expected =
298 "Failed to initialize SQL databases: Invalid safety_level "
304 auto& section = p->section(
"sqlite");
305 section.set(
"safety_level",
"slow");
325 auto const expected =
326 "Failed to initialize SQL databases: Invalid journal_mode "
332 auto& section = p->section(
"sqlite");
333 section.set(
"journal_mode",
"fast");
353 auto const expected =
354 "Failed to initialize SQL databases: Invalid synchronous "
360 auto& section = p->section(
"sqlite");
361 section.set(
"synchronous",
"instant");
381 auto const expected =
382 "Failed to initialize SQL databases: Invalid temp_store "
388 auto& section = p->section(
"sqlite");
389 section.set(
"temp_store",
"network");
410 if (BEAST_EXPECT(s.txPragma.size() == 4))
412 BEAST_EXPECT(s.txPragma.at(0) ==
"PRAGMA page_size=4096;");
413 BEAST_EXPECT(s.txPragma.at(1) ==
"PRAGMA journal_size_limit=1582080;");
414 BEAST_EXPECT(s.txPragma.at(2) ==
"PRAGMA max_page_count=4294967294;");
415 BEAST_EXPECT(s.txPragma.at(3) ==
"PRAGMA mmap_size=17179869184;");
423 auto& section = p->section(
"sqlite");
424 section.set(
"page_size",
"512");
425 section.set(
"journal_size_limit",
"2582080");
427 return Env(*
this, std::move(p));
430 if (BEAST_EXPECT(s.txPragma.size() == 4))
432 BEAST_EXPECT(s.txPragma.at(0) ==
"PRAGMA page_size=512;");
433 BEAST_EXPECT(s.txPragma.at(1) ==
"PRAGMA journal_size_limit=2582080;");
434 BEAST_EXPECT(s.txPragma.at(2) ==
"PRAGMA max_page_count=4294967294;");
435 BEAST_EXPECT(s.txPragma.at(3) ==
"PRAGMA mmap_size=17179869184;");
440 auto const expected =
"Invalid page_size. Must be between 512 and 65536.";
444 auto& section = p->section(
"sqlite");
445 section.set(
"page_size",
"256");
463 auto const expected =
"Invalid page_size. Must be between 512 and 65536.";
467 auto& section = p->section(
"sqlite");
468 section.set(
"page_size",
"131072");
486 auto const expected =
"Invalid page_size. Must be a power of 2.";
490 auto& section = p->section(
"sqlite");
491 section.set(
"page_size",
"513");
518 srcParams.
set(
"type", srcBackendType);
519 srcParams.
set(
"path", node_db.
path());
541 destParams.
set(
"type", destBackendType);
542 destParams.
set(
"path", dest_db.
path());
547 testcase(
"import into '" + destBackendType +
"' from '" + srcBackendType +
"'");
550 dest->importDatabase(*src);
567 bool const testPersistence,
569 int numObjsToTest = 2000)
573 std::string s =
"NodeStore backend '" + type +
"'";
579 nodeParams.
set(
"type", type);
580 nodeParams.
set(
"path", node_db.
path());
627 if (type ==
"memory")
639 nodeParams.
set(
"earliest_seq",
"0");
650 nodeParams.
set(
"earliest_seq",
"1");
655 BEAST_EXPECT(db->earliestLedgerSeq() == 1);
668 BEAST_EXPECT(
std::strcmp(e.
what(),
"earliest_seq set more than once") == 0);