test: add forAllApiVersions helper function (#4611)

Introduce a new variadic template helper function, `forAllApiVersions`,
that accepts callables to execute a set of functions over a range of
versions - from RPC::apiMinimumSupportedVersion to RPC::apiBetaVersion.
This avoids the duplication of code.

Context: #4552
This commit is contained in:
Arihant Kothari
2026-02-19 15:51:36 +09:00
committed by tequ
parent d5b6f7ef1a
commit e9ac727cc1
3 changed files with 39 additions and 15 deletions

View File

@@ -24,7 +24,6 @@
#include <ripple/beast/unit_test.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/jss.h>
#include <ripple/rpc/impl/RPCHelpers.h>
#include <test/app/Import_json.h>
#include <test/jtx.h>
@@ -2455,13 +2454,8 @@ public:
testQueue();
testLedgerAccountsOption();
// version specific tests
for (auto testVersion = RPC::apiMinimumSupportedVersion;
testVersion <= RPC::apiBetaVersion;
++testVersion)
{
testLedgerEntryInvalidParams(testVersion);
}
test::jtx::forAllApiVersions(std::bind_front(
&LedgerRPC_test::testLedgerEntryInvalidParams, this));
}
};