Skip to content

Commit

Permalink
Minor fixes and renamed testing modes
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Sep 13, 2024
1 parent 98d36e8 commit ba1d0d2
Show file tree
Hide file tree
Showing 45 changed files with 135 additions and 126 deletions.
2 changes: 1 addition & 1 deletion src/bucket/test/BucketListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ TEST_CASE("BucketList check bucket sizes", "[bucket][bucketlist][count]")
TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")
{
VirtualClock clock;
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY));
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS));
cfg.USE_CONFIG_FOR_GENESIS = true;

auto app = createTestApplication<BucketTestApplication>(clock, cfg);
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/test/BucketManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ TEST_CASE("bucketmanager do not leak empty-merge futures",
// are thereby not leaking. Disable BucketListDB so that snapshots do not
// hold persist buckets, complicating bucket counting.
VirtualClock clock;
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY));
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS));
cfg.ARTIFICIALLY_PESSIMIZE_MERGES_FOR_TESTING = true;
cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION =
static_cast<uint32_t>(
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/test/BucketTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ TEST_CASE_VERSIONS("merging bucket entries with initentry with shadows",
TEST_CASE_VERSIONS("legacy bucket apply", "[bucket]")
{
VirtualClock clock;
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE));
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS));
for_versions_with_differing_bucket_logic(cfg, [&](Config const& cfg) {
Application::pointer app = createTestApplication(clock, cfg);

Expand Down
4 changes: 2 additions & 2 deletions src/database/test/DatabaseTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ transactionTest(Application::pointer app)

TEST_CASE("database smoketest", "[db]")
{
Config const& cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config const& cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);

VirtualClock clock;
Application::pointer app = createTestApplication(clock, cfg, true, false);
Expand Down Expand Up @@ -349,7 +349,7 @@ TEST_CASE("postgres performance", "[db][pgperf][!hide]")

TEST_CASE("schema test", "[db]")
{
Config const& cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config const& cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);

VirtualClock clock;
Application::pointer app = createTestApplication(clock, cfg);
Expand Down
2 changes: 1 addition & 1 deletion src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ TEST_CASE("surge pricing", "[herder][txset][soroban]")
{
SECTION("max 0 ops per ledger")
{
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY));
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS));
cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE = 0;

VirtualClock clock;
Expand Down
12 changes: 6 additions & 6 deletions src/herder/test/UpgradesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void
testValidateUpgrades(VirtualClock::system_time_point preferredUpgradeDatetime,
bool canBeValid)
{
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION = 10;
cfg.TESTING_UPGRADE_DESIRED_FEE = 100;
cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE = 50;
Expand Down Expand Up @@ -632,7 +632,7 @@ TEST_CASE("Ledger Manager applies upgrades properly", "[upgrades]")
TEST_CASE("config upgrade validation", "[upgrades]")
{
VirtualClock clock;
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
auto app = createTestApplication(clock, cfg);

auto headerTime = VirtualClock::to_time_t(genesis(0, 2));
Expand Down Expand Up @@ -828,7 +828,7 @@ TEST_CASE("config upgrade validation", "[upgrades]")
TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]")
{
VirtualClock clock;
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION =
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1;
cfg.USE_CONFIG_FOR_GENESIS = false;
Expand Down Expand Up @@ -2275,7 +2275,7 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]")
{
VirtualClock clock;

auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
auto app = createTestApplication(clock, cfg);

auto& lm = app->getLedgerManager();
Expand Down Expand Up @@ -2974,7 +2974,7 @@ TEST_CASE("upgrade from cpp14 serialized data", "[upgrades]")

TEST_CASE("upgrades serialization roundtrip", "[upgrades]")
{
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
VirtualClock clock;
auto app = createTestApplication(clock, cfg);

Expand Down Expand Up @@ -3058,7 +3058,7 @@ TEST_CASE("upgrades serialization roundtrip", "[upgrades]")
TEST_CASE_VERSIONS("upgrade flags", "[upgrades][liquiditypool]")
{
VirtualClock clock;
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);

auto app = createTestApplication(clock, cfg);

Expand Down
4 changes: 2 additions & 2 deletions src/history/test/HistoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ dbModeName(Config::TestDbMode mode)
{
switch (mode)
{
case Config::TESTDB_IN_MEMORY_SQLITE:
return "TESTDB_IN_MEMORY_SQLITE";
case Config::TESTDB_IN_MEMORY_OFFERS:
return "TESTDB_IN_MEMORY_OFFERS";
case Config::TESTDB_ON_DISK_SQLITE:
return "TESTDB_ON_DISK_SQLITE";
#ifdef USE_POSTGRES
Expand Down
4 changes: 2 additions & 2 deletions src/invariant/test/AccountSubEntriesCountIsValidTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ deleteRandomSubEntryFromAccount(Application& app, LedgerEntry& le,
TEST_CASE("Create account with no subentries",
"[invariant][accountsubentriescount]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"AccountSubEntriesCountIsValid"};
VirtualClock clock;
Application::pointer app = createTestApplication(clock, cfg);
Expand All @@ -309,7 +309,7 @@ TEST_CASE("Create account then add signers and subentries",
"[invariant][accountsubentriescount]")
{
stellar::uniform_int_distribution<int32_t> changesDist(-1, 2);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"AccountSubEntriesCountIsValid"};

for (uint32_t i = 0; i < 50; ++i)
Expand Down
6 changes: 3 additions & 3 deletions src/invariant/test/ConservationOfLumensTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ TEST_CASE("Fee pool change without inflation",
TEST_CASE("Account balances changed without inflation",
"[invariant][conservationoflumens]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"ConservationOfLumens"};

uint32_t const N = 10;
Expand Down Expand Up @@ -187,7 +187,7 @@ TEST_CASE("Account balances changed without inflation",
TEST_CASE("Account balances unchanged without inflation",
"[invariant][conservationoflumens]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"ConservationOfLumens"};

uint32_t const N = 10;
Expand Down Expand Up @@ -228,7 +228,7 @@ TEST_CASE("Account balances unchanged without inflation",
TEST_CASE("Inflation changes are consistent",
"[invariant][conservationoflumens]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"ConservationOfLumens"};
stellar::uniform_int_distribution<uint32_t> payoutsDist(1, 100);
stellar::uniform_int_distribution<int64_t> amountDist(1, 100000);
Expand Down
4 changes: 2 additions & 2 deletions src/invariant/test/LedgerEntryIsValidTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace stellar::InvariantTestUtils;
TEST_CASE("Trigger validity check for each entry type",
"[invariant][ledgerentryisvalid]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"LedgerEntryIsValid"};

VirtualClock clock;
Expand Down Expand Up @@ -67,7 +67,7 @@ TEST_CASE("Trigger validity check for each entry type",
TEST_CASE("Modify ClaimableBalanceEntry",
"[invariant][ledgerentryisvalid][claimablebalance]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"LedgerEntryIsValid"};

VirtualClock clock;
Expand Down
14 changes: 7 additions & 7 deletions src/invariant/test/LiabilitiesMatchOffersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ updateAccountWithRandomBalance(LedgerEntry le, Application& app,
TEST_CASE("Create account above minimum balance",
"[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

for (uint32_t i = 0; i < 10; ++i)
Expand All @@ -75,7 +75,7 @@ TEST_CASE("Create account above minimum balance",
TEST_CASE("Create account below minimum balance",
"[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

for (uint32_t i = 0; i < 10; ++i)
Expand All @@ -92,7 +92,7 @@ TEST_CASE("Create account below minimum balance",
TEST_CASE("Create account then decrease balance below minimum",
"[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

for (uint32_t i = 0; i < 10; ++i)
Expand All @@ -111,7 +111,7 @@ TEST_CASE("Create account then decrease balance below minimum",
TEST_CASE("Account below minimum balance increases but stays below minimum",
"[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

for (uint32_t i = 0; i < 10; ++i)
Expand All @@ -130,7 +130,7 @@ TEST_CASE("Account below minimum balance increases but stays below minimum",
TEST_CASE("Account below minimum balance decreases",
"[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

for (uint32_t i = 0; i < 10; ++i)
Expand Down Expand Up @@ -250,7 +250,7 @@ generateBuyingLiabilities(Application& app, LedgerEntry offer, bool excess,
TEST_CASE("Create account then increase liabilities without changing balance",
"[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

VirtualClock clock;
Expand Down Expand Up @@ -289,7 +289,7 @@ TEST_CASE("Create account then increase liabilities without changing balance",

TEST_CASE("Invariant for liabilities", "[invariant][liabilitiesmatchoffers]")
{
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
cfg.INVARIANT_CHECKS = {"LiabilitiesMatchOffers"};

VirtualClock clock;
Expand Down
4 changes: 2 additions & 2 deletions src/invariant/test/OrderBookIsNotCrossedTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST_CASE("OrderBookIsNotCrossed in-memory order book is consistent with "
"[invariant][OrderBookIsNotCrossed]")
{
VirtualClock clock;
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
// When testing the order book not crossed invariant, enable it and no other
// invariants (these tests do things which violate other invariants).
cfg.INVARIANT_CHECKS = {};
Expand Down Expand Up @@ -185,7 +185,7 @@ TEST_CASE("OrderBookIsNotCrossed properly throws if order book is crossed",
{

VirtualClock clock;
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE);
auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_OFFERS);
// When testing the order book not crossed invariant, enable it and no other
// invariants (these tests do things which violate other invariants).
cfg.INVARIANT_CHECKS = {};
Expand Down
2 changes: 1 addition & 1 deletion src/invariant/test/SponsorshipCountIsValidTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace stellar::InvariantTestUtils;
TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]")
{
VirtualClock clock;
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY);
Config cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY_NO_OFFERS);
cfg.INVARIANT_CHECKS = {"SponsorshipCountIsValid"};
auto app = createTestApplication(clock, cfg);

Expand Down
5 changes: 2 additions & 3 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,9 +1726,8 @@ LedgerManagerImpl::transferLedgerEntriesToBucketList(
ltx.getAllEntries(initEntries, liveEntries, deadEntries);
if (blEnabled)
{
BucketTestUtils::addBatchAndUpdateSnapshot(
mApp.getBucketManager().getBucketList(), mApp, lh, initEntries,
liveEntries, deadEntries);
mApp.getBucketManager().addBatch(mApp, lh, initEntries, liveEntries,
deadEntries);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/ledger/test/LedgerCloseMetaStreamTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ TEST_CASE("LedgerCloseMetaStream file descriptor - LIVE_NODE",
Config const& cfg3 = getTestConfig(3);
Config cfg4 = getTestConfig(4);
Config cfg5 = getTestConfig(
5, Config::TESTDB_IN_MEMORY); // needed by
// EXPERIMENTAL_PRECAUTION_DELAY_META
5,
Config::
TESTDB_IN_MEMORY_NO_OFFERS); // needed by
// EXPERIMENTAL_PRECAUTION_DELAY_META

// Step 2: open writable files and pass them to configs 4 and 5
// (watchers).
Expand Down
Loading

0 comments on commit ba1d0d2

Please sign in to comment.