Fix duplicate and incorrect fields in server_definitions (#753)

This commit is contained in:
tequ
2026-05-27 06:58:13 +09:00
committed by GitHub
parent cb91b4e88e
commit c55420bcd8
2 changed files with 43 additions and 36 deletions

View File

@@ -55,9 +55,9 @@ public:
using namespace test::jtx;
Env env(*this);
auto const result = env.rpc("server_definitions");
{
Env env(*this);
auto const result = env.rpc("server_definitions");
BEAST_EXPECT(!result[jss::result].isMember(jss::error));
BEAST_EXPECT(result[jss::result].isMember(jss::FIELDS));
BEAST_EXPECT(result[jss::result].isMember(jss::LEDGER_ENTRY_TYPES));
@@ -71,6 +71,38 @@ public:
BEAST_EXPECT(result[jss::result].isMember(jss::hash));
BEAST_EXPECT(result[jss::result][jss::status] == "success");
}
// check exception SFields
{
auto const fieldExists = [&](std::string name) {
for (auto& field : result[jss::result][jss::FIELDS])
{
if (field[0u].asString() == name)
{
return true;
}
}
return false;
};
BEAST_EXPECT(fieldExists("Generic"));
BEAST_EXPECT(fieldExists("Invalid"));
BEAST_EXPECT(fieldExists("ObjectEndMarker"));
BEAST_EXPECT(fieldExists("ArrayEndMarker"));
BEAST_EXPECT(fieldExists("taker_gets_funded"));
BEAST_EXPECT(fieldExists("taker_pays_funded"));
BEAST_EXPECT(fieldExists("hash"));
BEAST_EXPECT(fieldExists("index"));
}
// verify no duplicate field names in FIELDS array
{
std::set<std::string> fieldNames;
for (auto const& field : result[jss::result][jss::FIELDS])
{
auto const name = field[0u].asString();
BEAST_EXPECT(fieldNames.insert(name).second);
}
}
}
void