Skip to content

Commit

Permalink
Enable the Beta RPC API (v2) for all unit tests: (XRPLF#4573)
Browse files Browse the repository at this point in the history
* Enable api_version 2, which is currently in beta. It is expected to be
  marked stable by the next stable release.
* This does not change any defaults.
* The only existing tests changed were one that set the same flag, which
  was now redundant, and a couple that tested versioning explicitly.
  • Loading branch information
ximinez authored and ckeshava committed Jul 10, 2023
1 parent eaf58f2 commit bd85cfa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/test/jtx/impl/envconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ setupConfigForUnitTests(Config& cfg)
cfg.FEES.account_reserve = XRP(200).value().xrp().drops();
cfg.FEES.owner_reserve = XRP(50).value().xrp().drops();

// The Beta API (currently v2) is always available to tests
cfg.BETA_RPC_API = true;

cfg.overwrite(ConfigSection::nodeDatabase(), "type", "memory");
cfg.overwrite(ConfigSection::nodeDatabase(), "path", "main");
cfg.deprecatedClearSection(ConfigSection::importNodeDatabase());
Expand Down
5 changes: 1 addition & 4 deletions src/test/rpc/AccountInfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ class AccountInfo_test : public beast::unit_test::suite
testSignerListsApiVersion2()
{
using namespace jtx;
Env env{*this, envconfig([](std::unique_ptr<Config> c) {
c->loadFromString("\n[beta_rpc_api]\n1\n");
return c;
})};
Env env{*this};
Account const alice{"alice"};
env.fund(XRP(1000), alice);

Expand Down
16 changes: 13 additions & 3 deletions src/test/rpc/Version_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@ class Version_test : public beast::unit_test::suite
std::to_string(RPC::apiMinimumSupportedVersion - 1) + "}");
BEAST_EXPECT(badVersion(re));

BEAST_EXPECT(env.app().config().BETA_RPC_API);
re = env.rpc(
"json",
"version",
"{\"api_version\": " +
std::to_string(RPC::apiMaximumSupportedVersion + 1) + "}");
std::to_string(
std::max(
RPC::apiMaximumSupportedVersion, RPC::apiBetaVersion) +
1) +
"}");
BEAST_EXPECT(badVersion(re));

re = env.rpc("json", "version", "{\"api_version\": \"a\"}");
Expand Down Expand Up @@ -190,20 +195,25 @@ class Version_test : public beast::unit_test::suite
using namespace test::jtx;
Env env{*this};

BEAST_EXPECT(env.app().config().BETA_RPC_API);
auto const without_api_verion = std::string("{ ") +
"\"jsonrpc\": \"2.0\", "
"\"ripplerpc\": \"2.0\", "
"\"id\": 5, "
"\"method\": \"version\", "
"\"params\": {}}";
auto const with_wrong_api_verion = std::string("{ ") +
auto const with_wrong_api_verion =
std::string("{ ") +
"\"jsonrpc\": \"2.0\", "
"\"ripplerpc\": \"2.0\", "
"\"id\": 6, "
"\"method\": \"version\", "
"\"params\": { "
"\"api_version\": " +
std::to_string(RPC::apiMaximumSupportedVersion + 1) + "}}";
std::to_string(
std::max(RPC::apiMaximumSupportedVersion, RPC::apiBetaVersion) +
1) +
"}}";
auto re = env.rpc(
"json2",
'[' + without_api_verion + ", " + with_wrong_api_verion + ']');
Expand Down

0 comments on commit bd85cfa

Please sign in to comment.