From c634f0f0baef5cc9c5d3c1b14bad3095da9b4c8f Mon Sep 17 00:00:00 2001 From: cyan317 <120398799+cindyyan317@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:11:42 +0100 Subject: [PATCH] Fix ledger_entry error code (#891) Fix #896 --- src/rpc/handlers/LedgerEntry.cpp | 4 ++-- unittests/rpc/handlers/LedgerEntryTests.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rpc/handlers/LedgerEntry.cpp b/src/rpc/handlers/LedgerEntry.cpp index c2c3fd684..d63fe46ec 100644 --- a/src/rpc/handlers/LedgerEntry.cpp +++ b/src/rpc/handlers/LedgerEntry.cpp @@ -83,8 +83,8 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input input, Context const& ctx) { // Must specify 1 of the following fields to indicate what type if (ctx.apiVersion == 1) - return Error{Status{RippledError::rpcINVALID_PARAMS}}; - return Error{Status{ClioError::rpcUNKNOWN_OPTION}}; + return Error{Status{ClioError::rpcUNKNOWN_OPTION}}; + return Error{Status{RippledError::rpcINVALID_PARAMS}}; } // check ledger exists diff --git a/unittests/rpc/handlers/LedgerEntryTests.cpp b/unittests/rpc/handlers/LedgerEntryTests.cpp index 69f64c738..5e71965ef 100644 --- a/unittests/rpc/handlers/LedgerEntryTests.cpp +++ b/unittests/rpc/handlers/LedgerEntryTests.cpp @@ -103,7 +103,7 @@ generateTestValuesForParametersTest() "invalidParams", "ledgerIndexMalformed"}, - ParamTestCaseBundle{"UnknownOption", R"({})", "unknownOption", "Unknown option."}, + ParamTestCaseBundle{"UnknownOption", R"({})", "invalidParams", "Invalid parameters."}, ParamTestCaseBundle{ "InvalidDepositPreauthType", @@ -1094,8 +1094,8 @@ TEST_F(RPCLedgerEntryTest, InvalidEntryTypeVersion2) auto const output = handler.process(req, Context{.yield = yield, .apiVersion = 2}); ASSERT_FALSE(output); auto const err = rpc::makeError(output.error()); - EXPECT_EQ(err.at("error").as_string(), "unknownOption"); - EXPECT_EQ(err.at("error_message").as_string(), "Unknown option."); + EXPECT_EQ(err.at("error").as_string(), "invalidParams"); + EXPECT_EQ(err.at("error_message").as_string(), "Invalid parameters."); }); } @@ -1107,7 +1107,7 @@ TEST_F(RPCLedgerEntryTest, InvalidEntryTypeVersion1) auto const output = handler.process(req, Context{.yield = yield, .apiVersion = 1}); ASSERT_FALSE(output); auto const err = rpc::makeError(output.error()); - EXPECT_EQ(err.at("error").as_string(), "invalidParams"); - EXPECT_EQ(err.at("error_message").as_string(), "Invalid parameters."); + EXPECT_EQ(err.at("error").as_string(), "unknownOption"); + EXPECT_EQ(err.at("error_message").as_string(), "Unknown option."); }); }