mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
fix: check for valid ammID field in amm_info RPC (#5188)
This commit is contained in:
@@ -316,6 +316,24 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
testInvalidAmmField()
|
||||
{
|
||||
using namespace jtx;
|
||||
testcase("Invalid amm field");
|
||||
|
||||
testAMM([&](AMM& amm, Env&) {
|
||||
auto const resp = amm.ammRpcInfo(
|
||||
std::nullopt,
|
||||
jss::validated.c_str(),
|
||||
std::nullopt,
|
||||
std::nullopt,
|
||||
gw);
|
||||
BEAST_EXPECT(
|
||||
resp.isMember("error") && resp["error"] == "actNotFound");
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -323,6 +341,7 @@ public:
|
||||
testSimpleRpc();
|
||||
testVoteAndBid();
|
||||
testFreeze();
|
||||
testInvalidAmmField();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -132,6 +132,8 @@ doAMMInfo(RPC::JsonContext& context)
|
||||
if (!sle)
|
||||
return Unexpected(rpcACT_MALFORMED);
|
||||
ammID = sle->getFieldH256(sfAMMID);
|
||||
if (ammID->isZero())
|
||||
return Unexpected(rpcACT_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (params.isMember(jss::account))
|
||||
|
||||
Reference in New Issue
Block a user