account_offer in new RPC framework (#567)

Fixes #569
This commit is contained in:
cyan317
2023-03-29 16:40:51 +01:00
committed by GitHub
parent 75c2011845
commit e9937fab76
20 changed files with 1300 additions and 19 deletions

View File

@@ -254,7 +254,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash)
}
// error case ledger non exist via index
TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex)
TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerStringIndex)
{
MockBackend* rawBackendPtr =
static_cast<MockBackend*>(mockBackendPtr.get());
@@ -280,6 +280,32 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex)
});
}
TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIntIndex)
{
MockBackend* rawBackendPtr =
static_cast<MockBackend*>(mockBackendPtr.get());
mockBackendPtr->updateRange(10); // min
mockBackendPtr->updateRange(30); // max
// mock fetchLedgerBySequence return empty
ON_CALL(*rawBackendPtr, fetchLedgerBySequence)
.WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
auto const input = json::parse(fmt::format(
R"({{
"account": "{}",
"ledger_index": 4
}})",
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
EXPECT_EQ(err.at("error_message").as_string(), "ledgerNotFound");
});
}
// error case ledger > max seq via hash
// idk why this case will happen in reality
TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash2)