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 1 commit
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
32 changes: 32 additions & 0 deletions src/test/rpc/AMMInfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,45 @@ 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
Env env{*this};

Account const gw("gw");
env.fund(XRP(10000), gw);

Json::Value jv;
jv[jss::TransactionType] = jss::AMMCreate;
jv[jss::Account] = gw.human();
jv[jss::TradingFee] = "0";
jv[jss::Amount] = "10000000";
jv[jss::Amount2] =
AnyAmount(gw["USD"](10)).value.getJson(JsonOptions::none);

env(jv, fee(drops(env.current()->fees().increment)));
env.close();

Json::Value jvParams;
jvParams[jss::ledger_index] = jss::validated;
jvParams[jss::amm_account] = gw.human();
auto const resp = env.rpc("json", "amm_info", to_string(jvParams));
BEAST_EXPECT(
resp.isMember("result") && resp["result"].isMember("error") &&
resp["result"]["error"] == "actNotFound");
}

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