Merge branch 'ximinez/lending-refactoring-3' into ximinez/lending-refactoring-4

This commit is contained in:
Ed Hennis
2025-09-03 19:21:00 -04:00
committed by GitHub
2 changed files with 47 additions and 1 deletions

View File

@@ -353,7 +353,9 @@ parseUint32(
else
{
ret = detail::make_stvar<STResult>(
field, beast::lexicalCastThrow<Integer>(value.asString()));
field,
safe_cast<typename STResult::value_type>(
beast::lexicalCastThrow<Integer>(value.asString())));
}
}
if (!ret)

View File

@@ -140,6 +140,30 @@ public:
}
}
{
std::string const goodJson(
R"({"CloseResolution":"19","Method":"250",)"
R"("TransactionResult":"tecFROZEN"})");
std::string const expectedJson(
R"({"CloseResolution":19,"Method":250,)"
R"("TransactionResult":"tecFROZEN"})");
Json::Value jv;
if (BEAST_EXPECT(parseJSONString(goodJson, jv)))
{
// Integer values are always parsed as int,
// unless they're too big. We want a small uint.
jv["CloseResolution"] = Json::UInt(19);
STParsedJSONObject parsed("test", jv);
if (BEAST_EXPECT(parsed.object))
{
std::string const& serialized(
to_string(parsed.object->getJson(JsonOptions::none)));
BEAST_EXPECT(serialized == expectedJson);
}
}
}
{
std::string const json(R"({"CloseResolution":19,"Method":250,)"
R"("TransactionResult":"terQUEUED"})");
@@ -227,6 +251,26 @@ public:
}
}
{
std::string const goodJson(R"({"CloseResolution":19,"Method":250,)"
R"("TransferFee":"65535"})");
std::string const expectedJson(
R"({"CloseResolution":19,"Method":250,)"
R"("TransferFee":65535})");
Json::Value jv;
if (BEAST_EXPECT(parseJSONString(goodJson, jv)))
{
STParsedJSONObject parsed("test", jv);
if (BEAST_EXPECT(parsed.object))
{
std::string const& serialized(
to_string(parsed.object->getJson(JsonOptions::none)));
BEAST_EXPECT(serialized == expectedJson);
}
}
}
{
std::string const json(R"({"CloseResolution":19,"Method":250,)"
R"("TransferFee":"65536"})");