Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking ammID field of account #5188

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/test/rpc/AMMInfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,32 @@ class AMMInfo_test : public jtx::AMMTestBase
});
}

void
testInvalidAmmField()
{
using namespace jtx;
testcase("Invalid amm field");

gregtatcam marked this conversation as resolved.
Show resolved Hide resolved
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");
});
Comment on lines +322 to +334
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the test could be moved into testErrors() IMO

}

void
run() override
{
testErrors();
testSimpleRpc();
testVoteAndBid();
testFreeze();
testInvalidAmmField();
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/xrpld/rpc/handlers/AMMInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading