1#include <test/jtx/TestSuite.h>
3#include <xrpl/basics/contract.h>
4#include <xrpl/beast/unit_test/suite.h>
5#include <xrpl/config/BasicConfig.h>
6#include <xrpl/config/Constants.h>
7#include <xrpl/rdb/SociDB.h>
9#include <boost/optional/optional.hpp>
11#include <soci/boost-optional.h>
13#include <soci/session.h>
36 auto value = dbPath.
string();
101 {{
"peerfinder",
".sqlite"},
104 {
"validators",
".sqlite"}});
106 for (
auto const& i : d)
121 auto checkValues = [
this, &stringData, &intData](soci::session& s) {
125 s <<
"SELECT StringData, IntData FROM SociTestTable;", soci::into(stringResult),
126 soci::into(intResult);
128 stringResult.
size() == stringData.size() && intResult.
size() == intData.size());
129 for (
int i = 0; i < stringResult.
size(); ++i)
134 BEAST_EXPECT(si == ii && si < stringResult.
size());
141 s <<
"CREATE TABLE IF NOT EXISTS SociTestTable ("
142 " Key INTEGER PRIMARY KEY,"
147 s <<
"INSERT INTO SociTestTable (StringData, IntData) VALUES "
148 "(:stringData, :intData);",
149 soci::use(stringData), soci::use(intData);
162 if (bfs::is_regular_file(dbPath))
184 s <<
"DROP TABLE IF EXISTS STT;";
186 s <<
"CREATE TABLE STT ("
188 " UI INTEGER UNSIGNED,"
190 " UBI BIGINT UNSIGNED"
193 s <<
"INSERT INTO STT (I, UI, BI, UBI) VALUES "
194 "(:id, :idu, :bid, :bidu);",
195 soci::use(
id), soci::use(uid), soci::use(bid), soci::use(ubid);
203 s <<
"SELECT I, UI, BI, UBI from STT;", soci::into(ig), soci::into(uig),
204 soci::into(big), soci::into(ubig);
205 BEAST_EXPECT(ig ==
id[0] && uig == uid[0] && big == bid[0] && ubig == ubid[0]);
215 boost::optional<std::int32_t> ig;
219 boost::optional<std::int64_t> big;
220 boost::optional<std::uint64_t> ubig;
221 s <<
"SELECT I, UI, BI, UBI from STT;", soci::into(ig), soci::into(uig),
222 soci::into(big), soci::into(ubig);
223 BEAST_EXPECT(*ig ==
id[0] && uig == uid[0] && *big == bid[0] && *ubig == ubid[0]);
236 if (bfs::is_regular_file(dbPath))
252 "BEGIN TRANSACTION;",
253 "CREATE TABLE Ledgers ( \
254 LedgerHash CHARACTER(64) PRIMARY KEY, \
255 LedgerSeq BIGINT UNSIGNED \
257 "CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);"};
258 for (
auto const c : dbInit)
264 int const numRows = 16;
268 ledgerIndexes.
reserve(numRows);
269 for (
int i = 0; i < numRows; ++i)
272 if (lh[toIncIndex] ==
'z')
277 s <<
"INSERT INTO Ledgers (LedgerHash, LedgerSeq) VALUES "
279 soci::use(ledgerHashes), soci::use(ledgerIndexes);
282 s <<
"SELECT LedgerSeq FROM Ledgers;", soci::into(ledgersLS);
283 BEAST_EXPECT(ledgersLS.
size() == numRows);
288 if (bfs::is_regular_file(dbPath))
void fail(String const &reason, char const *file, int line)
Record a failure.
TestcaseT testcase
Memberspace for declaring test cases.
Holds unparsed configuration information.
void overwrite(std::string const §ion, std::string const &key, std::string const &value)
Overwrite a key/value pair with a command line argument If the section does not exist it is created.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
DBConfig is used when a client wants to delay opening a soci::session after parsing the config parame...
void open(soci::session &s) const
std::string connectionString() const
static void setupDatabaseDir(std::filesystem::path const &dbPath)
static void cleanupDatabaseDir(std::filesystem::path const &dbPath)
void testSQLiteFileNames()
static std::filesystem::path getDatabasePath()
void testSQLiteDeleteWithSubselect()
static void setupSQLiteConfig(BasicConfig &config, std::filesystem::path const &dbPath)
void run() override
Runs the suite.
T create_directory(T... args)
T current_path(T... args)
T emplace_back(T... args)
T is_directory(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, xrpl)
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
static constexpr auto kBackend
static constexpr auto kSqdb
static constexpr auto kDatabasePath