Skip to content
12 changes: 7 additions & 5 deletions src/rpc/handlers/LedgerEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons

if (input.index) {
key = ripple::uint256{std::string_view(*(input.index))};
if (key.isZero())
return Error{Status{RippledError::rpcENTRY_NOT_FOUND}};
} else if (input.accountRoot) {
key = ripple::keylet::account(*util::parseBase58Wrapper<ripple::AccountID>(*(input.accountRoot))).key;
} else if (input.did) {
Expand Down Expand Up @@ -201,7 +203,7 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons
// Must specify 1 of the following fields to indicate what type
if (ctx.apiVersion == 1)
return Error{Status{ClioError::RpcUnknownOption}};
return Error{Status{RippledError::rpcINVALID_PARAMS}};
return Error{Status{RippledError::rpcINVALID_PARAMS, "No ledger_entry params provided."}};
}

// check ledger exists
Expand All @@ -220,20 +222,20 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons

if (!ledgerObject || ledgerObject->empty()) {
if (not input.includeDeleted)
return Error{Status{ClioError::RpcEntryNotFound}};
return Error{Status{RippledError::rpcENTRY_NOT_FOUND}};
auto const deletedSeq = sharedPtrBackend_->fetchLedgerObjectSeq(key, lgrInfo.seq, ctx.yield);
if (!deletedSeq)
return Error{Status{ClioError::RpcEntryNotFound}};
return Error{Status{RippledError::rpcENTRY_NOT_FOUND}};
ledgerObject = sharedPtrBackend_->fetchLedgerObject(key, deletedSeq.value() - 1, ctx.yield);
if (!ledgerObject || ledgerObject->empty())
return Error{Status{ClioError::RpcEntryNotFound}};
return Error{Status{RippledError::rpcENTRY_NOT_FOUND}};
output.deletedLedgerIndex = deletedSeq;
}

ripple::STLedgerEntry const sle{ripple::SerialIter{ledgerObject->data(), ledgerObject->size()}, key};

if (input.expectedType != ripple::ltANY && sle.getType() != input.expectedType)
return Error{Status{"unexpectedLedgerType"}};
return Error{Status{RippledError::rpcUNEXPECTED_LEDGER_TYPE}};

output.index = ripple::strHex(key);
output.ledgerIndex = lgrInfo.seq;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/rpc/handlers/LedgerEntryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ generateTestValuesForParametersTest()
.testName = "UnknownOption",
.testJson = R"JSON({})JSON",
.expectedError = "invalidParams",
.expectedErrorMessage = "Invalid parameters."
.expectedErrorMessage = "No ledger_entry params provided."
},

ParamTestCaseBundle{
Expand Down Expand Up @@ -3386,7 +3386,7 @@ TEST_F(RPCLedgerEntryTest, InvalidEntryTypeVersion2)
ASSERT_FALSE(output);
auto const err = rpc::makeError(output.result.error());
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
EXPECT_EQ(err.at("error_message").as_string(), "Invalid parameters.");
EXPECT_EQ(err.at("error_message").as_string(), "No ledger_entry params provided.");
});
}

Expand Down
Loading