Skip to content

Commit

Permalink
Fix BucketList test for versions < p22
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Aug 13, 2024
1 parent 05d6144 commit 5cace22
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/bucket/test/BucketListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ basicBucketListTest()
{
VirtualClock clock;
Config const& cfg = getTestConfig();
try
{
for_versions_with_differing_bucket_logic(cfg, [&](Config const& cfg) {

auto test = [&](Config const& cfg) {
try
{
Application::pointer app = createTestApplication(clock, cfg);
BucketListT bl;
CLOG_DEBUG(Bucket, "Adding batches to bucket list");
Expand Down Expand Up @@ -180,13 +181,22 @@ basicBucketListTest()
CHECK(snapSz <= BucketListT::levelHalf(j) * 100);
}
}
});
}
catch (std::future_error& e)
{
CLOG_DEBUG(Bucket, "Test caught std::future_error {}: {}",
e.code().value(), e.what());
REQUIRE(false);
}
};

if constexpr (std::is_same_v<BucketListT, LiveBucketList>)
{
for_versions_with_differing_bucket_logic(cfg, test);
}
catch (std::future_error& e)
else
{
CLOG_DEBUG(Bucket, "Test caught std::future_error {}: {}",
e.code().value(), e.what());
REQUIRE(false);
for_versions_from(22, cfg, test);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,13 @@ for_versions_from(std::vector<uint32> const& versions, Application& app,
for_versions_from(versions.back() + 1, app, f);
}

void
for_versions_from(uint32 from, Config const& cfg,
std::function<void(Config const&)> const& f)
{
for_versions(from, Config::CURRENT_LEDGER_PROTOCOL_VERSION, cfg, f);
}

void
for_all_versions(Application& app, std::function<void(void)> const& f)
{
Expand Down
3 changes: 3 additions & 0 deletions src/test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ void for_versions_from(uint32 from, Application& app,
void for_versions_from(std::vector<uint32> const& versions, Application& app,
std::function<void(void)> const& f);

void for_versions_from(uint32 from, Config const& cfg,
std::function<void(Config const&)> const& f);

void for_all_versions(Application& app, std::function<void(void)> const& f);

void for_all_versions(Config const& cfg,
Expand Down

0 comments on commit 5cace22

Please sign in to comment.