fix: check for valid ammID field in amm_info RPC (#5188)

This commit is contained in:
Olek
2024-11-18 13:58:25 -05:00
committed by GitHub
parent 838978b869
commit 0ec17b6026
2 changed files with 21 additions and 0 deletions

View File

@@ -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 void
run() override run() override
{ {
@@ -323,6 +341,7 @@ public:
testSimpleRpc(); testSimpleRpc();
testVoteAndBid(); testVoteAndBid();
testFreeze(); testFreeze();
testInvalidAmmField();
} }
}; };

View File

@@ -132,6 +132,8 @@ doAMMInfo(RPC::JsonContext& context)
if (!sle) if (!sle)
return Unexpected(rpcACT_MALFORMED); return Unexpected(rpcACT_MALFORMED);
ammID = sle->getFieldH256(sfAMMID); ammID = sle->getFieldH256(sfAMMID);
if (ammID->isZero())
return Unexpected(rpcACT_NOT_FOUND);
} }
if (params.isMember(jss::account)) if (params.isMember(jss::account))