mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-02 16:26:37 +00:00
Fix duplicate and incorrect fields in server_definitions (#753)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -267,32 +267,6 @@ private:
|
||||
ret[jss::FIELDS][i++] = a;
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value a = Json::arrayValue;
|
||||
a[0U] = "hash";
|
||||
Json::Value v = Json::objectValue;
|
||||
v[jss::nth] = 257;
|
||||
v[jss::isVLEncoded] = false;
|
||||
v[jss::isSerialized] = false;
|
||||
v[jss::isSigningField] = false;
|
||||
v[jss::type] = "Hash256";
|
||||
a[1U] = v;
|
||||
ret[jss::FIELDS][i++] = a;
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value a = Json::arrayValue;
|
||||
a[0U] = "index";
|
||||
Json::Value v = Json::objectValue;
|
||||
v[jss::nth] = 258;
|
||||
v[jss::isVLEncoded] = false;
|
||||
v[jss::isSerialized] = false;
|
||||
v[jss::isSigningField] = false;
|
||||
v[jss::type] = "Hash256";
|
||||
a[1U] = v;
|
||||
ret[jss::FIELDS][i++] = a;
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value a = Json::arrayValue;
|
||||
a[0U] = "taker_gets_funded";
|
||||
@@ -326,22 +300,23 @@ private:
|
||||
|
||||
Json::Value innerObj = Json::objectValue;
|
||||
|
||||
uint32_t fc = code & 0xFFU;
|
||||
uint32_t tc = code >> 16U;
|
||||
uint32_t type = f->fieldType;
|
||||
|
||||
innerObj[jss::nth] = fc;
|
||||
innerObj[jss::nth] = f->fieldValue;
|
||||
|
||||
innerObj[jss::isVLEncoded] =
|
||||
(tc == 7U /* Blob */ || tc == 8U /* AccountID */ ||
|
||||
tc == 19U /* Vector256 */);
|
||||
(type == 7U /* Blob */ || type == 8U /* AccountID */ ||
|
||||
type == 19U /* Vector256 */);
|
||||
|
||||
innerObj[jss::isSerialized] =
|
||||
(tc <
|
||||
10000); /* TRANSACTION, LEDGER_ENTRY, VALIDATION, METADATA */
|
||||
(type < 10000 && f->fieldName != "hash" &&
|
||||
f->fieldName !=
|
||||
"index"); /* hash, index, TRANSACTION, LEDGER_ENTRY,
|
||||
VALIDATION, METADATA */
|
||||
|
||||
innerObj[jss::isSigningField] = f->shouldInclude(false);
|
||||
|
||||
innerObj[jss::type] = type_map[tc];
|
||||
innerObj[jss::type] = type_map[type];
|
||||
|
||||
Json::Value innerArray = Json::arrayValue;
|
||||
innerArray[0U] = f->fieldName;
|
||||
|
||||
Reference in New Issue
Block a user