From fb50a0c90dd01c33bb276af33ab6e2ab2cd5a969 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 20 Feb 2026 02:22:36 +0900 Subject: [PATCH] fix: include `index` in `server_definitions` RPC (#5190) --- src/libxrpl/protocol/SField.cpp | 7 +++++-- src/test/rpc/ServerInfo_test.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libxrpl/protocol/SField.cpp b/src/libxrpl/protocol/SField.cpp index 2ce40ea4b..537fa557f 100644 --- a/src/libxrpl/protocol/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -70,9 +70,12 @@ TypedField::TypedField(private_access_tag_t pat, Args&&... args) ##__VA_ARGS__); // SFields which, for historical reasons, do not follow naming conventions. -SField const sfInvalid{access, -1}; -SField const sfGeneric{access, 0}; +SField const sfInvalid(access, -1); +SField const sfGeneric(access, 0); +// The following two fields aren't used anywhere, but they break tests/have +// downstream effects. SField const sfHash(access, STI_UINT256, 257, "hash"); +SField const sfIndex(access, STI_UINT256, 258, "index"); #include diff --git a/src/test/rpc/ServerInfo_test.cpp b/src/test/rpc/ServerInfo_test.cpp index fbeb4220d..e6f889c5b 100644 --- a/src/test/rpc/ServerInfo_test.cpp +++ b/src/test/rpc/ServerInfo_test.cpp @@ -198,6 +198,28 @@ admin = 127.0.0.1 BEAST_EXPECT( result[jss::result][jss::TYPES]["AccountID"].asUInt() == 8); + // 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")); + } + // test that base_uint types are replaced with "Hash" prefix { auto const types = result[jss::result][jss::TYPES];