mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-27 15:15:52 +00:00
@@ -99,7 +99,10 @@ FeatureHandler::process(FeatureHandler::Input input, Context const& ctx) const
|
||||
);
|
||||
|
||||
return Output{
|
||||
.features = std::move(features), .ledgerHash = ripple::strHex(lgrInfo.hash), .ledgerIndex = lgrInfo.seq
|
||||
.features = std::move(features),
|
||||
.ledgerHash = ripple::strHex(lgrInfo.hash),
|
||||
.ledgerIndex = lgrInfo.seq,
|
||||
.inlineResult = input.feature.has_value()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -124,14 +127,20 @@ tag_invoke(boost::json::value_from_tag, boost::json::value& jv, FeatureHandler::
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
if (output.inlineResult) {
|
||||
jv = value_from(output.features);
|
||||
} else {
|
||||
jv = {
|
||||
{JS(features), value_from(output.features)},
|
||||
{JS(ledger_hash), output.ledgerHash},
|
||||
{JS(ledger_index), output.ledgerIndex},
|
||||
{JS(validated), output.validated},
|
||||
};
|
||||
}
|
||||
|
||||
auto& obj = jv.as_object();
|
||||
obj[JS(ledger_hash)] = output.ledgerHash;
|
||||
obj[JS(ledger_index)] = output.ledgerIndex;
|
||||
obj[JS(validated)] = output.validated;
|
||||
}
|
||||
|
||||
void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, FeatureHandler::Output::Feature const& feature)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,9 @@ public:
|
||||
std::string ledgerHash;
|
||||
uint32_t ledgerIndex{};
|
||||
|
||||
// when set to true, output will be inlined in `result` instead of wrapping as `features` inside of `result`.
|
||||
bool inlineResult = false;
|
||||
|
||||
// validated should be sent via framework
|
||||
bool validated = true;
|
||||
};
|
||||
|
||||
@@ -257,13 +257,11 @@ TEST_F(RPCFeatureHandlerTest, SuccessPathViaNameWithSingleSupportedAndEnabledRes
|
||||
|
||||
auto const expectedOutput = fmt::format(
|
||||
R"({{
|
||||
"features": {{
|
||||
"2E2FB9CF8A44EB80F4694D38AADAE9B8B7ADAFD2F092E10068E61C98C4F092B0":
|
||||
{{
|
||||
"name": "fixUniversalNumber",
|
||||
"enabled": true,
|
||||
"supported": true
|
||||
}}
|
||||
}},
|
||||
"ledger_hash": "{}",
|
||||
"ledger_index": {},
|
||||
@@ -311,13 +309,11 @@ TEST_F(RPCFeatureHandlerTest, SuccessPathViaHashWithSingleResult)
|
||||
|
||||
auto const expectedOutput = fmt::format(
|
||||
R"({{
|
||||
"features": {{
|
||||
"2E2FB9CF8A44EB80F4694D38AADAE9B8B7ADAFD2F092E10068E61C98C4F092B0":
|
||||
{{
|
||||
"name": "fixUniversalNumber",
|
||||
"enabled": true,
|
||||
"supported": true
|
||||
}}
|
||||
}},
|
||||
"ledger_hash": "{}",
|
||||
"ledger_index": {},
|
||||
|
||||
Reference in New Issue
Block a user