1#include <test/jtx/TestSuite.h>
2#include <test/unit_test/FileDirGuard.h>
4#include <xrpld/core/Config.h>
5#include <xrpld/core/ConfigSections.h>
7#include <xrpl/beast/unit_test/suite.h>
8#include <xrpl/beast/utility/temp_dir.h>
9#include <xrpl/server/Port.h>
11#include <boost/filesystem.hpp>
12#include <boost/format.hpp>
22 static boost::format configContentsTemplate(R
"xrpldConfig(
50#-------------------------------------------------------------------------------
55# This is primary persistent datastore for xrpld. This includes transaction
56# metadata, account states, and ledger headers. Helpful information can be
57# found on https://xrpl.org/capacity-planning.html#node-db-type
58# delete old ledgers while maintaining at least 2000. Do not require an
59# external administrative command to initiate deletion.
62path=/Users/dummy/xrpld/config/db/rocksdb
73# This needs to be an absolute directory reference, not a relative one.
74# Modify this value as required.
76/Users/dummy/xrpld/config/log/debug.log
84# Where to find some other servers speaking the Ripple protocol.
89# Turn down default logging to save disk space in the long run.
90# Valid values here are trace, debug, info, warning, error, and fatal
92{ "command": "log_level", "severity": "warning" }
94# Defaults to 1 ("yes") so that certificates will be validated. To allow the use
95# of self-signed certificates for development or internal use, set to 0 ("no").
104 dbPath.empty() ? "" :
"[database_path]\n" + dbPath;
106 validatorsFile.
empty() ?
"" :
"[validators_file]\n" + validatorsFile;
107 return boost::str(configContentsTemplate % dbPathSection % valFileSection);
128 path const& validatorsFile,
129 bool useCounter =
true,
167 return boost::filesystem::is_directory(
dataDir_);
180 using namespace boost::filesystem;
197n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7
198n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj
199n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C
200n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS
201n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA
204nHUhG1PgAG8H8myUENypM35JgfqXAKNQvRVVAFDRzJrny5eZN8d5
205nHBu9PTL9dn2GuZtdW4U2WzBwffyX9qsQCd9CNU4Z5YG3PQfViM8
206nHUPDdcdb2Y5DZAJne4c2iabFuAP3F34xZUgYQT2NH7qfkdapgnz
208[validator_list_sites]
209recommended-xrpl-validators.com
210more-xrpl-validators.net
21303E74EE14CB525AFBB9F1B7D86CD58ECC4B91452294B42AB4E78F260BD905C091D
214030775A669685BD6ABCEBD80385921C7851783D991A8055FD21D2F3966C96F1B56
216[validator_list_threshold]
231 path const& validatorsFileName,
232 bool useCounter =
true)
237 validatorsFileName.empty() ?
Config::validatorsFileName
238 : validatorsFileName),
253 return absolute(
file()).string();
265 using path = boost::filesystem::path;
287 BEAST_EXPECT(c.legacy("ssl_verify") ==
"0");
291 BEAST_EXPECT(c.
legacy(
"not_in_file") ==
"");
292 c.
legacy(
"not_in_file",
"new_value");
293 BEAST_EXPECT(c.
legacy(
"not_in_file") ==
"new_value");
300 using namespace boost::filesystem;
301 auto const cwd = current_path();
304 char const* configFiles[] = {
308 for (
auto const& configFile : configFiles)
312 current_path(td.
path());
320 c.
setup(
"",
true,
false,
true);
324 "/Users/dummy/xrpld/config/log/debug.log");
328#if BOOST_OS_LINUX || BOOST_OS_MACOS
329 for (
auto const& configFile : configFiles)
334 current_path(td.
path());
344 char const* h = getenv(
"HOME");
346 char const* x = getenv(
"XDG_CONFIG_HOME");
347 setenv(
"XDG_CONFIG_HOME", tc.
path().
c_str(), 1);
359 c.
setup(
"",
true,
false,
true);
364 "/Users/dummy/xrpld/config/log/debug.log");
367 h ? setenv(
"HOME", h, 1) : unsetenv(
"HOME");
368 x ? setenv(
"XDG_CONFIG_HOME", x, 1)
369 : unsetenv(
"XDG_CONFIG_HOME");
378 char const* h = getenv(
"HOME");
380 char const* x = getenv(
"XDG_CONFIG_HOME");
381 unsetenv(
"XDG_CONFIG_HOME");
390 p = tc.
file(s +
"/" + configFile);
397 c.
setup(
"",
true,
false,
true);
402 "/Users/dummy/xrpld/config/log/debug.log");
405 h ? setenv(
"HOME", h, 1) : unsetenv(
"HOME");
407 setenv(
"XDG_CONFIG_HOME", x, 1);
420 using namespace boost::filesystem;
422 boost::format cc(
"[database_path]\n%1%\n");
424 auto const cwd = current_path();
425 path const dataDirRel(
"test_data_dir");
426 path const dataDirAbs(cwd / dataDirRel);
431 BEAST_EXPECT(c.
legacy(
"database_path") == dataDirAbs.string());
437 BEAST_EXPECT(c.
legacy(
"database_path") == dataDirAbs.string());
445 BEAST_EXPECT(c.
legacy(
"database_path") ==
"");
450 auto const cwd = current_path();
452 path const dataDirRel(
"test_data_dir");
453 path const dataDirAbs(cwd / g0.
subdir() / dataDirRel);
461 auto const& c(g.
config());
464 BEAST_EXPECT(c.legacy(
"database_path") == dataDirAbs.string());
471 auto const& c(g.
config());
475 BEAST_EXPECT(c.legacy(
"database_path") == nativeDbPath);
481 auto const& c(g.
config());
486 BEAST_EXPECT(c.legacy(
"database_path") == nativeDbPath);
498 "eyJ2YWxpZGF0aW9uX3ByaXZhdGVfa2V5IjoiOWVkNDVmODY2MjQxY2MxOGEyNzQ3Yj"
499 "U0Mzg3YzA2MjU5MDc5NzJmNGU3MTkwMjMxZmFhOTM3NDU3ZmE5ZGFmNiIsIm1hbmlm"
500 "ZXN0IjoiSkFBQUFBRnhJZTFGdHdtaW12R3RIMmlDY01KcUM5Z1ZGS2lsR2Z3MS92Q3"
501 "hIWFhMcGxjMkduTWhBa0UxYWdxWHhCd0R3RGJJRDZPTVNZdU0wRkRBbHBBZ05rOFNL"
502 "Rm43TU8yZmRrY3dSUUloQU9uZ3U5c0FLcVhZb3VKK2wyVjBXK3NBT2tWQitaUlM2UF"
503 "NobEpBZlVzWGZBaUJzVkpHZXNhYWRPSmMvYUFab2tTMXZ5bUdtVnJsSFBLV1gzWXl3"
504 "dTZpbjhIQVNRS1B1Z0JENjdrTWFSRkd2bXBBVEhsR0tKZHZERmxXUFl5NUFxRGVkRn"
505 "Y1VEphMncwaTIxZXEzTVl5d0xWSlpuRk9yN0Mwa3cyQWlUelNDakl6ZGl0UTg9In0"
510 static boost::format configTemplate(R
"xrpldConfig(
518 auto const expectedError =
519 "Cannot have both [validation_seed] "
520 "and [validator_token] config sections";
530 BEAST_EXPECT(error == expectedError);
552 BEAST_EXPECT(error ==
"");
565 BEAST_EXPECT(error ==
"");
580 BEAST_EXPECT(error ==
"");
595 BEAST_EXPECT(error ==
"");
604 using namespace boost::filesystem;
607 boost::format cc(
"[validators_file]\n%1%\n");
609 std::string const missingPath =
"/no/way/this/path/exists";
610 auto const expectedError =
611 "The file specified in [validators_file] does not exist: " +
622 BEAST_EXPECT(error == expectedError);
627 *
this,
"test_cfg",
"validators.cfg");
628 path const invalidFile = current_path() / vtg.
subdir();
629 boost::format cc(
"[validators_file]\n%1%\n");
631 auto const expectedError =
632 "Invalid file specified in [validators_file]: " +
633 invalidFile.string();
643 BEAST_EXPECT(error == expectedError);
650n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7
651n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj
652n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C
655nHUhG1PgAG8H8myUENypM35JgfqXAKNQvRVVAFDRzJrny5eZN8d5
656nHBu9PTL9dn2GuZtdW4U2WzBwffyX9qsQCd9CNU4Z5YG3PQfViM8
659 BEAST_EXPECT(c.legacy("validators_file").empty());
667[validator_list_sites]
669trustthesevalidators.gov
672021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566
674[validator_list_threshold]
682 "xrplvalidators.com");
685 "trustthesevalidators.gov");
690 "021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801"
696 c.
section(SECTION_VALIDATOR_LIST_THRESHOLD).
values()[0] ==
"1");
703[validator_list_sites]
705trustthesevalidators.gov
708021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566
710[validator_list_threshold]
718 "xrplvalidators.com");
721 "trustthesevalidators.gov");
726 "021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801"
732 c.
section(SECTION_VALIDATOR_LIST_THRESHOLD).
values()[0] ==
"0");
740[validator_list_sites]
742trustthesevalidators.gov
745021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566
747[validator_list_threshold]
751 auto const expectedError =
752 "Value in config section [validator_list_threshold] exceeds "
753 "the number of configured list keys";
763 BEAST_EXPECT(error == expectedError);
769[validator_list_sites]
771trustthesevalidators.gov
774021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566
776[validator_list_threshold]
780 auto const expectedError =
781 "Config section [validator_list_threshold] should contain "
792 BEAST_EXPECT(error == expectedError);
798[validator_list_sites]
800trustthesevalidators.gov
803021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566
805[validator_list_threshold]
825[validator_list_sites]
827trustthesevalidators.gov
830 auto const expectedError =
831 "[validator_list_keys] config section is missing";
841 BEAST_EXPECT(error == expectedError);
846 *
this,
"test_cfg",
"validators.cfg");
849 boost::format cc(
"[validators_file]\n%1%\n");
867 *
this,
"test_cfg", valFileName);
877 auto const& c(rcg.
config());
878 BEAST_EXPECT(c.legacy(
"validators_file") == valFileName);
879 BEAST_EXPECT(c.section(SECTION_VALIDATORS).values().size() == 8);
881 c.section(SECTION_VALIDATOR_LIST_SITES).values().size() == 2);
883 c.section(SECTION_VALIDATOR_LIST_KEYS).values().size() == 2);
885 c.section(SECTION_VALIDATOR_LIST_THRESHOLD).values().size() ==
887 BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2);
893 *
this,
"test_cfg",
"validators.txt");
894 auto const valFilePath =
".." / vtg.
subdir() /
"validators.txt";
904 auto const& c(rcg.
config());
905 BEAST_EXPECT(c.legacy(
"validators_file") == valFilePath);
906 BEAST_EXPECT(c.section(SECTION_VALIDATORS).values().size() == 8);
908 c.section(SECTION_VALIDATOR_LIST_SITES).values().size() == 2);
910 c.section(SECTION_VALIDATOR_LIST_KEYS).values().size() == 2);
912 c.section(SECTION_VALIDATOR_LIST_THRESHOLD).values().size() ==
914 BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2);
919 *
this,
"test_cfg",
"validators.txt");
924 auto const& c(rcg.
config());
925 BEAST_EXPECT(c.legacy(
"validators_file").empty());
926 BEAST_EXPECT(c.section(SECTION_VALIDATORS).values().size() == 8);
928 c.section(SECTION_VALIDATOR_LIST_SITES).values().size() == 2);
930 c.section(SECTION_VALIDATOR_LIST_KEYS).values().size() == 2);
932 c.section(SECTION_VALIDATOR_LIST_THRESHOLD).values().size() ==
934 BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2);
940 *
this,
"test_cfg",
"validators.cfg");
943 *
this, vtg.
subdir(),
"validators.txt",
false);
953 auto const& c(rcg.
config());
954 BEAST_EXPECT(c.legacy(
"validators_file") == vtg.
validatorsFile());
955 BEAST_EXPECT(c.section(SECTION_VALIDATORS).values().size() == 8);
957 c.section(SECTION_VALIDATOR_LIST_SITES).values().size() == 2);
959 c.section(SECTION_VALIDATOR_LIST_KEYS).values().size() == 2);
961 c.section(SECTION_VALIDATOR_LIST_THRESHOLD).values().size() ==
963 BEAST_EXPECT(c.VALIDATOR_LIST_THRESHOLD == 2);
968 boost::format cc(R
"xrpldConfig(
973n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7
974n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj
975n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C
976n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS
977n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA
980nHB1X37qrniVugfQcuBTAjswphC1drx7QjFFojJPZwKHHnt8kU7v
981nHUkAWDR4cB8AgPg7VXMX6et8xRTQb2KJfgv1aBEXozwrawRKgMB
983[validator_list_sites]
985trustthesevalidators.gov
988021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566
991 *
this,
"test_cfg",
"validators.cfg");
1009 boost::format cc(R
"xrpldConfig(
1013[validator_list_threshold]
1018 *
this,
"test_cfg",
"validators.cfg");
1020 auto const expectedError =
1021 "Config section [validator_list_threshold] should contain "
1022 "single value only";
1033 BEAST_EXPECT(error == expectedError);
1040 boost::format cc(
"[validators_file]\n%1%\n");
1043 *
this,
"test_cfg",
"validators.cfg");
1045 auto const expectedError =
1046 "The file specified in [validators_file] does not contain a "
1047 "[validators], [validator_keys] or [validator_list_keys] "
1060 BEAST_EXPECT(error == expectedError);
1070 explicitPath ?
"test_db" :
"",
1084 BEAST_EXPECT(!config.
quiet());
1085 BEAST_EXPECT(!config.
silent());
1088 BEAST_EXPECT(!config.
legacy(
"database_path").empty());
1097 BEAST_EXPECT(config.
quiet());
1098 BEAST_EXPECT(!config.
silent());
1101 BEAST_EXPECT(!config.
legacy(
"database_path").empty());
1110 BEAST_EXPECT(config.
quiet());
1111 BEAST_EXPECT(config.
silent());
1114 BEAST_EXPECT(!config.
legacy(
"database_path").empty());
1123 BEAST_EXPECT(config.
quiet());
1124 BEAST_EXPECT(config.
silent());
1127 BEAST_EXPECT(!config.
legacy(
"database_path").empty());
1136 BEAST_EXPECT(!config.
quiet());
1137 BEAST_EXPECT(!config.
silent());
1141 config.
legacy(
"database_path").empty() == !explicitPath);
1150 BEAST_EXPECT(config.
quiet());
1151 BEAST_EXPECT(!config.
silent());
1155 config.
legacy(
"database_path").empty() == !explicitPath);
1164 BEAST_EXPECT(config.
quiet());
1165 BEAST_EXPECT(config.
silent());
1169 config.
legacy(
"database_path").empty() == !explicitPath);
1178 BEAST_EXPECT(config.
quiet());
1179 BEAST_EXPECT(config.
silent());
1183 config.
legacy(
"database_path").empty() == !explicitPath);
1192 auto const& conf = cfg.
config();
1193 if (!BEAST_EXPECT(conf.exists(
"port_rpc")))
1195 if (!BEAST_EXPECT(conf.exists(
"port_wss_admin")))
1225 BEAST_EXPECT(
false);
1230 "Invalid value '0' for key 'port'"));
1267 cfg.exists(SECTION_IPS) &&
1268 cfg.section(SECTION_IPS).lines().size() == 1 &&
1269 cfg.section(SECTION_IPS).values().size() == 1);
1271 cfg.exists(SECTION_IPS_FIXED) &&
1272 cfg.section(SECTION_IPS_FIXED).lines().size() == 2 &&
1273 cfg.section(SECTION_IPS_FIXED).values().size() == 2);
1302 anotherserversansport
1303 anotherserverwithport:12
1313 2001:db8:3333:4444:5555:6666:7777:8888:12345
1314 [2001:db8:3333:4444:5555:6666:7777:8888]:1
1323 cfg.
exists(SECTION_IPS) &&
1327 cfg.
exists(SECTION_IPS_FIXED) &&
1330 BEAST_EXPECT(cfg.
IPS[0] ==
"r.ripple.com 51235");
1332 BEAST_EXPECT(cfg.
IPS_FIXED[0] ==
"s1.ripple.com 51235");
1333 BEAST_EXPECT(cfg.
IPS_FIXED[1] ==
"s2.ripple.com 51235");
1334 BEAST_EXPECT(cfg.
IPS_FIXED[2] ==
"anotherserversansport");
1335 BEAST_EXPECT(cfg.
IPS_FIXED[3] ==
"anotherserverwithport 12");
1336 BEAST_EXPECT(cfg.
IPS_FIXED[4] ==
"1.1.1.1 1");
1337 BEAST_EXPECT(cfg.
IPS_FIXED[5] ==
"1.1.1.1 1");
1338 BEAST_EXPECT(cfg.
IPS_FIXED[6] ==
"12.34.12.123 12345");
1339 BEAST_EXPECT(cfg.
IPS_FIXED[7] ==
"12.34.12.123 12345");
1343 BEAST_EXPECT(cfg.
IPS_FIXED[9] ==
"2001:db8::");
1344 BEAST_EXPECT(cfg.
IPS_FIXED[10] ==
"::1");
1345 BEAST_EXPECT(cfg.
IPS_FIXED[11] ==
"::1:12345");
1346 BEAST_EXPECT(cfg.
IPS_FIXED[12] ==
"[::1]:12345");
1349 "2001:db8:3333:4444:5555:6666:7777:8888:12345");
1351 cfg.
IPS_FIXED[14] ==
"[2001:db8:3333:4444:5555:6666:7777:8888]:1");
1357 struct TestCommentData
1366 {{
"password = aaaa\\#bbbb",
"password",
"aaaa#bbbb",
false},
1367 {
"password = aaaa#bbbb",
"password",
"aaaa",
true},
1368 {
"password = aaaa #bbbb",
"password",
"aaaa",
true},
1370 {
"password = #aaaa #bbbb",
"",
"password =",
true},
1371 {
"password = aaaa\\# #bbbb",
"password",
"aaaa#",
true},
1372 {
"password = aaaa\\##bbbb",
"password",
"aaaa#",
true},
1373 {
"aaaa#bbbb",
"",
"aaaa",
true},
1374 {
"aaaa\\#bbbb",
"",
"aaaa#bbbb",
false},
1375 {
"aaaa\\##bbbb",
"",
"aaaa#",
true},
1376 {
"aaaa #bbbb",
"",
"aaaa",
true},
1377 {
"1 #comment",
"",
"1",
true},
1378 {
"#whole thing is comment",
"",
"",
false},
1379 {
" #whole comment with space",
"",
"",
false}}};
1381 for (
auto const& t : tests)
1384 s.append(t.line.data());
1385 BEAST_EXPECT(s.had_trailing_comments() == t.had_comment);
1386 if (t.field.empty())
1388 BEAST_EXPECTS(s.legacy() == t.expect, s.legacy());
1393 BEAST_EXPECTS(
set(field, t.field.data(), s), t.line);
1394 BEAST_EXPECTS(field == t.expect, t.line);
1400 s.append(
"online_delete = 3000");
1402 BEAST_EXPECT(
set(od,
"online_delete", s));
1403 BEAST_EXPECTS(od == 3000, *(s.get<
std::string>(
"online_delete")));
1408 s.append(
"online_delete = 2000 #my comment on this");
1410 BEAST_EXPECT(
set(od,
"online_delete", s));
1411 BEAST_EXPECTS(od == 2000, *(s.get<
std::string>(
"online_delete")));
1418 using namespace std::string_literals;
1419 Section s{
"MySection"};
1420 s.append(
"a_string = mystring");
1421 s.append(
"positive_int = 2");
1422 s.append(
"negative_int = -3");
1423 s.append(
"bool_ish = 1");
1426 auto val_1 =
"value 1"s;
1427 BEAST_EXPECT(
set(val_1,
"a_string", s));
1428 BEAST_EXPECT(val_1 ==
"mystring");
1430 auto val_2 =
"value 2"s;
1431 BEAST_EXPECT(!
set(val_2,
"not_a_key", s));
1432 BEAST_EXPECT(val_2 ==
"value 2");
1433 BEAST_EXPECT(!
set(val_2,
"default"s,
"not_a_key", s));
1434 BEAST_EXPECT(val_2 ==
"default");
1436 auto val_3 = get<std::string>(s,
"a_string");
1437 BEAST_EXPECT(val_3 ==
"mystring");
1438 auto val_4 = get<std::string>(s,
"not_a_key");
1439 BEAST_EXPECT(val_4 ==
"");
1440 auto val_5 = get<std::string>(s,
"not_a_key",
"default");
1441 BEAST_EXPECT(val_5 ==
"default");
1443 auto val_6 =
"value 6"s;
1445 BEAST_EXPECT(val_6 ==
"mystring");
1447 auto val_7 =
"value 7"s;
1449 BEAST_EXPECT(val_7 ==
"value 7");
1454 BEAST_EXPECT(
set(val_1,
"positive_int", s));
1455 BEAST_EXPECT(val_1 == 2);
1458 BEAST_EXPECT(
set(val_2,
"negative_int", s));
1459 BEAST_EXPECT(val_2 == -3);
1462 BEAST_EXPECT(!
set(val_3,
"a_string", s));
1463 BEAST_EXPECT(val_3 == 3);
1465 auto val_4 = get<int>(s,
"positive_int");
1466 BEAST_EXPECT(val_4 == 2);
1467 auto val_5 = get<int>(s,
"not_a_key");
1468 BEAST_EXPECT(val_5 == 0);
1469 auto val_6 = get<int>(s,
"not_a_key", 5);
1470 BEAST_EXPECT(val_6 == 5);
1471 auto val_7 = get<int>(s,
"a_string", 6);
1472 BEAST_EXPECT(val_7 == 6);
1476 BEAST_EXPECT(val_8 == 2);
1480 BEAST_EXPECT(val_9 == 9);
1484 BEAST_EXPECT(val_10 == 10);
1489 s.get<
int>(
"a_string");
1492 catch (boost::bad_lexical_cast&)
1499 bool flag_1 =
false;
1501 BEAST_EXPECT(flag_1 ==
true);
1503 bool flag_2 =
false;
1505 BEAST_EXPECT(flag_2 ==
false);
1522 {
"seconds", 1, 15 * 60,
false},
1523 {
"minutes", 60, 14,
false},
1524 {
"minutes", 60, 15,
true},
1525 {
"hours", 3600, 10,
true},
1526 {
"days", 86400, 10,
true},
1527 {
"weeks", 604800, 2,
true},
1528 {
"months", 2592000, 1,
false},
1529 {
"years", 31536000, 1,
false}};
1532 for (
auto& [unit, sec, val, shouldPass] : units)
1536[amendment_majority_time]
1543 c.loadFromString(toLoad);
1546 c.AMENDMENT_MAJORITY_TIME.count() == val * sec);
1570 c.loadFromString(
"[overlay]\nmax_unknown_time=" + value);
1571 return c.MAX_UNKNOWN_TIME;
1580 BEAST_EXPECT(!testUnknown(
"none"));
1581 BEAST_EXPECT(!testUnknown(
"0.5"));
1582 BEAST_EXPECT(!testUnknown(
"180 seconds"));
1583 BEAST_EXPECT(!testUnknown(
"9 minutes"));
1586 BEAST_EXPECT(!testUnknown(
"299"));
1595 BEAST_EXPECT(!testUnknown(
"1801"));
1615 BEAST_EXPECT(!testDiverged(
"none"));
1616 BEAST_EXPECT(!testDiverged(
"0.5"));
1617 BEAST_EXPECT(!testDiverged(
"180 seconds"));
1618 BEAST_EXPECT(!testDiverged(
"9 minutes"));
1621 BEAST_EXPECT(!testDiverged(
"0"));
1622 BEAST_EXPECT(!testDiverged(
"59"));
1631 BEAST_EXPECT(!testDiverged(
"901"));
1656BEAST_DEFINE_TESTSUITE(Config, core,
xrpl);
RAII temporary directory.
std::string path() const
Get the native path for the temporary directory.
std::string file(std::string const &name) const
Get the native path for the a file.
log_os< char > log
Logging output stream.
void pass()
Record a successful test condition.
testcase_t testcase
Memberspace for declaring test cases.
bool unexcept(F &&f, String const &reason)
void fail(String const &reason, char const *file, int line)
Record a failure.
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
Section & section(std::string const &name)
Returns the section with the given name.
void testSetup(bool explicitPath)
void run() override
Runs the suite.
void testValidatorsFile()
boost::filesystem::path path
static char const *const configLegacyName
std::optional< std::size_t > VALIDATOR_LIST_THRESHOLD
static char const *const configFileName
std::chrono::seconds MAX_DIVERGED_TIME
std::vector< std::string > IPS
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
std::uint32_t LEDGER_HISTORY
std::vector< std::string > IPS_FIXED
static char const *const databaseDirName
std::vector< std::string > const & values() const
Returns all the values in the section.
std::vector< std::string > const & lines() const
Returns all the lines in the section.
bool expectException(Functor f, std::string const &message="")
Create a directory and remove it when it's done.
beast::unit_test::suite & test_
path const & subdir() const
auto rmDir(path const &toRm)
boost::filesystem::path path
Write a xrpld config file and remove when done.
Config const & config() const
std::string configFile() const
bool configFileExists() const
FileCfgGuard(beast::unit_test::suite &test, path subDir, path const &dbPath, path const &configFile, path const &validatorsFile, bool useCounter=true, std::string confContents="")
bool dataDirExists() const
Write a file in a directory and remove when done.
path const & file() const
Write a validators.txt file and remove when done.
std::string validatorsFile() const
bool validatorsFileExists() const
ValidatorsTxtGuard(beast::unit_test::suite &test, path subDir, path const &validatorsFileName, bool useCounter=true)
field_t< CharT, Traits, Allocator > field(std::basic_string< CharT, Traits, Allocator > const &text, int width=8, int pad=0, bool right=false)
std::string valFileContents()
std::string configContents(std::string const &dbPath, std::string const &validatorsFile)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void parse_Port(ParsedPort &port, Section const §ion, std::ostream &log)
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
static std::string const & systemName()
bool get_if_exists(Section const §ion, std::string const &name, T &v)
static std::optional< Seed > validationSeed(Json::Value const ¶ms)
T regex_replace(T... args)
std::vector< boost::asio::ip::network_v4 > admin_nets_v4
std::vector< boost::asio::ip::network_v6 > admin_nets_v6