Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the Beta RPC API (v2) for all unit tests: #4573

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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