33 auto const integrityWarning =
34 "reducing the data integrity guarantees from the "
35 "default [sqlite] behavior is not recommended for "
36 "nodes storing large amounts of history, because of the "
37 "difficulty inherent in rebuilding corrupted data.";
44 if (BEAST_EXPECT(s.globalPragma->size() == 3))
46 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
47 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
48 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
59 auto& section = p->section(
"sqlite");
60 section.set(
"safety_level",
"high");
62 p->LEDGER_HISTORY = 100'000'000;
73 if (BEAST_EXPECT(s.globalPragma->size() == 3))
75 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
76 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
77 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
88 auto& section = p->section(
"sqlite");
89 section.set(
"safety_level",
"low");
91 p->LEDGER_HISTORY = 100'000'000;
102 if (BEAST_EXPECT(s.globalPragma->size() == 3))
104 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=memory;");
105 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=off;");
106 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=memory;");
117 auto& section = p->section(
"sqlite");
118 section.set(
"journal_mode",
"off");
119 section.set(
"synchronous",
"extra");
120 section.set(
"temp_store",
"default");
132 BEAST_EXPECT(!found);
134 if (BEAST_EXPECT(s.globalPragma->size() == 3))
136 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
137 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
138 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
149 auto& section = p->section(
"sqlite");
150 section.set(
"journal_mode",
"off");
151 section.set(
"synchronous",
"extra");
152 section.set(
"temp_store",
"default");
154 p->LEDGER_HISTORY = 50'000'000;
167 if (BEAST_EXPECT(s.globalPragma->size() == 3))
169 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
170 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
171 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
177 auto const expected =
178 "Failed to initialize SQL databases: "
179 "Configuration file may not define both \"safety_level\" and "
185 auto& section = p->section(
"sqlite");
186 section.set(
"safety_level",
"low");
187 section.set(
"journal_mode",
"off");
188 section.set(
"synchronous",
"extra");
189 section.set(
"temp_store",
"default");
209 auto const expected =
210 "Failed to initialize SQL databases: Configuration file may "
211 "not define both \"safety_level\" and \"journal_mode\"";
216 auto& section = p->section(
"sqlite");
217 section.set(
"safety_level",
"high");
218 section.set(
"journal_mode",
"off");
238 auto const expected =
239 "Failed to initialize SQL databases: Configuration file may "
240 "not define both \"safety_level\" and \"synchronous\"";
245 auto& section = p->section(
"sqlite");
246 section.set(
"safety_level",
"low");
247 section.set(
"synchronous",
"extra");
267 auto const expected =
268 "Failed to initialize SQL databases: Configuration file may "
269 "not define both \"safety_level\" and \"temp_store\"";
274 auto& section = p->section(
"sqlite");
275 section.set(
"safety_level",
"high");
276 section.set(
"temp_store",
"default");
296 auto const expected =
297 "Failed to initialize SQL databases: Invalid safety_level "
303 auto& section = p->section(
"sqlite");
304 section.set(
"safety_level",
"slow");
324 auto const expected =
325 "Failed to initialize SQL databases: Invalid journal_mode "
331 auto& section = p->section(
"sqlite");
332 section.set(
"journal_mode",
"fast");
352 auto const expected =
353 "Failed to initialize SQL databases: Invalid synchronous "
359 auto& section = p->section(
"sqlite");
360 section.set(
"synchronous",
"instant");
380 auto const expected =
381 "Failed to initialize SQL databases: Invalid temp_store "
387 auto& section = p->section(
"sqlite");
388 section.set(
"temp_store",
"network");
409 if (BEAST_EXPECT(s.txPragma.size() == 4))
411 BEAST_EXPECT(s.txPragma.at(0) ==
"PRAGMA page_size=4096;");
412 BEAST_EXPECT(s.txPragma.at(1) ==
"PRAGMA journal_size_limit=1582080;");
413 BEAST_EXPECT(s.txPragma.at(2) ==
"PRAGMA max_page_count=4294967294;");
414 BEAST_EXPECT(s.txPragma.at(3) ==
"PRAGMA mmap_size=17179869184;");
422 auto& section = p->section(
"sqlite");
423 section.set(
"page_size",
"512");
424 section.set(
"journal_size_limit",
"2582080");
426 return Env(*
this, std::move(p));
429 if (BEAST_EXPECT(s.txPragma.size() == 4))
431 BEAST_EXPECT(s.txPragma.at(0) ==
"PRAGMA page_size=512;");
432 BEAST_EXPECT(s.txPragma.at(1) ==
"PRAGMA journal_size_limit=2582080;");
433 BEAST_EXPECT(s.txPragma.at(2) ==
"PRAGMA max_page_count=4294967294;");
434 BEAST_EXPECT(s.txPragma.at(3) ==
"PRAGMA mmap_size=17179869184;");
439 auto const expected =
"Invalid page_size. Must be between 512 and 65536.";
443 auto& section = p->section(
"sqlite");
444 section.set(
"page_size",
"256");
462 auto const expected =
"Invalid page_size. Must be between 512 and 65536.";
466 auto& section = p->section(
"sqlite");
467 section.set(
"page_size",
"131072");
485 auto const expected =
"Invalid page_size. Must be a power of 2.";
489 auto& section = p->section(
"sqlite");
490 section.set(
"page_size",
"513");
517 srcParams.
set(
"type", srcBackendType);
518 srcParams.
set(
"path", node_db.
path());
540 destParams.
set(
"type", destBackendType);
541 destParams.
set(
"path", dest_db.
path());
546 testcase(
"import into '" + destBackendType +
"' from '" + srcBackendType +
"'");
549 dest->importDatabase(*src);
566 bool const testPersistence,
568 int numObjsToTest = 2000)
572 std::string s =
"NodeStore backend '" + type +
"'";
578 nodeParams.
set(
"type", type);
579 nodeParams.
set(
"path", node_db.
path());
626 if (type ==
"memory")
638 nodeParams.
set(
"earliest_seq",
"0");
649 nodeParams.
set(
"earliest_seq",
"1");
654 BEAST_EXPECT(db->earliestLedgerSeq() == 1);
667 BEAST_EXPECT(
std::strcmp(e.
what(),
"earliest_seq set more than once") == 0);