mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-17 02:05:52 +00:00
@@ -46,7 +46,7 @@ class RPCAccountHandlerTest : public HandlerBaseTest
|
||||
|
||||
TEST_F(RPCAccountHandlerTest, NonHexLedgerHash)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -62,12 +62,11 @@ TEST_F(RPCAccountHandlerTest, NonHexLedgerHash)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledger_hashMalformed");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountHandlerTest, NonStringLedgerHash)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -83,12 +82,11 @@ TEST_F(RPCAccountHandlerTest, NonStringLedgerHash)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledger_hashNotString");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountHandlerTest, InvalidLedgerIndexString)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -104,12 +102,11 @@ TEST_F(RPCAccountHandlerTest, InvalidLedgerIndexString)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledgerIndexMalformed");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountHandlerTest, MarkerNotString)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -124,7 +121,6 @@ TEST_F(RPCAccountHandlerTest, MarkerNotString)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "markerNotString");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case : invalid marker
|
||||
@@ -132,7 +128,7 @@ TEST_F(RPCAccountHandlerTest, MarkerNotString)
|
||||
// former will be read as hex, and the latter using boost lexical cast.
|
||||
TEST_F(RPCAccountHandlerTest, InvalidMarker)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -147,7 +143,7 @@ TEST_F(RPCAccountHandlerTest, InvalidMarker)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "Malformed cursor");
|
||||
});
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -161,13 +157,12 @@ TEST_F(RPCAccountHandlerTest, InvalidMarker)
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// the limit is between 10 400
|
||||
TEST_F(RPCAccountHandlerTest, IncorrectLimit)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -181,7 +176,7 @@ TEST_F(RPCAccountHandlerTest, IncorrectLimit)
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -200,7 +195,7 @@ TEST_F(RPCAccountHandlerTest, IncorrectLimit)
|
||||
// error case: account invalid format, length is incorrect
|
||||
TEST_F(RPCAccountHandlerTest, AccountInvalidFormat)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
|
||||
@@ -211,13 +206,12 @@ TEST_F(RPCAccountHandlerTest, AccountInvalidFormat)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "accountMalformed");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case: account invalid format
|
||||
TEST_F(RPCAccountHandlerTest, AccountNotString)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(R"({
|
||||
"account": 12
|
||||
@@ -229,7 +223,6 @@ TEST_F(RPCAccountHandlerTest, AccountNotString)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "accountNotString");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case ledger non exist via hash
|
||||
@@ -249,7 +242,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
LEDGERHASH));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_FALSE(output);
|
||||
@@ -258,7 +251,6 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledgerNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case ledger non exist via index
|
||||
@@ -278,7 +270,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex)
|
||||
"ledger_index": "4"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_FALSE(output);
|
||||
@@ -286,7 +278,6 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex)
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledgerNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case ledger > max seq via hash
|
||||
@@ -309,7 +300,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
LEDGERHASH));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_FALSE(output);
|
||||
@@ -317,7 +308,6 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledgerNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case ledger > max seq via index
|
||||
@@ -336,7 +326,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
"ledger_index": "31"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_FALSE(output);
|
||||
@@ -344,7 +334,6 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledgerNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// error case account not exist
|
||||
@@ -369,7 +358,7 @@ TEST_F(RPCAccountHandlerTest, NonExistAccount)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
LEDGERHASH));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_FALSE(output);
|
||||
@@ -377,7 +366,6 @@ TEST_F(RPCAccountHandlerTest, NonExistAccount)
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "accountNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// normal case when only provide account
|
||||
@@ -453,13 +441,12 @@ TEST_F(RPCAccountHandlerTest, DefaultParameterTest)
|
||||
"account": "{}"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// normal case : limit is used
|
||||
@@ -511,7 +498,7 @@ TEST_F(RPCAccountHandlerTest, UseLimit)
|
||||
"limit": 20
|
||||
}})",
|
||||
ACCOUNT));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
@@ -521,7 +508,6 @@ TEST_F(RPCAccountHandlerTest, UseLimit)
|
||||
(*output).as_object().at("marker").as_string().c_str(),
|
||||
EndsWith(",0"));
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// normal case : destination is used
|
||||
@@ -586,13 +572,12 @@ TEST_F(RPCAccountHandlerTest, UseDestination)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT3));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 20);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// normal case : but the lines is emtpy
|
||||
@@ -628,13 +613,12 @@ TEST_F(RPCAccountHandlerTest, EmptyChannel)
|
||||
"account": "{}"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 0);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// Return expiration cancel_offer source_tag destination_tag when available
|
||||
@@ -721,13 +705,12 @@ TEST_F(RPCAccountHandlerTest, OptionalResponseField)
|
||||
"account": "{}"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// normal case : test marker output correct
|
||||
@@ -799,7 +782,7 @@ TEST_F(RPCAccountHandlerTest, MarkerOutput)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
limit));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
@@ -808,7 +791,6 @@ TEST_F(RPCAccountHandlerTest, MarkerOutput)
|
||||
fmt::format("{},{}", INDEX1, nextPage));
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 15);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// normal case : handler marker correctly
|
||||
@@ -867,7 +849,7 @@ TEST_F(RPCAccountHandlerTest, MarkerInput)
|
||||
limit,
|
||||
INDEX1,
|
||||
nextPage));
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
@@ -877,5 +859,4 @@ TEST_F(RPCAccountHandlerTest, MarkerInput)
|
||||
EXPECT_EQ(
|
||||
(*output).as_object().at("channels").as_array().size(), limit - 1);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
@@ -64,14 +64,13 @@ TEST_F(RPCAccountCurrenciesHandlerTest, AccountNotExsit)
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "accountNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaSequence)
|
||||
@@ -90,14 +89,13 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaSequence)
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
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");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaHash)
|
||||
@@ -118,14 +116,13 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaHash)
|
||||
ACCOUNT,
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(input);
|
||||
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");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountCurrenciesHandlerTest, DefaultParameter)
|
||||
@@ -193,12 +190,11 @@ TEST_F(RPCAccountCurrenciesHandlerTest, DefaultParameter)
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUTPUT));
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderHash)
|
||||
@@ -239,11 +235,10 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderHash)
|
||||
ACCOUNT,
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeq)
|
||||
@@ -285,11 +280,10 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeq)
|
||||
ACCOUNT,
|
||||
ledgerSeq));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(input, yield);
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(
|
||||
(*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ TEST_P(ParameterTest, CheckError)
|
||||
{
|
||||
auto bundle = GetParam();
|
||||
auto const handler = AnyHandler{GatewayBalancesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output =
|
||||
handler.process(json::parse(bundle.testJson), yield);
|
||||
ASSERT_FALSE(output);
|
||||
@@ -81,7 +81,6 @@ TEST_P(ParameterTest, CheckError)
|
||||
EXPECT_EQ(
|
||||
err.at("error_message").as_string(), bundle.expectedErrorMessage);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
auto
|
||||
@@ -199,7 +198,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFound)
|
||||
.WillByDefault(Return(std::optional<ripple::LedgerInfo>{}));
|
||||
|
||||
auto const handler = AnyHandler{GatewayBalancesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(
|
||||
json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -214,7 +213,6 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFound)
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "ledgerNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCGatewayBalancesHandlerTest, AccountNotFound)
|
||||
@@ -237,7 +235,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, AccountNotFound)
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(1);
|
||||
|
||||
auto const handler = AnyHandler{GatewayBalancesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(
|
||||
json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -250,7 +248,6 @@ TEST_F(RPCGatewayBalancesHandlerTest, AccountNotFound)
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "accountNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet)
|
||||
@@ -289,7 +286,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet)
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||
|
||||
auto const handler = AnyHandler{GatewayBalancesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(
|
||||
json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -304,7 +301,6 @@ TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), "invalidHotWallet");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
struct NormalTestBundle
|
||||
@@ -369,7 +365,7 @@ TEST_P(NormalPathTest, CheckOutput)
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||
|
||||
auto const handler = AnyHandler{GatewayBalancesHandler{mockBackendPtr}};
|
||||
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
|
||||
runSpawn([&](auto& yield) {
|
||||
auto const output = handler.process(
|
||||
json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -382,7 +378,6 @@ TEST_P(NormalPathTest, CheckOutput)
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value(), json::parse(bundle.expectedJson));
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
auto
|
||||
|
||||
@@ -549,7 +549,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
TEST_P(LedgerEntryParameterTest, InvalidParams)
|
||||
{
|
||||
auto const testBundle = GetParam();
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, yield);
|
||||
@@ -563,7 +563,6 @@ TEST_P(LedgerEntryParameterTest, InvalidParams)
|
||||
err.at("error_message").as_string(),
|
||||
testBundle.expectedErrorMessage);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// parameterized test cases for index
|
||||
@@ -591,7 +590,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
TEST_P(IndexTest, InvalidIndexUint256)
|
||||
{
|
||||
auto const index = GetParam();
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -605,13 +604,12 @@ TEST_P(IndexTest, InvalidIndexUint256)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), index + "Malformed");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_P(IndexTest, InvalidIndexNotString)
|
||||
{
|
||||
auto const index = GetParam();
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -625,7 +623,6 @@ TEST_P(IndexTest, InvalidIndexNotString)
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
EXPECT_EQ(err.at("error_message").as_string(), index + "NotString");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCLedgerEntryTest, LedgerEntryNotFound)
|
||||
@@ -646,7 +643,7 @@ TEST_F(RPCLedgerEntryTest, LedgerEntryNotFound)
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject(key, RANGEMAX, _))
|
||||
.WillByDefault(Return(std::optional<Blob>{}));
|
||||
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -658,7 +655,6 @@ TEST_F(RPCLedgerEntryTest, LedgerEntryNotFound)
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "entryNotFound");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
struct NormalPathTestBundle
|
||||
@@ -952,7 +948,7 @@ TEST_P(RPCLedgerEntryNormalPathTest, NormalPath)
|
||||
.WillByDefault(
|
||||
Return(testBundle.mockedEntity.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, yield);
|
||||
@@ -966,7 +962,6 @@ TEST_P(RPCLedgerEntryNormalPathTest, NormalPath)
|
||||
ripple::uint256(output.value().at("index").as_string().c_str()),
|
||||
testBundle.expectedIndex);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
// this testcase will test the deserialization of ledger entry
|
||||
@@ -1010,7 +1005,7 @@ TEST_F(RPCLedgerEntryTest, BinaryFalse)
|
||||
doFetchLedgerObject(ripple::uint256{INDEX1}, RANGEMAX, _))
|
||||
.WillByDefault(Return(ledgerEntry.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -1021,7 +1016,6 @@ TEST_F(RPCLedgerEntryTest, BinaryFalse)
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCLedgerEntryTest, UnexpectedLedgerType)
|
||||
@@ -1044,7 +1038,7 @@ TEST_F(RPCLedgerEntryTest, UnexpectedLedgerType)
|
||||
doFetchLedgerObject(ripple::uint256{INDEX1}, RANGEMAX, _))
|
||||
.WillByDefault(Return(ledgerEntry.getSerializer().peekData()));
|
||||
|
||||
boost::asio::spawn(ctx, [&, this](boost::asio::yield_context yield) {
|
||||
runSpawn([&, this](auto& yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -1054,5 +1048,4 @@ TEST_F(RPCLedgerEntryTest, UnexpectedLedgerType)
|
||||
auto const output = handler.process(req, yield);
|
||||
ASSERT_FALSE(output);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class RPCTxTest : public HandlerBaseTest
|
||||
|
||||
TEST_F(RPCTxTest, ExcessiveLgrRange)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -58,12 +58,11 @@ TEST_F(RPCTxTest, ExcessiveLgrRange)
|
||||
EXPECT_EQ(
|
||||
err.at("error_message").as_string(), "Ledger range exceeds 1000.");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCTxTest, InvalidLgrRange)
|
||||
{
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -81,7 +80,6 @@ TEST_F(RPCTxTest, InvalidLgrRange)
|
||||
EXPECT_EQ(
|
||||
err.at("error_message").as_string(), "Ledger range is invalid.");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCTxTest, TxnNotFound)
|
||||
@@ -90,7 +88,7 @@ TEST_F(RPCTxTest, TxnNotFound)
|
||||
ON_CALL(*rawBackendPtr, fetchTransaction(ripple::uint256{TXNID}, _))
|
||||
.WillByDefault(Return(std::optional<TransactionAndMetadata>{}));
|
||||
EXPECT_CALL(*rawBackendPtr, fetchTransaction).Times(1);
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -106,7 +104,6 @@ TEST_F(RPCTxTest, TxnNotFound)
|
||||
EXPECT_EQ(
|
||||
err.at("error_message").as_string(), "Transaction not found.");
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllFalse)
|
||||
@@ -117,7 +114,7 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllFalse)
|
||||
ON_CALL(*rawBackendPtr, fetchTransaction(ripple::uint256{TXNID}, _))
|
||||
.WillByDefault(Return(std::optional<TransactionAndMetadata>{}));
|
||||
EXPECT_CALL(*rawBackendPtr, fetchTransaction).Times(1);
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -136,7 +133,6 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllFalse)
|
||||
err.at("error_message").as_string(), "Transaction not found.");
|
||||
EXPECT_EQ(err.at("searched_all").as_bool(), false);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllTrue)
|
||||
@@ -147,7 +143,7 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllTrue)
|
||||
ON_CALL(*rawBackendPtr, fetchTransaction(ripple::uint256{TXNID}, _))
|
||||
.WillByDefault(Return(std::optional<TransactionAndMetadata>{}));
|
||||
EXPECT_CALL(*rawBackendPtr, fetchTransaction).Times(1);
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -166,7 +162,6 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllTrue)
|
||||
err.at("error_message").as_string(), "Transaction not found.");
|
||||
EXPECT_EQ(err.at("searched_all").as_bool(), true);
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCTxTest, DefaultParameter)
|
||||
@@ -220,7 +215,7 @@ TEST_F(RPCTxTest, DefaultParameter)
|
||||
ON_CALL(*rawBackendPtr, fetchTransaction(ripple::uint256{TXNID}, _))
|
||||
.WillByDefault(Return(tx));
|
||||
EXPECT_CALL(*rawBackendPtr, fetchTransaction).Times(1);
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -232,7 +227,6 @@ TEST_F(RPCTxTest, DefaultParameter)
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
TEST_F(RPCTxTest, ReturnBinary)
|
||||
@@ -258,7 +252,7 @@ TEST_F(RPCTxTest, ReturnBinary)
|
||||
ON_CALL(*rawBackendPtr, fetchTransaction(ripple::uint256{TXNID}, _))
|
||||
.WillByDefault(Return(tx));
|
||||
EXPECT_CALL(*rawBackendPtr, fetchTransaction).Times(1);
|
||||
boost::asio::spawn(ctx, [this](boost::asio::yield_context yield) {
|
||||
runSpawn([this](auto& yield) {
|
||||
auto const handler = AnyHandler{TxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(
|
||||
R"({{
|
||||
@@ -271,5 +265,4 @@ TEST_F(RPCTxTest, ReturnBinary)
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
ctx.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user