mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-19 11:15:50 +00:00
fix: LedgerEntryNotExist unittest failure (#1564)
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
#include "util/NameGenerator.hpp"
|
||||
#include "util/TestObject.hpp"
|
||||
|
||||
#include <boost/asio/executor_work_guard.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <boost/json/parse.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
@@ -2726,6 +2729,7 @@ TEST_F(RPCLedgerEntryTest, LedgerEntryDeleted)
|
||||
// Expected Result: return entryNotFound error
|
||||
TEST_F(RPCLedgerEntryTest, LedgerEntryNotExist)
|
||||
{
|
||||
backend->setRange(RANGEMIN, RANGEMAX);
|
||||
auto const ledgerinfo = CreateLedgerHeader(LEDGERHASH, RANGEMAX);
|
||||
EXPECT_CALL(*backend, fetchLedgerBySequence(RANGEMAX, _)).WillRepeatedly(Return(ledgerinfo));
|
||||
EXPECT_CALL(*backend, doFetchLedgerObject(ripple::uint256{INDEX1}, RANGEMAX, _))
|
||||
@@ -2916,6 +2920,7 @@ TEST_F(RPCLedgerEntryTest, ObjectDeletedPreviously)
|
||||
// Expected Result: return entryNotFound error
|
||||
TEST_F(RPCLedgerEntryTest, ObjectSeqNotExist)
|
||||
{
|
||||
backend->setRange(RANGEMIN, RANGEMAX);
|
||||
auto const ledgerinfo = CreateLedgerHeader(LEDGERHASH, RANGEMAX);
|
||||
EXPECT_CALL(*backend, fetchLedgerBySequence(RANGEMAX, _)).WillRepeatedly(Return(ledgerinfo));
|
||||
EXPECT_CALL(*backend, doFetchLedgerObject(ripple::uint256{INDEX1}, RANGEMAX, _))
|
||||
@@ -2938,3 +2943,27 @@ TEST_F(RPCLedgerEntryTest, ObjectSeqNotExist)
|
||||
EXPECT_EQ(myerr, "entryNotFound");
|
||||
});
|
||||
}
|
||||
|
||||
using RPCLedgerEntryDeathTest = RPCLedgerEntryTest;
|
||||
|
||||
TEST_F(RPCLedgerEntryDeathTest, RangeNotAvailable)
|
||||
{
|
||||
boost::asio::io_context ctx;
|
||||
bool checkCalled = false;
|
||||
spawn(ctx, [&, _ = make_work_guard(ctx)](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{backend}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
"index": "{}"
|
||||
}})",
|
||||
INDEX1
|
||||
));
|
||||
checkCalled = true;
|
||||
EXPECT_DEATH(
|
||||
{ [[maybe_unused]] auto __ = handler.process(req, Context{yield}); }, "Ledger range must be available"
|
||||
);
|
||||
});
|
||||
|
||||
ctx.run();
|
||||
ASSERT_TRUE(checkCalled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user