mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Write improved forAllApiVersions used in NetworkOPs (#4833)
This commit is contained in:
@@ -758,40 +758,6 @@ Env::rpc(std::string const& cmd, Args&&... args)
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* The SingleVersionedTestCallable concept checks for a callable that takes
|
||||
* an unsigned integer as its argument and returns void.
|
||||
*/
|
||||
template <class T>
|
||||
concept SingleVersionedTestCallable = requires(T callable, unsigned int version)
|
||||
{
|
||||
{
|
||||
callable(version)
|
||||
}
|
||||
->std::same_as<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* The VersionedTestCallable concept checks if a set of callables all satisfy
|
||||
* the SingleVersionedTestCallable concept. This allows forAllApiVersions to
|
||||
* accept any number of functions. It executes a set of provided functions over
|
||||
* a range of versions from RPC::apiMinimumSupportedVersion to
|
||||
* RPC::apiBetaVersion. This is useful for running a series of tests or
|
||||
* operations that need to be performed on multiple versions of an API.
|
||||
*/
|
||||
template <class... T>
|
||||
concept VersionedTestCallable = (... && SingleVersionedTestCallable<T>);
|
||||
void
|
||||
forAllApiVersions(VersionedTestCallable auto... testCallable)
|
||||
{
|
||||
for (auto testVersion = RPC::apiMinimumSupportedVersion;
|
||||
testVersion <= RPC::apiMaximumValidVersion;
|
||||
++testVersion)
|
||||
{
|
||||
(..., testCallable(testVersion));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace jtx
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user