From 5cace22fc711a2630c860fc05d9152648519d993 Mon Sep 17 00:00:00 2001 From: Garand Tyson Date: Tue, 13 Aug 2024 11:27:17 -0700 Subject: [PATCH] Fix BucketList test for versions < p22 --- src/bucket/test/BucketListTests.cpp | 26 ++++++++++++++++++-------- src/test/test.cpp | 7 +++++++ src/test/test.h | 3 +++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/bucket/test/BucketListTests.cpp b/src/bucket/test/BucketListTests.cpp index bb5505b009..cec79e288a 100644 --- a/src/bucket/test/BucketListTests.cpp +++ b/src/bucket/test/BucketListTests.cpp @@ -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"); @@ -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) + { + 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); } } diff --git a/src/test/test.cpp b/src/test/test.cpp index c99192aa9b..61d4ccf20d 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -489,6 +489,13 @@ for_versions_from(std::vector const& versions, Application& app, for_versions_from(versions.back() + 1, app, f); } +void +for_versions_from(uint32 from, Config const& cfg, + std::function const& f) +{ + for_versions(from, Config::CURRENT_LEDGER_PROTOCOL_VERSION, cfg, f); +} + void for_all_versions(Application& app, std::function const& f) { diff --git a/src/test/test.h b/src/test/test.h index ad41a1f5f1..75a98adbaa 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -55,6 +55,9 @@ void for_versions_from(uint32 from, Application& app, void for_versions_from(std::vector const& versions, Application& app, std::function const& f); +void for_versions_from(uint32 from, Config const& cfg, + std::function const& f); + void for_all_versions(Application& app, std::function const& f); void for_all_versions(Config const& cfg,