From dcbc4577c21a83d4192607f7577e52850ac2c021 Mon Sep 17 00:00:00 2001 From: cyan317 <120398799+cindyyan317@users.noreply.github.com> Date: Wed, 5 Jul 2023 17:25:17 +0100 Subject: [PATCH] Use "invalidParam" when "book_offers" taker format is wrong (#734) Fix #735 --- src/rpc/handlers/BookOffers.h | 5 ++++- unittests/rpc/handlers/BookOffersTest.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rpc/handlers/BookOffers.h b/src/rpc/handlers/BookOffers.h index fa881e42..97366d1d 100644 --- a/src/rpc/handlers/BookOffers.h +++ b/src/rpc/handlers/BookOffers.h @@ -90,7 +90,10 @@ public: {JS(issuer), validation::WithCustomError{ validation::IssuerValidator, Status(RippledError::rpcSRC_ISR_MALFORMED)}}}}, - {JS(taker), validation::AccountValidator}, + // return INVALID_PARAMS if account format is wrong for "taker" + {JS(taker), + validation::WithCustomError{ + validation::AccountValidator, Status(RippledError::rpcINVALID_PARAMS, "Invalid field 'taker'")}}, {JS(limit), validation::Type{}, validation::Between{1, 100}}, {JS(ledger_hash), validation::Uint256HexStringValidator}, {JS(ledger_index), validation::LedgerIndexValidator}, diff --git a/unittests/rpc/handlers/BookOffersTest.cpp b/unittests/rpc/handlers/BookOffersTest.cpp index 8d2d0a63..95ea061c 100644 --- a/unittests/rpc/handlers/BookOffersTest.cpp +++ b/unittests/rpc/handlers/BookOffersTest.cpp @@ -255,8 +255,8 @@ generateParameterBookOffersTestBundles() }, "taker": "123" })", - "actMalformed", - "takerMalformed"}, + "invalidParams", + "Invalid field 'taker'"}, ParameterTestBundle{ "TakerNotString", R"({ @@ -272,7 +272,7 @@ generateParameterBookOffersTestBundles() "taker": 123 })", "invalidParams", - "takerNotString"}, + "Invalid field 'taker'"}, ParameterTestBundle{ "LimitNotInt", R"({