mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-23 05:05:54 +00:00
Simplify backend mock access for unittests (#1062)
This commit is contained in:
@@ -76,10 +76,10 @@ protected:
|
||||
etl = std::make_shared<MockETLService>();
|
||||
rpcEngine = std::make_shared<MockAsyncRPCEngine>();
|
||||
tagFactory = std::make_shared<util::TagDecoratorFactory>(cfg);
|
||||
subManager = std::make_shared<SubscriptionManager>(cfg, mockBackendPtr);
|
||||
subManager = std::make_shared<SubscriptionManager>(cfg, backend);
|
||||
session = std::make_shared<MockWsBase>(*tagFactory);
|
||||
handler = std::make_shared<RPCServerHandler<MockAsyncRPCEngine, MockETLService>>(
|
||||
cfg, mockBackendPtr, rpcEngine, etl, subManager
|
||||
cfg, backend, rpcEngine, etl, subManager
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,8 +105,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPDefaultPath)
|
||||
"params": [{}]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr result = "{}";
|
||||
static auto constexpr response = R"({
|
||||
@@ -138,8 +137,7 @@ TEST_F(WebRPCServerHandlerTest, WsNormalPath)
|
||||
"id": 99
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr result = "{}";
|
||||
static auto constexpr response = R"({
|
||||
@@ -171,8 +169,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPForwardedPath)
|
||||
"params": [{}]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr result = R"({
|
||||
"result": {
|
||||
@@ -211,8 +208,7 @@ TEST_F(WebRPCServerHandlerTest, WsForwardedPath)
|
||||
"id": 99
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr result = R"({
|
||||
"result": {
|
||||
@@ -271,8 +267,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPErrorPath)
|
||||
]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr requestJSON = R"({
|
||||
"method": "ledger",
|
||||
@@ -314,8 +309,7 @@ TEST_F(WebRPCServerHandlerTest, WsErrorPath)
|
||||
]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr requestJSON = R"({
|
||||
"command": "ledger",
|
||||
@@ -395,8 +389,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPInvalidAPIVersion)
|
||||
}]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = "invalid_API_version";
|
||||
|
||||
@@ -415,8 +408,7 @@ TEST_F(WebRPCServerHandlerTest, WSInvalidAPIVersion)
|
||||
"api_version": null
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = R"({
|
||||
"error": "invalid_API_version",
|
||||
@@ -440,8 +432,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPBadSyntaxWhenRequestSubscribe)
|
||||
{
|
||||
static auto constexpr request = R"({"method": "subscribe"})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = R"({
|
||||
"result": {
|
||||
@@ -467,8 +458,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPMissingCommand)
|
||||
{
|
||||
static auto constexpr request = R"({"method2": "server_info"})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = "Null method";
|
||||
|
||||
@@ -483,8 +473,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPCommandNotString)
|
||||
{
|
||||
static auto constexpr request = R"({"method": 1})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = "method is not string";
|
||||
|
||||
@@ -499,8 +488,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPCommandIsEmpty)
|
||||
{
|
||||
static auto constexpr request = R"({"method": ""})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = "method is empty";
|
||||
|
||||
@@ -519,8 +507,7 @@ TEST_F(WebRPCServerHandlerTest, WsMissingCommand)
|
||||
"id": 99
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response = R"({
|
||||
"error": "missingCommand",
|
||||
@@ -545,8 +532,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPParamsUnparseableNotArray)
|
||||
{
|
||||
static auto constexpr response = "params unparseable";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr requestJSON = R"({
|
||||
"method": "ledger",
|
||||
@@ -564,8 +550,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPParamsUnparseableArrayWithDigit)
|
||||
{
|
||||
static auto constexpr response = "params unparseable";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr requestJSON = R"({
|
||||
"method": "ledger",
|
||||
@@ -595,8 +580,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPInternalError)
|
||||
}
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr requestJSON = R"({
|
||||
"method": "ledger",
|
||||
@@ -627,8 +611,7 @@ TEST_F(WebRPCServerHandlerTest, WsInternalError)
|
||||
}
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr requestJSON = R"({
|
||||
"command": "ledger",
|
||||
@@ -649,8 +632,7 @@ TEST_F(WebRPCServerHandlerTest, HTTPOutDated)
|
||||
"params": [{}]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr result = "{}";
|
||||
static auto constexpr response = R"({
|
||||
@@ -687,8 +669,7 @@ TEST_F(WebRPCServerHandlerTest, WsOutdated)
|
||||
"id": 99
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr result = "{}";
|
||||
static auto constexpr response = R"({
|
||||
@@ -723,15 +704,14 @@ TEST_F(WebRPCServerHandlerTest, WsTooBusy)
|
||||
|
||||
auto localRpcEngine = std::make_shared<MockRPCEngine>();
|
||||
auto localHandler = std::make_shared<RPCServerHandler<MockRPCEngine, MockETLService>>(
|
||||
cfg, mockBackendPtr, localRpcEngine, etl, subManager
|
||||
cfg, backend, localRpcEngine, etl, subManager
|
||||
);
|
||||
static auto constexpr request = R"({
|
||||
"command": "server_info",
|
||||
"id": 99
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response =
|
||||
R"({
|
||||
@@ -753,15 +733,14 @@ TEST_F(WebRPCServerHandlerTest, HTTPTooBusy)
|
||||
{
|
||||
auto localRpcEngine = std::make_shared<MockRPCEngine>();
|
||||
auto localHandler = std::make_shared<RPCServerHandler<MockRPCEngine, MockETLService>>(
|
||||
cfg, mockBackendPtr, localRpcEngine, etl, subManager
|
||||
cfg, backend, localRpcEngine, etl, subManager
|
||||
);
|
||||
static auto constexpr request = R"({
|
||||
"method": "server_info",
|
||||
"params": [{}]
|
||||
})";
|
||||
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
backend->setRange(MINSEQ, MAXSEQ);
|
||||
|
||||
static auto constexpr response =
|
||||
R"({
|
||||
|
||||
Reference in New Issue
Block a user