mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-27 23:25:53 +00:00
@@ -40,6 +40,60 @@ class RPCAccountChannelsHandlerTest : public HandlerBaseTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(RPCAccountChannelsHandlerTest, LimitNotInt)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"account": "{}",
|
||||
"limit": "t"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountChannelsHandlerTest, LimitNagetive)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"account": "{}",
|
||||
"limit": -1
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountChannelsHandlerTest, LimitZero)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"account": "{}",
|
||||
"limit": 0
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountChannelsHandlerTest, NonHexLedgerHash)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
@@ -51,7 +105,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonHexLedgerHash)
|
||||
"ledger_hash": "xxx"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -71,7 +125,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonStringLedgerHash)
|
||||
"ledger_hash": 123
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -91,7 +145,7 @@ TEST_F(RPCAccountChannelsHandlerTest, InvalidLedgerIndexString)
|
||||
"ledger_index": "notvalidated"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -110,7 +164,7 @@ TEST_F(RPCAccountChannelsHandlerTest, MarkerNotString)
|
||||
"marker": 9
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -132,7 +186,7 @@ TEST_F(RPCAccountChannelsHandlerTest, InvalidMarker)
|
||||
"marker": "123invalid"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -147,7 +201,7 @@ TEST_F(RPCAccountChannelsHandlerTest, InvalidMarker)
|
||||
"marker": 401
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -163,7 +217,7 @@ TEST_F(RPCAccountChannelsHandlerTest, AccountInvalidFormat)
|
||||
auto const input = json::parse(R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
|
||||
@@ -179,7 +233,7 @@ TEST_F(RPCAccountChannelsHandlerTest, AccountNotString)
|
||||
auto const input = json::parse(R"({
|
||||
"account": 12
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -206,7 +260,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -232,7 +286,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonExistLedgerViaLedgerStringIndex)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -256,7 +310,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonExistLedgerViaLedgerIntIndex)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -284,7 +338,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -309,7 +363,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -338,7 +392,7 @@ TEST_F(RPCAccountChannelsHandlerTest, NonExistAccount)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountChannelsHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -414,7 +468,7 @@ TEST_F(RPCAccountChannelsHandlerTest, DefaultParameterTest)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
@@ -466,7 +520,7 @@ TEST_F(RPCAccountChannelsHandlerTest, UseLimit)
|
||||
"limit": 20
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 20);
|
||||
@@ -481,7 +535,7 @@ TEST_F(RPCAccountChannelsHandlerTest, UseLimit)
|
||||
"limit": 9
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit?
|
||||
});
|
||||
|
||||
@@ -493,7 +547,7 @@ TEST_F(RPCAccountChannelsHandlerTest, UseLimit)
|
||||
"limit": 401
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit?
|
||||
});
|
||||
}
|
||||
@@ -555,7 +609,7 @@ TEST_F(RPCAccountChannelsHandlerTest, UseDestination)
|
||||
ACCOUNT3));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 20);
|
||||
});
|
||||
@@ -591,7 +645,7 @@ TEST_F(RPCAccountChannelsHandlerTest, EmptyChannel)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 0);
|
||||
});
|
||||
@@ -676,7 +730,7 @@ TEST_F(RPCAccountChannelsHandlerTest, OptionalResponseField)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
@@ -744,7 +798,7 @@ TEST_F(RPCAccountChannelsHandlerTest, MarkerOutput)
|
||||
limit));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("marker").as_string().c_str(), fmt::format("{},{}", INDEX1, nextPage));
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 15);
|
||||
@@ -802,7 +856,7 @@ TEST_F(RPCAccountChannelsHandlerTest, MarkerInput)
|
||||
nextPage));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE((*output).as_object().if_contains("marker") == nullptr);
|
||||
// the first item is the marker itself, so the result will have limit-1
|
||||
@@ -851,7 +905,7 @@ TEST_F(RPCAccountChannelsHandlerTest, LimitLessThanMin)
|
||||
AccountChannelsHandler::LIMIT_MIN - 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 2);
|
||||
EXPECT_EQ((*output).as_object().at("limit").as_uint64(), AccountChannelsHandler::LIMIT_MIN);
|
||||
@@ -898,7 +952,7 @@ TEST_F(RPCAccountChannelsHandlerTest, LimitMoreThanMax)
|
||||
AccountChannelsHandler::LIMIT_MAX + 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 2);
|
||||
EXPECT_EQ((*output).as_object().at("limit").as_uint64(), AccountChannelsHandler::LIMIT_MAX);
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, AccountNotExist)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -83,7 +83,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaIntSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -110,7 +110,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaStringSequence)
|
||||
seq));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -137,7 +137,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -204,7 +204,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, DefaultParameter)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUTPUT));
|
||||
});
|
||||
@@ -244,7 +244,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
});
|
||||
}
|
||||
@@ -285,7 +285,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeq)
|
||||
ledgerSeq));
|
||||
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ TEST_P(AccountInfoParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -132,7 +132,7 @@ TEST_F(RPCAccountInfoHandlerTest, LedgerNonExistViaIntSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -157,7 +157,7 @@ TEST_F(RPCAccountInfoHandlerTest, LedgerNonExistViaStringSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -184,7 +184,7 @@ TEST_F(RPCAccountInfoHandlerTest, LedgerNonExistViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -211,7 +211,7 @@ TEST_F(RPCAccountInfoHandlerTest, AccountNotExist)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -239,7 +239,7 @@ TEST_F(RPCAccountInfoHandlerTest, AccountInvalid)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "dbDeserialization");
|
||||
@@ -274,7 +274,7 @@ TEST_F(RPCAccountInfoHandlerTest, SignerListsInvalid)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "dbDeserialization");
|
||||
@@ -373,7 +373,7 @@ TEST_F(RPCAccountInfoHandlerTest, SignerListsTrue)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -443,7 +443,7 @@ TEST_F(RPCAccountInfoHandlerTest, Flags)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -472,7 +472,7 @@ TEST_F(RPCAccountInfoHandlerTest, IdentAndSignerListsFalse)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_FALSE(output->as_object().contains("signer_lists"));
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonHexLedgerHash)
|
||||
"ledger_hash": "xxx"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -76,7 +76,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonStringLedgerHash)
|
||||
"ledger_hash": 123
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -96,7 +96,7 @@ TEST_F(RPCAccountLinesHandlerTest, InvalidLedgerIndexString)
|
||||
"ledger_index": "notvalidated"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -115,7 +115,7 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerNotString)
|
||||
"marker": 9
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -137,7 +137,7 @@ TEST_F(RPCAccountLinesHandlerTest, InvalidMarker)
|
||||
"marker": "123invalid"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -152,7 +152,7 @@ TEST_F(RPCAccountLinesHandlerTest, InvalidMarker)
|
||||
"marker": 401
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -169,7 +169,7 @@ TEST_F(RPCAccountLinesHandlerTest, AccountInvalidFormat)
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
|
||||
@@ -186,7 +186,7 @@ TEST_F(RPCAccountLinesHandlerTest, AccountNotString)
|
||||
R"({
|
||||
"account": 12
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -204,7 +204,7 @@ TEST_F(RPCAccountLinesHandlerTest, PeerInvalidFormat)
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"peer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actMalformed");
|
||||
@@ -221,7 +221,7 @@ TEST_F(RPCAccountLinesHandlerTest, PeerNotString)
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"peer": 12
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -230,6 +230,57 @@ TEST_F(RPCAccountLinesHandlerTest, PeerNotString)
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountLinesHandlerTest, LimitNotInt)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"limit": "t"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountLinesHandlerTest, LimitNagetive)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"limit": -1
|
||||
})");
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountLinesHandlerTest, LimitZero)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"limit": 0
|
||||
})");
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
// error case ledger non exist via hash
|
||||
TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
{
|
||||
@@ -248,7 +299,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -274,7 +325,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerStringIndex)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -298,7 +349,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerIntIndex)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -326,7 +377,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -351,7 +402,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -380,7 +431,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistAccount)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountLinesHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -463,7 +514,7 @@ TEST_F(RPCAccountLinesHandlerTest, DefaultParameterTest)
|
||||
})";
|
||||
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
@@ -516,7 +567,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseLimit)
|
||||
"limit": 20
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 20);
|
||||
@@ -531,7 +582,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseLimit)
|
||||
"limit": 9
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit somehow?
|
||||
});
|
||||
|
||||
@@ -543,7 +594,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseLimit)
|
||||
"limit": 401
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit somehow?
|
||||
});
|
||||
}
|
||||
@@ -607,7 +658,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseDestination)
|
||||
ACCOUNT3));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 20);
|
||||
});
|
||||
@@ -643,7 +694,7 @@ TEST_F(RPCAccountLinesHandlerTest, EmptyChannel)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 0);
|
||||
});
|
||||
@@ -731,7 +782,7 @@ TEST_F(RPCAccountLinesHandlerTest, OptionalResponseField)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
@@ -800,7 +851,7 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerOutput)
|
||||
limit));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ((*output).as_object().at("marker").as_string().c_str(), fmt::format("{},{}", INDEX1, nextPage));
|
||||
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 15);
|
||||
@@ -859,7 +910,7 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerInput)
|
||||
nextPage));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE((*output).as_object().if_contains("marker") == nullptr);
|
||||
// the first item is the marker itself, so the result will have limit-1
|
||||
@@ -945,7 +996,7 @@ TEST_F(RPCAccountLinesHandlerTest, LimitLessThanMin)
|
||||
AccountLinesHandler::LIMIT_MIN);
|
||||
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
@@ -1028,7 +1079,7 @@ TEST_F(RPCAccountLinesHandlerTest, LimitMoreThanMax)
|
||||
AccountLinesHandler::LIMIT_MAX);
|
||||
|
||||
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
});
|
||||
|
||||
@@ -114,6 +114,18 @@ generateTestValuesForParametersTest()
|
||||
"invalidParams",
|
||||
"Invalid parameters.",
|
||||
},
|
||||
{
|
||||
"LimitNegative",
|
||||
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": -1})",
|
||||
"invalidParams",
|
||||
"Invalid parameters.",
|
||||
},
|
||||
{
|
||||
"LimitZero",
|
||||
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": 0})",
|
||||
"invalidParams",
|
||||
"Invalid parameters.",
|
||||
},
|
||||
{
|
||||
"MarkerNotString",
|
||||
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "marker": 123})",
|
||||
@@ -141,7 +153,7 @@ TEST_P(AccountNFTParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -168,7 +180,7 @@ TEST_F(RPCAccountNFTsHandlerTest, LedgerNotFoundViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -195,7 +207,7 @@ TEST_F(RPCAccountNFTsHandlerTest, LedgerNotFoundViaStringIndex)
|
||||
seq));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -222,7 +234,7 @@ TEST_F(RPCAccountNFTsHandlerTest, LedgerNotFoundViaIntIndex)
|
||||
seq));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -249,7 +261,7 @@ TEST_F(RPCAccountNFTsHandlerTest, AccountNotFound)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -311,7 +323,7 @@ TEST_F(RPCAccountNFTsHandlerTest, NormalPath)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -348,7 +360,7 @@ TEST_F(RPCAccountNFTsHandlerTest, Limit)
|
||||
limit));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_nfts").as_array().size(), 20);
|
||||
EXPECT_EQ(output->as_object().at("marker").as_string(), ripple::strHex(firstPage));
|
||||
@@ -384,7 +396,7 @@ TEST_F(RPCAccountNFTsHandlerTest, Marker)
|
||||
PAGE));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_nfts").as_array().size(), 1);
|
||||
});
|
||||
@@ -447,7 +459,7 @@ TEST_F(RPCAccountNFTsHandlerTest, LimitLessThanMin)
|
||||
AccountNFTsHandler::LIMIT_MIN - 1));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -510,7 +522,7 @@ TEST_F(RPCAccountNFTsHandlerTest, LimitMoreThanMax)
|
||||
AccountNFTsHandler::LIMIT_MAX + 1));
|
||||
auto const handler = AnyHandler{AccountNFTsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
|
||||
@@ -106,6 +106,16 @@ generateTestValuesForParametersTest()
|
||||
R"({"account":"rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "limit":"1"})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
AccountObjectsParamTestCaseBundle{
|
||||
"LimitNagetive",
|
||||
R"({"account":"rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "limit":-1})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
AccountObjectsParamTestCaseBundle{
|
||||
"LimitZero",
|
||||
R"({"account":"rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "limit":0})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
AccountObjectsParamTestCaseBundle{
|
||||
"MarkerNotString",
|
||||
R"({"account":"rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "marker":9})",
|
||||
@@ -148,7 +158,7 @@ TEST_P(AccountObjectsParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -174,7 +184,7 @@ TEST_F(RPCAccountObjectsHandlerTest, LedgerNonExistViaIntSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -199,7 +209,7 @@ TEST_F(RPCAccountObjectsHandlerTest, LedgerNonExistViaStringSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -226,7 +236,7 @@ TEST_F(RPCAccountObjectsHandlerTest, LedgerNonExistViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -253,7 +263,7 @@ TEST_F(RPCAccountObjectsHandlerTest, AccountNotExist)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -332,7 +342,7 @@ TEST_F(RPCAccountObjectsHandlerTest, DefaultParameterNoNFTFound)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -385,7 +395,7 @@ TEST_F(RPCAccountObjectsHandlerTest, Limit)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), limit);
|
||||
EXPECT_EQ(output->as_object().at("marker").as_string(), fmt::format("{},{}", INDEX1, 0));
|
||||
@@ -435,7 +445,7 @@ TEST_F(RPCAccountObjectsHandlerTest, Marker)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), limit - 1);
|
||||
EXPECT_FALSE(output->as_object().contains("marker"));
|
||||
@@ -496,7 +506,7 @@ TEST_F(RPCAccountObjectsHandlerTest, MultipleDirNoNFT)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), count * 2);
|
||||
EXPECT_EQ(output->as_object().at("marker").as_string(), fmt::format("{},{}", INDEX1, nextpage));
|
||||
@@ -554,7 +564,7 @@ TEST_F(RPCAccountObjectsHandlerTest, TypeFilter)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), 1);
|
||||
});
|
||||
@@ -610,7 +620,7 @@ TEST_F(RPCAccountObjectsHandlerTest, TypeFilterReturnEmpty)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), 0);
|
||||
});
|
||||
@@ -673,7 +683,7 @@ TEST_F(RPCAccountObjectsHandlerTest, DeletionBlockersOnlyFilter)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), 2);
|
||||
});
|
||||
@@ -725,7 +735,7 @@ TEST_F(RPCAccountObjectsHandlerTest, DeletionBlockersOnlyFilterWithTypeFilter)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), 1);
|
||||
});
|
||||
@@ -792,7 +802,7 @@ TEST_F(RPCAccountObjectsHandlerTest, DeletionBlockersOnlyFilterEmptyResult)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), 0);
|
||||
});
|
||||
@@ -858,7 +868,7 @@ TEST_F(RPCAccountObjectsHandlerTest, DeletionBlockersOnlyFilterWithIncompatibleT
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), 0);
|
||||
});
|
||||
@@ -976,7 +986,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTMixOtherObjects)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -1022,7 +1032,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTReachLimitReturnMarker)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("account_objects").as_array().size(), 10);
|
||||
EXPECT_EQ(
|
||||
@@ -1075,7 +1085,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTReachLimitNoMarker)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("account_objects").as_array().size(), 11);
|
||||
//"0000000000000000000000000000000000000000000000000000000000000000,4294967295"
|
||||
@@ -1158,7 +1168,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTMarker)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("account_objects").as_array().size(), 11 + 3);
|
||||
EXPECT_FALSE(output.value().as_object().contains("marker"));
|
||||
@@ -1219,7 +1229,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTMarkerNoMoreNFT)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("account_objects").as_array().size(), 3);
|
||||
EXPECT_FALSE(output.value().as_object().contains("marker"));
|
||||
@@ -1251,7 +1261,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTMarkerNotInRange)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -1288,7 +1298,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTMarkerNotExist)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -1369,7 +1379,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTLimitAdjust)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("account_objects").as_array().size(), 12);
|
||||
// marker not in NFT "1B8590C01B0006EDFA9ED60296DD052DC5E90F99659B25014D08E1BC983515BC,0"
|
||||
@@ -1468,7 +1478,7 @@ TEST_F(RPCAccountObjectsHandlerTest, FilterNFT)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -1520,7 +1530,7 @@ TEST_F(RPCAccountObjectsHandlerTest, NFTZeroMarkerNotAffectOtherMarker)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("account_objects").as_array().size(), limit);
|
||||
EXPECT_EQ(output->as_object().at("marker").as_string(), fmt::format("{},{}", INDEX1, 0));
|
||||
@@ -1602,7 +1612,7 @@ TEST_F(RPCAccountObjectsHandlerTest, LimitLessThanMin)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -1683,7 +1693,7 @@ TEST_F(RPCAccountObjectsHandlerTest, LimitMoreThanMax)
|
||||
|
||||
auto const handler = AnyHandler{AccountObjectsHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
|
||||
@@ -107,6 +107,18 @@ generateTestValuesForParametersTest()
|
||||
"invalidParams",
|
||||
"Invalid parameters.",
|
||||
},
|
||||
{
|
||||
"LimitNegative",
|
||||
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": -1})",
|
||||
"invalidParams",
|
||||
"Invalid parameters.",
|
||||
},
|
||||
{
|
||||
"LimitZero",
|
||||
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": 0})",
|
||||
"invalidParams",
|
||||
"Invalid parameters.",
|
||||
},
|
||||
{
|
||||
"MarkerNotString",
|
||||
R"({"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "marker": 123})",
|
||||
@@ -134,7 +146,7 @@ TEST_P(AccountOfferParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -161,7 +173,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -188,7 +200,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaStringIndex)
|
||||
seq));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -215,7 +227,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaIntIndex)
|
||||
seq));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -242,7 +254,7 @@ TEST_F(RPCAccountOffersHandlerTest, AccountNotFound)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -319,7 +331,7 @@ TEST_F(RPCAccountOffersHandlerTest, DefaultParams)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -370,7 +382,7 @@ TEST_F(RPCAccountOffersHandlerTest, Limit)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 10);
|
||||
EXPECT_EQ(output->at("marker").as_string(), fmt::format("{},0", INDEX1));
|
||||
@@ -427,7 +439,7 @@ TEST_F(RPCAccountOffersHandlerTest, Marker)
|
||||
startPage));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 19);
|
||||
EXPECT_FALSE(output->as_object().contains("marker"));
|
||||
@@ -465,7 +477,7 @@ TEST_F(RPCAccountOffersHandlerTest, MarkerNotExists)
|
||||
startPage));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -521,7 +533,7 @@ TEST_F(RPCAccountOffersHandlerTest, LimitLessThanMin)
|
||||
AccountOffersHandler::LIMIT_MIN - 1));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), AccountOffersHandler::LIMIT_MIN);
|
||||
});
|
||||
@@ -575,7 +587,7 @@ TEST_F(RPCAccountOffersHandlerTest, LimitMoreThanMax)
|
||||
AccountOffersHandler::LIMIT_MAX + 1));
|
||||
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), AccountOffersHandler::LIMIT_MAX);
|
||||
});
|
||||
|
||||
@@ -109,6 +109,16 @@ generateTestValuesForParametersTest()
|
||||
R"({"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": "123"})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
AccountTxParamTestCaseBundle{
|
||||
"limitNegative",
|
||||
R"({"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": -1})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
AccountTxParamTestCaseBundle{
|
||||
"limitZero",
|
||||
R"({"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "limit": 0})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
AccountTxParamTestCaseBundle{
|
||||
"MarkerNotObject",
|
||||
R"({"account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "marker": 101})",
|
||||
@@ -216,7 +226,7 @@ TEST_P(AccountTxParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountTxHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -309,7 +319,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexSpecificForwardTrue)
|
||||
ACCOUNT,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
@@ -350,7 +360,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexSpecificForwardFalse)
|
||||
ACCOUNT,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
@@ -391,7 +401,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexNotSpecificForwardTrue)
|
||||
ACCOUNT,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -432,7 +442,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexNotSpecificForwardFalse)
|
||||
ACCOUNT,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -473,7 +483,7 @@ TEST_F(RPCAccountTxHandlerTest, BinaryTrue)
|
||||
ACCOUNT,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -524,7 +534,7 @@ TEST_F(RPCAccountTxHandlerTest, LimitAndMarker)
|
||||
ACCOUNT,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -567,7 +577,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificLedgerIndex)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MAXSEQ - 1);
|
||||
@@ -596,7 +606,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificNonexistLedgerIntIndex)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -622,7 +632,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificNonexistLedgerStringIndex)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -662,7 +672,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificLedgerHash)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
LEDGERHASH));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MAXSEQ - 1);
|
||||
@@ -704,7 +714,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificLedgerIndexValidated)
|
||||
"ledger_index":"validated"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MAXSEQ);
|
||||
@@ -745,7 +755,7 @@ TEST_F(RPCAccountTxHandlerTest, TxLessThanMinSeq)
|
||||
ACCOUNT,
|
||||
MINSEQ + 2,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 2);
|
||||
@@ -786,7 +796,7 @@ TEST_F(RPCAccountTxHandlerTest, TxLargerThanMaxSeq)
|
||||
ACCOUNT,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 2));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
@@ -797,46 +807,6 @@ TEST_F(RPCAccountTxHandlerTest, TxLargerThanMaxSeq)
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountTxHandlerTest, LimitLessThanMin)
|
||||
{
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
|
||||
auto const transCursor = TransactionsAndCursor{transactions, TransactionsCursor{12, 34}};
|
||||
ON_CALL(*rawBackendPtr, fetchAccountTransactions).WillByDefault(Return(transCursor));
|
||||
EXPECT_CALL(
|
||||
*rawBackendPtr,
|
||||
fetchAccountTransactions(
|
||||
testing::_, testing::_, false, testing::Optional(testing::Eq(TransactionsCursor{10, 11})), testing::_))
|
||||
.Times(1);
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{AccountTxHandler{mockBackendPtr}};
|
||||
auto const static input = boost::json::parse(fmt::format(
|
||||
R"({{
|
||||
"account":"{}",
|
||||
"ledger_index_min": {},
|
||||
"ledger_index_max": {},
|
||||
"limit": {},
|
||||
"forward": false,
|
||||
"marker": {{"ledger":10,"seq":11}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
-1,
|
||||
-1,
|
||||
AccountTxHandler::LIMIT_MIN - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("account").as_string(), ACCOUNT);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
EXPECT_EQ(output->at("ledger_index_max").as_uint64(), MAXSEQ);
|
||||
EXPECT_EQ(output->at("limit").as_uint64(), AccountTxHandler::LIMIT_MIN);
|
||||
EXPECT_EQ(output->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
|
||||
EXPECT_EQ(output->at("transactions").as_array().size(), 2);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCAccountTxHandlerTest, NFTTxs)
|
||||
{
|
||||
auto const OUT = R"({
|
||||
@@ -1056,7 +1026,7 @@ TEST_F(RPCAccountTxHandlerTest, NFTTxs)
|
||||
ACCOUNT,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, boost::json::parse(OUT));
|
||||
});
|
||||
|
||||
@@ -89,7 +89,7 @@ TEST_P(BookChangesParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{BookChangesHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -110,7 +110,7 @@ TEST_F(RPCBookChangesHandlerTest, LedgerNonExistViaIntSequence)
|
||||
auto const static input = boost::json::parse(R"({"ledger_index":30})");
|
||||
auto const handler = AnyHandler{BookChangesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -130,7 +130,7 @@ TEST_F(RPCBookChangesHandlerTest, LedgerNonExistViaStringSequence)
|
||||
auto const static input = boost::json::parse(R"({"ledger_index":"30"})");
|
||||
auto const handler = AnyHandler{BookChangesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -155,7 +155,7 @@ TEST_F(RPCBookChangesHandlerTest, LedgerNonExistViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{BookChangesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -206,7 +206,7 @@ TEST_F(RPCBookChangesHandlerTest, NormalPath)
|
||||
|
||||
auto const handler = AnyHandler{BookChangesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(json::parse("{}"), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse("{}"), Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST_P(RPCBookOffersParameterTest, CheckError)
|
||||
auto bundle = GetParam();
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(json::parse(bundle.testJson), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse(bundle.testJson), Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), bundle.expectedError);
|
||||
@@ -289,6 +289,38 @@ generateParameterBookOffersTestBundles()
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
ParameterTestBundle{
|
||||
"LimitNagetive",
|
||||
R"({
|
||||
"taker_pays" :
|
||||
{
|
||||
"currency" : "CNY",
|
||||
"issuer" : "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"taker_gets" :
|
||||
{
|
||||
"currency" : "XRP"
|
||||
},
|
||||
"limit": -1
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
ParameterTestBundle{
|
||||
"LimitZero",
|
||||
R"({
|
||||
"taker_pays" :
|
||||
{
|
||||
"currency" : "CNY",
|
||||
"issuer" : "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
},
|
||||
"taker_gets" :
|
||||
{
|
||||
"currency" : "XRP"
|
||||
},
|
||||
"limit": 0
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
ParameterTestBundle{
|
||||
"LedgerIndexInvalid",
|
||||
R"({
|
||||
@@ -486,7 +518,7 @@ TEST_P(RPCBookOffersNormalPathTest, CheckOutput)
|
||||
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(json::parse(bundle.inputJson), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse(bundle.inputJson), Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value(), json::parse(bundle.expectedJson));
|
||||
});
|
||||
@@ -1091,7 +1123,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaIntSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -1124,7 +1156,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaSequence)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -1159,7 +1191,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaHash)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -1232,84 +1264,12 @@ TEST_F(RPCBookOffersHandlerTest, Limit)
|
||||
ACCOUNT));
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("offers").as_array().size(), 5);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCBookOffersHandlerTest, LimitLessThanMin)
|
||||
{
|
||||
auto const seq = 300;
|
||||
auto const rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
mockBackendPtr->updateRange(10); // min
|
||||
mockBackendPtr->updateRange(seq); // max
|
||||
EXPECT_CALL(*rawBackendPtr, fetchLedgerBySequence).Times(1);
|
||||
// return valid ledgerinfo
|
||||
auto const ledgerinfo = CreateLedgerInfo(LEDGERHASH, seq);
|
||||
ON_CALL(*rawBackendPtr, fetchLedgerBySequence(seq, _)).WillByDefault(Return(ledgerinfo));
|
||||
|
||||
auto const issuer = GetAccountIDWithString(ACCOUNT);
|
||||
// return valid book dir
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchSuccessorKey).Times(1);
|
||||
|
||||
auto const getsXRPPaysUSDBook = getBookBase(std::get<ripple::Book>(
|
||||
RPC::parseBook(ripple::to_currency("USD"), issuer, ripple::xrpCurrency(), ripple::xrpAccount())));
|
||||
ON_CALL(*rawBackendPtr, doFetchSuccessorKey(getsXRPPaysUSDBook, seq, _))
|
||||
.WillByDefault(Return(ripple::uint256{PAYS20USDGETS10XRPBOOKDIR}));
|
||||
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(5);
|
||||
auto const indexes = std::vector<ripple::uint256>(10, ripple::uint256{INDEX2});
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ripple::uint256{PAYS20USDGETS10XRPBOOKDIR}, seq, _))
|
||||
.WillByDefault(Return(CreateOwnerDirLedgerObject(indexes, INDEX1).getSerializer().peekData()));
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ripple::keylet::account(GetAccountIDWithString(ACCOUNT2)).key, seq, _))
|
||||
.WillByDefault(Return(CreateAccountRootObject(ACCOUNT2, 0, 2, 200, 2, INDEX1, 2).getSerializer().peekData()));
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ripple::keylet::fees().key, seq, _))
|
||||
.WillByDefault(Return(CreateFeeSettingBlob(1, 2, 3, 4, 0)));
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ripple::keylet::account(issuer).key, seq, _))
|
||||
.WillByDefault(Return(
|
||||
CreateAccountRootObject(ACCOUNT, 0, 2, 200, 2, INDEX1, 2, TRANSFERRATEX2).getSerializer().peekData()));
|
||||
|
||||
auto const gets10XRPPays20USDOffer = CreateOfferLedgerObject(
|
||||
ACCOUNT2,
|
||||
10,
|
||||
20,
|
||||
ripple::to_string(ripple::xrpCurrency()),
|
||||
ripple::to_string(ripple::to_currency("USD")),
|
||||
toBase58(ripple::xrpAccount()),
|
||||
ACCOUNT,
|
||||
PAYS20USDGETS10XRPBOOKDIR);
|
||||
|
||||
std::vector<Blob> bbs(10, gets10XRPPays20USDOffer.getSerializer().peekData());
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||
|
||||
auto const static input = boost::json::parse(fmt::format(
|
||||
R"({{
|
||||
"taker_gets":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"taker_pays":
|
||||
{{
|
||||
"currency": "USD",
|
||||
"issuer": "{}"
|
||||
}},
|
||||
"limit": {}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
BookOffersHandler::LIMIT_MIN - 1));
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("offers").as_array().size(), BookOffersHandler::LIMIT_MIN);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCBookOffersHandlerTest, LimitMoreThanMax)
|
||||
{
|
||||
auto const seq = 300;
|
||||
@@ -1376,7 +1336,7 @@ TEST_F(RPCBookOffersHandlerTest, LimitMoreThanMax)
|
||||
BookOffersHandler::LIMIT_MAX + 1));
|
||||
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
|
||||
runSpawn([&](boost::asio::yield_context yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().as_object().at("offers").as_array().size(), BookOffersHandler::LIMIT_MAX);
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ TEST_F(RPCDefaultProcessorTest, ValidInput)
|
||||
EXPECT_CALL(handler, spec(_)).WillOnce(ReturnRef(spec));
|
||||
EXPECT_CALL(handler, process(Eq(data), _)).WillOnce(Return(data));
|
||||
|
||||
auto const ret = processor(handler, input, Context{std::ref(yield)});
|
||||
auto const ret = processor(handler, input, Context{yield});
|
||||
ASSERT_TRUE(ret); // no error
|
||||
});
|
||||
}
|
||||
@@ -64,7 +64,7 @@ TEST_F(RPCDefaultProcessorTest, NoInputVaildCall)
|
||||
auto const input = json::parse(R"({})");
|
||||
EXPECT_CALL(handler, process(_)).WillOnce(Return(data));
|
||||
|
||||
auto const ret = processor(handler, input, Context{std::ref(yield)});
|
||||
auto const ret = processor(handler, input, Context{yield});
|
||||
ASSERT_TRUE(ret); // no error
|
||||
});
|
||||
}
|
||||
@@ -79,7 +79,7 @@ TEST_F(RPCDefaultProcessorTest, InvalidInput)
|
||||
auto const spec = RpcSpec{{"something", Required{}}};
|
||||
EXPECT_CALL(handler, spec(_)).WillOnce(ReturnRef(spec));
|
||||
|
||||
auto const ret = processor(handler, input, Context{std::ref(yield)});
|
||||
auto const ret = processor(handler, input, Context{yield});
|
||||
ASSERT_FALSE(ret); // returns error
|
||||
});
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ TEST_P(DepositAuthorizedParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
@@ -203,7 +203,7 @@ TEST_F(RPCDepositAuthorizedTest, LedgerNotExistViaIntSequence)
|
||||
ACCOUNT2,
|
||||
RANGEMAX));
|
||||
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -233,7 +233,7 @@ TEST_F(RPCDepositAuthorizedTest, LedgerNotExistViaStringSequence)
|
||||
ACCOUNT2,
|
||||
RANGEMAX));
|
||||
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -263,7 +263,7 @@ TEST_F(RPCDepositAuthorizedTest, LedgerNotExistViaHash)
|
||||
ACCOUNT2,
|
||||
LEDGERHASH));
|
||||
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -298,7 +298,7 @@ TEST_F(RPCDepositAuthorizedTest, SourceAccountDoesNotExist)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
@@ -338,7 +338,7 @@ TEST_F(RPCDepositAuthorizedTest, DestinationAccountDoesNotExist)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
@@ -385,7 +385,7 @@ TEST_F(RPCDepositAuthorizedTest, AccountsAreEqual)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
@@ -434,7 +434,7 @@ TEST_F(RPCDepositAuthorizedTest, DifferentAccountsNoDepositAuthFlag)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
@@ -484,7 +484,7 @@ TEST_F(RPCDepositAuthorizedTest, DifferentAccountsWithDepositAuthFlagReturnsFals
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
@@ -534,7 +534,7 @@ TEST_F(RPCDepositAuthorizedTest, DifferentAccountsWithDepositAuthFlagReturnsTrue
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{DepositAuthorizedHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
|
||||
@@ -68,7 +68,7 @@ TEST_P(ParameterTest, CheckError)
|
||||
auto bundle = GetParam();
|
||||
auto const handler = AnyHandler{GatewayBalancesHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(json::parse(bundle.testJson), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse(bundle.testJson), Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), bundle.expectedError);
|
||||
@@ -199,7 +199,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaStringIndex)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
seq)),
|
||||
Context{std::ref(yield)});
|
||||
Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -227,7 +227,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaIntIndex)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
seq)),
|
||||
Context{std::ref(yield)});
|
||||
Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -255,7 +255,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaHash)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
LEDGERHASH)),
|
||||
Context{std::ref(yield)});
|
||||
Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -287,7 +287,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, AccountNotFound)
|
||||
"account": "{}"
|
||||
}})",
|
||||
ACCOUNT)),
|
||||
Context{std::ref(yield)});
|
||||
Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -334,7 +334,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT2)),
|
||||
Context{std::ref(yield)});
|
||||
Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidHotWallet");
|
||||
@@ -406,7 +406,7 @@ TEST_P(NormalPathTest, CheckOutput)
|
||||
}})",
|
||||
ACCOUNT,
|
||||
bundle.hotwallet)),
|
||||
Context{std::ref(yield)});
|
||||
Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value(), json::parse(bundle.expectedJson));
|
||||
});
|
||||
|
||||
@@ -77,6 +77,8 @@ generateTestValuesForParametersTest()
|
||||
"ledger_hashNotString", R"({"ledger_hash": 123})", "invalidParams", "ledger_hashNotString"},
|
||||
LedgerDataParamTestCaseBundle{"binaryNotBool", R"({"binary": 123})", "invalidParams", "Invalid parameters."},
|
||||
LedgerDataParamTestCaseBundle{"limitNotInt", R"({"limit": "xxx"})", "invalidParams", "Invalid parameters."},
|
||||
LedgerDataParamTestCaseBundle{"limitNagetive", R"({"limit": -1})", "invalidParams", "Invalid parameters."},
|
||||
LedgerDataParamTestCaseBundle{"limitZero", R"({"limit": 0})", "invalidParams", "Invalid parameters."},
|
||||
LedgerDataParamTestCaseBundle{"markerInvalid", R"({"marker": "xxx"})", "invalidParams", "markerMalformed"},
|
||||
LedgerDataParamTestCaseBundle{
|
||||
"markerOutOfOrder",
|
||||
@@ -107,7 +109,7 @@ TEST_P(LedgerDataParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerDataHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -131,7 +133,7 @@ TEST_F(RPCLedgerDataHandlerTest, LedgerNotExistViaIntSequence)
|
||||
"ledger_index": {}
|
||||
}})",
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -155,7 +157,7 @@ TEST_F(RPCLedgerDataHandlerTest, LedgerNotExistViaStringSequence)
|
||||
"ledger_index": "{}"
|
||||
}})",
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -179,7 +181,7 @@ TEST_F(RPCLedgerDataHandlerTest, LedgerNotExistViaHash)
|
||||
"ledger_hash": "{}"
|
||||
}})",
|
||||
LEDGERHASH));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -208,7 +210,7 @@ TEST_F(RPCLedgerDataHandlerTest, MarkerNotExist)
|
||||
"marker": "{}"
|
||||
}})",
|
||||
INDEX1));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -269,7 +271,7 @@ TEST_F(RPCLedgerDataHandlerTest, NoMarker)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerDataHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(R"({"limit":10})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
//"close_time_human" 's format depends on platform, might be sightly different
|
||||
@@ -338,7 +340,7 @@ TEST_F(RPCLedgerDataHandlerTest, TypeFilter)
|
||||
"type":"state"
|
||||
})");
|
||||
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
//"close_time_human" 's format depends on platform, might be sightly different
|
||||
@@ -395,7 +397,7 @@ TEST_F(RPCLedgerDataHandlerTest, OutOfOrder)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerDataHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(R"({"limit":10, "out_of_order":true})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
EXPECT_EQ(output->as_object().at("ledger").as_object().erase("close_time_human"), 1);
|
||||
@@ -450,7 +452,7 @@ TEST_F(RPCLedgerDataHandlerTest, Marker)
|
||||
"marker": "{}"
|
||||
}})",
|
||||
INDEX1));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_FALSE(output->as_object().contains("ledger"));
|
||||
EXPECT_EQ(output->as_object().at("marker").as_string(), INDEX2);
|
||||
@@ -497,7 +499,7 @@ TEST_F(RPCLedgerDataHandlerTest, DiffMarker)
|
||||
"out_of_order": true
|
||||
}})",
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_FALSE(output->as_object().contains("ledger"));
|
||||
EXPECT_EQ(output->as_object().at("state").as_array().size(), 10);
|
||||
@@ -540,7 +542,7 @@ TEST_F(RPCLedgerDataHandlerTest, Binary)
|
||||
"limit":10,
|
||||
"binary": true
|
||||
})");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
EXPECT_TRUE(output->as_object().at("ledger").as_object().contains("ledger_data"));
|
||||
@@ -585,7 +587,7 @@ TEST_F(RPCLedgerDataHandlerTest, BinaryLimitMoreThanMax)
|
||||
"binary": true
|
||||
}})",
|
||||
LedgerDataHandler::LIMITBINARY + 1));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
EXPECT_TRUE(output->as_object().at("ledger").as_object().contains("ledger_data"));
|
||||
@@ -630,7 +632,7 @@ TEST_F(RPCLedgerDataHandlerTest, JsonLimitMoreThanMax)
|
||||
"binary": false
|
||||
}})",
|
||||
LedgerDataHandler::LIMITJSON + 1));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
EXPECT_TRUE(output->as_object().at("ledger").as_object().at("closed").as_bool());
|
||||
|
||||
@@ -552,7 +552,7 @@ TEST_P(LedgerEntryParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -592,7 +592,7 @@ TEST_P(IndexTest, InvalidIndexUint256)
|
||||
"{}": "invalid"
|
||||
}})",
|
||||
index));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -611,7 +611,7 @@ TEST_P(IndexTest, InvalidIndexNotString)
|
||||
"{}": 123
|
||||
}})",
|
||||
index));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -642,7 +642,7 @@ TEST_F(RPCLedgerEntryTest, LedgerEntryNotFound)
|
||||
"account_root": "{}"
|
||||
}})",
|
||||
ACCOUNT));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "entryNotFound");
|
||||
@@ -917,7 +917,7 @@ TEST_P(RPCLedgerEntryNormalPathTest, NormalPath)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerEntryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value().at("ledger_hash").as_string(), LEDGERHASH);
|
||||
EXPECT_EQ(output.value().at("ledger_index").as_uint64(), RANGEMAX);
|
||||
@@ -972,7 +972,7 @@ TEST_F(RPCLedgerEntryTest, BinaryFalse)
|
||||
"payment_channel": "{}"
|
||||
}})",
|
||||
INDEX1));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
@@ -1001,7 +1001,7 @@ TEST_F(RPCLedgerEntryTest, UnexpectedLedgerType)
|
||||
"check": "{}"
|
||||
}})",
|
||||
INDEX1));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "unexpectedLedgerType");
|
||||
@@ -1026,7 +1026,7 @@ TEST_F(RPCLedgerEntryTest, LedgerNotExistViaIntSequence)
|
||||
}})",
|
||||
INDEX1,
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -1052,7 +1052,7 @@ TEST_F(RPCLedgerEntryTest, LedgerNotExistViaStringSequence)
|
||||
}})",
|
||||
INDEX1,
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -1078,7 +1078,7 @@ TEST_F(RPCLedgerEntryTest, LedgerNotExistViaHash)
|
||||
}})",
|
||||
INDEX1,
|
||||
LEDGERHASH));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
|
||||
@@ -40,7 +40,7 @@ TEST_F(RPCLedgerRangeTest, LedgerRangeMinMaxSame)
|
||||
mockBackendPtr->updateRange(RANGEMIN);
|
||||
auto const handler = AnyHandler{LedgerRangeHandler{mockBackendPtr}};
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
auto const json = output.value();
|
||||
EXPECT_EQ(json.at("ledger_index_min").as_uint64(), RANGEMIN);
|
||||
@@ -55,7 +55,7 @@ TEST_F(RPCLedgerRangeTest, LedgerRangeFullySet)
|
||||
mockBackendPtr->updateRange(RANGEMAX);
|
||||
auto const handler = AnyHandler{LedgerRangeHandler{mockBackendPtr}};
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
auto const json = output.value();
|
||||
EXPECT_EQ(json.at("ledger_index_min").as_uint64(), RANGEMIN);
|
||||
|
||||
@@ -168,7 +168,7 @@ TEST_P(LedgerParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -192,7 +192,7 @@ TEST_F(RPCLedgerHandlerTest, LedgerNotExistViaIntSequence)
|
||||
"ledger_index": {}
|
||||
}})",
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -216,7 +216,7 @@ TEST_F(RPCLedgerHandlerTest, LedgerNotExistViaStringSequence)
|
||||
"ledger_index": "{}"
|
||||
}})",
|
||||
RANGEMAX));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -240,7 +240,7 @@ TEST_F(RPCLedgerHandlerTest, LedgerNotExistViaHash)
|
||||
"ledger_hash": "{}"
|
||||
}})",
|
||||
LEDGERHASH));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -282,7 +282,7 @@ TEST_F(RPCLedgerHandlerTest, Default)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{mockBackendPtr}};
|
||||
auto const req = json::parse("{}");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
// remove human readable time, it is sightly different cross the platform
|
||||
EXPECT_EQ(output->as_object().at("ledger").as_object().erase("close_time_human"), 1);
|
||||
@@ -309,7 +309,7 @@ TEST_F(RPCLedgerHandlerTest, NotSupportedFieldsDefaultValue)
|
||||
"accounts": false,
|
||||
"queue": false
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
});
|
||||
}
|
||||
@@ -327,7 +327,7 @@ TEST_F(RPCLedgerHandlerTest, QueryViaLedgerIndex)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(R"({"ledger_index": 15})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
});
|
||||
@@ -346,7 +346,7 @@ TEST_F(RPCLedgerHandlerTest, QueryViaLedgerHash)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{LedgerHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(fmt::format(R"({{"ledger_hash": "{}" }})", INDEX1));
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains("ledger"));
|
||||
});
|
||||
@@ -378,7 +378,7 @@ TEST_F(RPCLedgerHandlerTest, BinaryTrue)
|
||||
R"({
|
||||
"binary": true
|
||||
})");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -430,7 +430,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsExpandBinary)
|
||||
"expand": true,
|
||||
"transactions": true
|
||||
})");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -520,7 +520,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsExpandNotBinary)
|
||||
"expand": true,
|
||||
"transactions": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
// remove human readable time, it is sightly different cross the platform
|
||||
EXPECT_EQ(output->as_object().at("ledger").as_object().erase("close_time_human"), 1);
|
||||
@@ -548,7 +548,7 @@ TEST_F(RPCLedgerHandlerTest, TransactionsNotExpand)
|
||||
R"({
|
||||
"transactions": true
|
||||
})");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(
|
||||
output->as_object().at("ledger").at("transactions"),
|
||||
@@ -605,7 +605,7 @@ TEST_F(RPCLedgerHandlerTest, DiffNotBinary)
|
||||
R"({
|
||||
"diff": true
|
||||
})");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("ledger").at("diff"), json::parse(expectedOut));
|
||||
});
|
||||
@@ -650,7 +650,7 @@ TEST_F(RPCLedgerHandlerTest, DiffBinary)
|
||||
"diff": true,
|
||||
"binary": true
|
||||
})");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("ledger").at("diff"), json::parse(expectedOut));
|
||||
});
|
||||
@@ -741,7 +741,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsEmtpy)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
// remove human readable time, it is sightly different cross the platform
|
||||
EXPECT_EQ(output->as_object().at("ledger").as_object().erase("close_time_human"), 1);
|
||||
@@ -851,7 +851,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsTrueBinaryFalse)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
// remove human readable time, it is sightly different cross the platform
|
||||
EXPECT_EQ(output->as_object().at("ledger").as_object().erase("close_time_human"), 1);
|
||||
@@ -921,7 +921,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsTrueBinaryTrue)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -957,7 +957,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsIssuerIsSelf)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_FALSE(output->as_object()["ledger"].as_object()["transactions"].as_array()[0].as_object().contains(
|
||||
"owner_funds"));
|
||||
@@ -1026,7 +1026,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsNotEnoughForReserve)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOut));
|
||||
});
|
||||
@@ -1074,7 +1074,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsNotXRP)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(
|
||||
output->as_object()["ledger"]
|
||||
@@ -1138,7 +1138,7 @@ TEST_F(RPCLedgerHandlerTest, OwnerFundsIgnoreFreezeLine)
|
||||
"transactions": true,
|
||||
"owner_funds": true
|
||||
})");
|
||||
auto output = handler.process(req, Context{std::ref(yield)});
|
||||
auto output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(
|
||||
output->as_object()["ledger"]
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonHexLedgerHash)
|
||||
"ledger_hash": "xxx"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -57,6 +57,60 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonHexLedgerHash)
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTBuyOffersHandlerTest, LimitNotInt)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id": "{}",
|
||||
"limit": "xxx"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTBuyOffersHandlerTest, LimitNegative)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id": "{}",
|
||||
"limit": -1
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTBuyOffersHandlerTest, LimitZero)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id": "{}",
|
||||
"limit": 0
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTBuyOffersHandlerTest, NonStringLedgerHash)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
@@ -67,7 +121,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonStringLedgerHash)
|
||||
"ledger_hash": 123
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -86,7 +140,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, InvalidLedgerIndexString)
|
||||
"ledger_index": "notvalidated"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -103,7 +157,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NFTIDInvalidFormat)
|
||||
auto const input = json::parse(R"({
|
||||
"nft_id": "00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE7"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -119,7 +173,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NFTIDNotString)
|
||||
auto const input = json::parse(R"({
|
||||
"nft_id": 12
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -146,7 +200,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -172,7 +226,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerIndex)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -200,7 +254,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -225,7 +279,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -253,7 +307,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, NoNFT)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTBuyOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "objectNotFound");
|
||||
@@ -271,7 +325,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, MarkerNotString)
|
||||
"marker": 9
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -292,7 +346,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, InvalidMarker)
|
||||
"marker": "123invalid"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -307,7 +361,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, InvalidMarker)
|
||||
"marker": 250
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -366,7 +420,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, DefaultParameters)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTBuyOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
@@ -410,7 +464,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, MultipleResultsWithMarkerAndLimitOutput)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTBuyOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||
@@ -471,7 +525,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, ResultsForInputWithMarkerAndLimit)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTBuyOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||
@@ -534,7 +588,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, ResultsWithoutMarkerForInputWithMarkerAndLimi
|
||||
"limit": 50
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||
@@ -551,7 +605,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, ResultsWithoutMarkerForInputWithMarkerAndLimi
|
||||
"limit": 49
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit somehow?
|
||||
});
|
||||
|
||||
@@ -563,7 +617,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, ResultsWithoutMarkerForInputWithMarkerAndLimi
|
||||
"limit": 501
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit somehow?
|
||||
});
|
||||
}
|
||||
@@ -603,7 +657,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, LimitLessThanMin)
|
||||
NFTBuyOffersHandler::LIMIT_MIN - 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTBuyOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), NFTBuyOffersHandler::LIMIT_MIN);
|
||||
@@ -646,7 +700,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, LimitMoreThanMax)
|
||||
NFTBuyOffersHandler::LIMIT_MAX + 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTBuyOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), NFTBuyOffersHandler::LIMIT_MAX);
|
||||
|
||||
@@ -108,6 +108,16 @@ generateTestValuesForParametersTest()
|
||||
R"({"nft_id":"00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004", "limit": "123"})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
NFTHistoryParamTestCaseBundle{
|
||||
"limitNagetive",
|
||||
R"({"nft_id":"00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004", "limit": -1})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
NFTHistoryParamTestCaseBundle{
|
||||
"limitZero",
|
||||
R"({"nft_id":"00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004", "limit": 0})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
NFTHistoryParamTestCaseBundle{
|
||||
"MarkerNotObject",
|
||||
R"({"nft_id":"00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004", "marker": 101})",
|
||||
@@ -205,7 +215,7 @@ TEST_P(NFTHistoryParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NFTHistoryHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -268,7 +278,7 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardTrue)
|
||||
NFTID,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
@@ -309,7 +319,7 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexSpecificForwardFalse)
|
||||
NFTID,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
@@ -346,7 +356,7 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexNotSpecificForwardTrue)
|
||||
NFTID,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -387,7 +397,7 @@ TEST_F(RPCNFTHistoryHandlerTest, IndexNotSpecificForwardFalse)
|
||||
NFTID,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -428,7 +438,7 @@ TEST_F(RPCNFTHistoryHandlerTest, BinaryTrue)
|
||||
NFTID,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -479,7 +489,7 @@ TEST_F(RPCNFTHistoryHandlerTest, LimitAndMarker)
|
||||
NFTID,
|
||||
-1,
|
||||
-1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ);
|
||||
@@ -522,7 +532,7 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificLedgerIndex)
|
||||
}})",
|
||||
NFTID,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MAXSEQ - 1);
|
||||
@@ -551,7 +561,7 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificNonexistLedgerIntIndex)
|
||||
}})",
|
||||
NFTID,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -577,7 +587,7 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificNonexistLedgerStringIndex)
|
||||
}})",
|
||||
NFTID,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -617,7 +627,7 @@ TEST_F(RPCNFTHistoryHandlerTest, SpecificLedgerHash)
|
||||
}})",
|
||||
NFTID,
|
||||
LEDGERHASH));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MAXSEQ - 1);
|
||||
@@ -658,7 +668,7 @@ TEST_F(RPCNFTHistoryHandlerTest, TxLessThanMinSeq)
|
||||
NFTID,
|
||||
MINSEQ + 2,
|
||||
MAXSEQ - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 2);
|
||||
@@ -699,7 +709,7 @@ TEST_F(RPCNFTHistoryHandlerTest, TxLargerThanMaxSeq)
|
||||
NFTID,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 2));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
@@ -710,49 +720,6 @@ TEST_F(RPCNFTHistoryHandlerTest, TxLargerThanMaxSeq)
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTHistoryHandlerTest, LimitLessThanMin)
|
||||
{
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
mockBackendPtr->updateRange(MAXSEQ); // max
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
auto const transactions = genTransactions(MINSEQ + 1, MAXSEQ - 1);
|
||||
auto const transCursor = TransactionsAndCursor{transactions, TransactionsCursor{12, 34}};
|
||||
ON_CALL(*rawBackendPtr, fetchNFTTransactions).WillByDefault(Return(transCursor));
|
||||
EXPECT_CALL(
|
||||
*rawBackendPtr,
|
||||
fetchNFTTransactions(
|
||||
testing::_,
|
||||
testing::_,
|
||||
false,
|
||||
testing::Optional(testing::Eq(TransactionsCursor{MAXSEQ - 1, INT32_MAX})),
|
||||
testing::_))
|
||||
.Times(1);
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NFTHistoryHandler{mockBackendPtr}};
|
||||
auto const static input = boost::json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id":"{}",
|
||||
"ledger_index_min": {},
|
||||
"ledger_index_max": {},
|
||||
"forward": false,
|
||||
"limit": {}
|
||||
}})",
|
||||
NFTID,
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 1,
|
||||
NFTHistoryHandler::LIMIT_MIN - 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
EXPECT_EQ(output->at("ledger_index_max").as_uint64(), MAXSEQ - 1);
|
||||
EXPECT_EQ(output->at("marker").as_object(), json::parse(R"({"ledger":12,"seq":34})"));
|
||||
EXPECT_EQ(output->at("transactions").as_array().size(), 2);
|
||||
EXPECT_EQ(output->as_object().at("limit").as_uint64(), NFTHistoryHandler::LIMIT_MIN);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTHistoryHandlerTest, LimitMoreThanMax)
|
||||
{
|
||||
mockBackendPtr->updateRange(MINSEQ); // min
|
||||
@@ -785,7 +752,7 @@ TEST_F(RPCNFTHistoryHandlerTest, LimitMoreThanMax)
|
||||
MINSEQ + 1,
|
||||
MAXSEQ - 1,
|
||||
NFTHistoryHandler::LIMIT_MAX + 1));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("nft_id").as_string(), NFTID);
|
||||
EXPECT_EQ(output->at("ledger_index_min").as_uint64(), MINSEQ + 1);
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonHexLedgerHash)
|
||||
"ledger_hash": "xxx"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -66,7 +66,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonStringLedgerHash)
|
||||
"ledger_hash": 123
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -85,7 +85,7 @@ TEST_F(RPCNFTInfoHandlerTest, InvalidLedgerIndexString)
|
||||
"ledger_index": "notvalidated"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -102,7 +102,7 @@ TEST_F(RPCNFTInfoHandlerTest, NFTIDInvalidFormat)
|
||||
auto const input = json::parse(R"({
|
||||
"nft_id": "00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE7"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -118,7 +118,7 @@ TEST_F(RPCNFTInfoHandlerTest, NFTIDNotString)
|
||||
auto const input = json::parse(R"({
|
||||
"nft_id": 12
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -145,7 +145,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTInfoHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -171,7 +171,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistLedgerViaLedgerStringIndex)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTInfoHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -195,7 +195,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistLedgerViaLedgerIntIndex)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTInfoHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -223,7 +223,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTInfoHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -248,7 +248,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTInfoHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -277,7 +277,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistNFT)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTInfoHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "objectNotFound");
|
||||
@@ -320,7 +320,7 @@ TEST_F(RPCNFTInfoHandlerTest, DefaultParameters)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
@@ -362,7 +362,7 @@ TEST_F(RPCNFTInfoHandlerTest, BurnedNFT)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
@@ -403,7 +403,7 @@ TEST_F(RPCNFTInfoHandlerTest, NotBurnedNFTWithoutURI)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
@@ -444,7 +444,7 @@ TEST_F(RPCNFTInfoHandlerTest, NFTWithExtraFieldsSet)
|
||||
NFTID2));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
|
||||
@@ -38,6 +38,60 @@ class RPCNFTSellOffersHandlerTest : public HandlerBaseTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(RPCNFTSellOffersHandlerTest, LimitNotInt)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id": "{}",
|
||||
"limit": "xxx"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTSellOffersHandlerTest, LimitNegative)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id": "{}",
|
||||
"limit": -1
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTSellOffersHandlerTest, LimitZero)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"nft_id": "{}",
|
||||
"limit": 0
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNFTSellOffersHandlerTest, NonHexLedgerHash)
|
||||
{
|
||||
runSpawn([this](boost::asio::yield_context yield) {
|
||||
@@ -48,7 +102,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonHexLedgerHash)
|
||||
"ledger_hash": "xxx"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -67,7 +121,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonStringLedgerHash)
|
||||
"ledger_hash": 123
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -86,7 +140,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, InvalidLedgerIndexString)
|
||||
"ledger_index": "notvalidated"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -103,7 +157,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NFTIDInvalidFormat)
|
||||
auto const input = json::parse(R"({
|
||||
"nft_id": "00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE7"
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -119,7 +173,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NFTIDNotString)
|
||||
auto const input = json::parse(R"({
|
||||
"nft_id": 12
|
||||
})");
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -146,7 +200,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -172,7 +226,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonExistLedgerViaLedgerIndex)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -200,7 +254,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonExistLedgerViaLedgerHash2)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -225,7 +279,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonExistLedgerViaLedgerIndex2)
|
||||
NFTID));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -253,7 +307,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NoNFT)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](boost::asio::yield_context yield) {
|
||||
auto const handler = AnyHandler{NFTSellOffersHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "objectNotFound");
|
||||
@@ -271,7 +325,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, MarkerNotString)
|
||||
"marker": 9
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -292,7 +346,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, InvalidMarker)
|
||||
"marker": "123invalid"
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -307,7 +361,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, InvalidMarker)
|
||||
"marker": 250
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -366,7 +420,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, DefaultParameters)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correctOutput), *output);
|
||||
@@ -410,7 +464,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, MultipleResultsWithMarkerAndLimitOutput)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||
@@ -471,7 +525,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, ResultsForInputWithMarkerAndLimit)
|
||||
NFTID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||
@@ -534,7 +588,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, ResultsWithoutMarkerForInputWithMarkerAndLim
|
||||
"limit": 50
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||
@@ -551,7 +605,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, ResultsWithoutMarkerForInputWithMarkerAndLim
|
||||
"limit": 49
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit?
|
||||
});
|
||||
|
||||
@@ -563,7 +617,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, ResultsWithoutMarkerForInputWithMarkerAndLim
|
||||
"limit": 501
|
||||
}})",
|
||||
NFTID));
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output); // todo: check limit?
|
||||
});
|
||||
}
|
||||
@@ -603,7 +657,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, LimitLessThanMin)
|
||||
NFTSellOffersHandler::LIMIT_MIN - 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), NFTSellOffersHandler::LIMIT_MIN);
|
||||
@@ -646,7 +700,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, LimitMoreThanMax)
|
||||
NFTSellOffersHandler::LIMIT_MAX + 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("offers").as_array().size(), NFTSellOffersHandler::LIMIT_MAX);
|
||||
|
||||
@@ -114,6 +114,24 @@ generateTestValuesForParametersTest()
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
NoRippleParamTestCaseBundle{
|
||||
"LimitNegative",
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"role": "gateway",
|
||||
"limit": -1
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
NoRippleParamTestCaseBundle{
|
||||
"LimitZero",
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"role": "gateway",
|
||||
"limit": 0
|
||||
})",
|
||||
"invalidParams",
|
||||
"Invalid parameters."},
|
||||
NoRippleParamTestCaseBundle{
|
||||
"TransactionsNotBool",
|
||||
R"({
|
||||
@@ -138,7 +156,7 @@ TEST_P(NoRippleCheckParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -166,7 +184,7 @@ TEST_F(RPCNoRippleCheckTest, LedgerNotExistViaHash)
|
||||
LEDGERHASH));
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -194,7 +212,7 @@ TEST_F(RPCNoRippleCheckTest, LedgerNotExistViaIntIndex)
|
||||
seq));
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -222,7 +240,7 @@ TEST_F(RPCNoRippleCheckTest, LedgerNotExistViaStringIndex)
|
||||
seq));
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
runSpawn([&](auto yield) {
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -251,7 +269,7 @@ TEST_F(RPCNoRippleCheckTest, AccountNotExist)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
|
||||
@@ -313,7 +331,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathRoleUserDefaultRippleSetTrustLineNoRipple
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -371,7 +389,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathRoleUserDefaultRippleUnsetTrustLineNoRipp
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -432,7 +450,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathRoleGatewayDefaultRippleSetTrustLineNoRip
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -490,7 +508,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathRoleGatewayDefaultRippleUnsetTrustLineNoR
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
@@ -541,7 +559,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathRoleGatewayDefaultRippleUnsetTrustLineNoR
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("transactions").as_array().size(), 1);
|
||||
EXPECT_EQ(output->as_object().at("problems").as_array().size(), 1);
|
||||
@@ -593,7 +611,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathLimit)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("problems").as_array().size(), 1);
|
||||
});
|
||||
@@ -695,64 +713,12 @@ TEST_F(RPCNoRippleCheckTest, NormalPathTransactions)
|
||||
LEDGERHASH));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(expectedOutput));
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNoRippleCheckTest, LimitLessThanMin)
|
||||
{
|
||||
constexpr auto seq = 30;
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
mockBackendPtr->updateRange(10); // min
|
||||
mockBackendPtr->updateRange(30); // max
|
||||
auto ledgerinfo = CreateLedgerInfo(LEDGERHASH, seq);
|
||||
ON_CALL(*rawBackendPtr, fetchLedgerByHash(ripple::uint256{LEDGERHASH}, _)).WillByDefault(Return(ledgerinfo));
|
||||
EXPECT_CALL(*rawBackendPtr, fetchLedgerByHash).Times(1);
|
||||
// fetch account object return valid account with DefaultRippleSet flag
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject)
|
||||
.WillByDefault(Return(CreateAccountRootObject(ACCOUNT, ripple::lsfDefaultRipple, 2, 200, 2, INDEX1, 2)
|
||||
.getSerializer()
|
||||
.peekData()));
|
||||
auto const ownerDir = CreateOwnerDirLedgerObject({ripple::uint256{INDEX1}, ripple::uint256{INDEX2}}, INDEX1);
|
||||
auto const ownerDirKk = ripple::keylet::ownerDir(GetAccountIDWithString(ACCOUNT)).key;
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObject(ownerDirKk, seq, _))
|
||||
.WillByDefault(Return(ownerDir.getSerializer().peekData()));
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObject).Times(2);
|
||||
|
||||
auto const line1 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, ripple::lsfLowNoRipple);
|
||||
|
||||
auto const line2 = CreateRippleStateLedgerObject(
|
||||
ACCOUNT, "USD", ISSUER, 100, ACCOUNT, 10, ACCOUNT2, 20, TXNID, 123, ripple::lsfLowNoRipple);
|
||||
|
||||
std::vector<Blob> bbs;
|
||||
bbs.push_back(line1.getSerializer().peekData());
|
||||
bbs.push_back(line2.getSerializer().peekData());
|
||||
|
||||
ON_CALL(*rawBackendPtr, doFetchLedgerObjects).WillByDefault(Return(bbs));
|
||||
EXPECT_CALL(*rawBackendPtr, doFetchLedgerObjects).Times(1);
|
||||
|
||||
auto const input = json::parse(fmt::format(
|
||||
R"({{
|
||||
"account": "{}",
|
||||
"ledger_hash": "{}",
|
||||
"role": "gateway",
|
||||
"limit": {}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
LEDGERHASH,
|
||||
NoRippleCheckHandler::LIMIT_MIN - 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("problems").as_array().size(), NoRippleCheckHandler::LIMIT_MIN);
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(RPCNoRippleCheckTest, LimitMoreThanMax)
|
||||
{
|
||||
constexpr auto seq = 30;
|
||||
@@ -799,7 +765,7 @@ TEST_F(RPCNoRippleCheckTest, LimitMoreThanMax)
|
||||
NoRippleCheckHandler::LIMIT_MAX + 1));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("problems").as_array().size(), NoRippleCheckHandler::LIMIT_MAX);
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ TEST_F(RPCPingHandlerTest, Default)
|
||||
{
|
||||
runSpawn([](auto yield) {
|
||||
auto const handler = AnyHandler{PingHandler{}};
|
||||
auto const output = handler.process(boost::json::parse(R"({})"), Context{std::ref(yield)});
|
||||
auto const output = handler.process(boost::json::parse(R"({})"), Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output.value(), boost::json::parse(R"({})"));
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ TEST_F(RPCRandomHandlerTest, Default)
|
||||
{
|
||||
runSpawn([](auto yield) {
|
||||
auto const handler = AnyHandler{RandomHandler{}};
|
||||
auto const output = handler.process(boost::json::parse(R"({})"), Context{std::ref(yield)});
|
||||
auto const output = handler.process(boost::json::parse(R"({})"), Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().contains(JS(random)));
|
||||
EXPECT_EQ(output->as_object().at(JS(random)).as_string().size(), 64u);
|
||||
|
||||
@@ -150,7 +150,7 @@ TEST_F(RPCServerInfoHandlerTest, NoLedgerInfoErrorsOutWithInternal)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -177,7 +177,7 @@ TEST_F(RPCServerInfoHandlerTest, NoFeesErrorsOutWithInternal)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -218,7 +218,7 @@ TEST_F(RPCServerInfoHandlerTest, DefaultOutputIsPresent)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield), {}, false, CLIENTIP});
|
||||
auto const output = handler.process(req, Context{yield, {}, false, CLIENTIP});
|
||||
|
||||
validateNormalOutput(output);
|
||||
|
||||
@@ -262,7 +262,7 @@ TEST_F(RPCServerInfoHandlerTest, AmendmentBlockedIsPresentIfSet)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield), {}, false, CLIENTIP});
|
||||
auto const output = handler.process(req, Context{yield, {}, false, CLIENTIP});
|
||||
|
||||
validateNormalOutput(output);
|
||||
|
||||
@@ -317,7 +317,7 @@ TEST_F(RPCServerInfoHandlerTest, AdminSectionPresentWhenAdminFlagIsSet)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield), {}, true});
|
||||
auto const output = handler.process(req, Context{yield, {}, true});
|
||||
|
||||
validateNormalOutput(output);
|
||||
validateAdminOutput(output);
|
||||
@@ -379,7 +379,7 @@ TEST_F(RPCServerInfoHandlerTest, RippledForwardedValuesPresent)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield), {}, true});
|
||||
auto const output = handler.process(req, Context{yield, {}, true});
|
||||
|
||||
validateNormalOutput(output);
|
||||
validateAdminOutput(output);
|
||||
@@ -437,7 +437,7 @@ TEST_F(RPCServerInfoHandlerTest, RippledForwardedValuesMissingNoExceptionThrown)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const req = json::parse("{}");
|
||||
auto const output = handler.process(req, Context{std::ref(yield), {}, true});
|
||||
auto const output = handler.process(req, Context{yield, {}, true});
|
||||
|
||||
validateNormalOutput(output);
|
||||
validateAdminOutput(output);
|
||||
|
||||
@@ -540,7 +540,7 @@ TEST_P(SubscribeParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -552,7 +552,7 @@ TEST_F(RPCSubscribeHandlerTest, EmptyResponse)
|
||||
{
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
@@ -567,7 +567,7 @@ TEST_F(RPCSubscribeHandlerTest, StreamsWithoutLedger)
|
||||
})");
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
std::this_thread::sleep_for(20ms);
|
||||
@@ -612,7 +612,7 @@ TEST_F(RPCSubscribeHandlerTest, StreamsLedger)
|
||||
})");
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object(), json::parse(expectedOutput));
|
||||
std::this_thread::sleep_for(20ms);
|
||||
@@ -632,7 +632,7 @@ TEST_F(RPCSubscribeHandlerTest, Accounts)
|
||||
ACCOUNT2));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
std::this_thread::sleep_for(20ms);
|
||||
@@ -653,7 +653,7 @@ TEST_F(RPCSubscribeHandlerTest, AccountsProposed)
|
||||
ACCOUNT2));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
std::this_thread::sleep_for(20ms);
|
||||
@@ -685,7 +685,7 @@ TEST_F(RPCSubscribeHandlerTest, JustBooks)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
std::this_thread::sleep_for(20ms);
|
||||
@@ -717,7 +717,7 @@ TEST_F(RPCSubscribeHandlerTest, BooksBothSet)
|
||||
ACCOUNT));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
std::this_thread::sleep_for(20ms);
|
||||
@@ -880,7 +880,7 @@ TEST_F(RPCSubscribeHandlerTest, BooksBothSnapshotSet)
|
||||
ACCOUNT);
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("bids").as_array().size(), 10);
|
||||
EXPECT_EQ(output->as_object().at("asks").as_array().size(), 10);
|
||||
@@ -1020,7 +1020,7 @@ TEST_F(RPCSubscribeHandlerTest, BooksBothUnsetSnapshotSet)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->as_object().at("offers").as_array().size(), 10);
|
||||
EXPECT_EQ(output->as_object().at("offers").as_array()[0].as_object(), json::parse(expectedOffer));
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST_F(RPCTestHandlerTest, HandlerSuccess)
|
||||
"limit": 10
|
||||
})");
|
||||
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
auto const val = output.value();
|
||||
@@ -57,7 +57,7 @@ TEST_F(RPCTestHandlerTest, NoInputHandlerSuccess)
|
||||
{
|
||||
runSpawn([](auto yield) {
|
||||
auto const handler = AnyHandler{NoInputHandlerFake{}};
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
auto const val = output.value();
|
||||
@@ -74,7 +74,7 @@ TEST_F(RPCTestHandlerTest, HandlerErrorHandling)
|
||||
"limit": 10
|
||||
})");
|
||||
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -94,7 +94,7 @@ TEST_F(RPCTestHandlerTest, HandlerInnerErrorHandling)
|
||||
})");
|
||||
|
||||
// validation succeeds but handler itself returns error
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
|
||||
@@ -42,7 +42,7 @@ TEST_F(RPCTransactionEntryHandlerTest, TxHashNotProvide)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{TransactionEntryHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(json::parse("{}"), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse("{}"), Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "fieldNotFoundTransaction");
|
||||
@@ -54,7 +54,7 @@ TEST_F(RPCTransactionEntryHandlerTest, TxHashWrongFormat)
|
||||
{
|
||||
runSpawn([this](auto yield) {
|
||||
auto const handler = AnyHandler{TransactionEntryHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(json::parse(R"({"tx_hash":"123"})"), Context{std::ref(yield)});
|
||||
auto const output = handler.process(json::parse(R"({"tx_hash":"123"})"), Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
|
||||
@@ -79,7 +79,7 @@ TEST_F(RPCTransactionEntryHandlerTest, NonExistLedgerViaLedgerHash)
|
||||
TXNID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TransactionEntryHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -104,7 +104,7 @@ TEST_F(RPCTransactionEntryHandlerTest, NonExistLedgerViaLedgerIndex)
|
||||
TXNID));
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TransactionEntryHandler{mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
auto const output = handler.process(input, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
|
||||
@@ -129,7 +129,7 @@ TEST_F(RPCTransactionEntryHandlerTest, TXNotFound)
|
||||
"tx_hash": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "transactionNotFound");
|
||||
@@ -162,7 +162,7 @@ TEST_F(RPCTransactionEntryHandlerTest, LedgerSeqNotMatch)
|
||||
"ledger_index": "30"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), "transactionNotFound");
|
||||
@@ -240,7 +240,7 @@ TEST_F(RPCTransactionEntryHandlerTest, NormalPath)
|
||||
}})",
|
||||
TXNID,
|
||||
tx.ledgerSequence));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(OUTPUT), *output);
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ TEST_F(RPCTxTest, ExcessiveLgrRange)
|
||||
"max_ledger":1002
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -72,7 +72,7 @@ TEST_F(RPCTxTest, InvalidLgrRange)
|
||||
"min_ledger": 10
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -95,7 +95,7 @@ TEST_F(RPCTxTest, TxnNotFound)
|
||||
"transaction": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -122,7 +122,7 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllFalse)
|
||||
"max_ledger":1000
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -150,7 +150,7 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllTrue)
|
||||
"max_ledger":1000
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
|
||||
auto const err = RPC::makeError(output.error());
|
||||
@@ -215,7 +215,7 @@ TEST_F(RPCTxTest, DefaultParameter)
|
||||
"transaction": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
@@ -249,7 +249,7 @@ TEST_F(RPCTxTest, ReturnBinary)
|
||||
"binary": true
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
@@ -327,7 +327,7 @@ TEST_F(RPCTxTest, MintNFT)
|
||||
"transaction": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(*output, json::parse(OUT));
|
||||
});
|
||||
@@ -349,7 +349,7 @@ TEST_F(RPCTxTest, NFTAcceptOffer)
|
||||
"transaction": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(output->at("meta").at("nftoken_id").as_string(), NFTID);
|
||||
});
|
||||
@@ -372,7 +372,7 @@ TEST_F(RPCTxTest, NFTCancelOffer)
|
||||
"transaction": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
for (auto const& id : output->at("meta").at("nftoken_ids").as_array())
|
||||
@@ -401,7 +401,7 @@ TEST_F(RPCTxTest, NFTCreateOffer)
|
||||
"transaction": "{}"
|
||||
}})",
|
||||
TXNID));
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->at("meta").at("offer_id").as_string() == NFTID2);
|
||||
});
|
||||
|
||||
@@ -495,7 +495,7 @@ TEST_P(UnsubscribeParameterTest, InvalidParams)
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const req = json::parse(testBundle.testJson);
|
||||
auto const output = handler.process(req, Context{std::ref(yield)});
|
||||
auto const output = handler.process(req, Context{yield});
|
||||
ASSERT_FALSE(output);
|
||||
auto const err = RPC::makeError(output.error());
|
||||
EXPECT_EQ(err.at("error").as_string(), testBundle.expectedError);
|
||||
@@ -507,7 +507,7 @@ TEST_F(RPCUnsubscribeTest, EmptyResponse)
|
||||
{
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(json::parse(R"({})"), Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
@@ -531,7 +531,7 @@ TEST_F(RPCUnsubscribeTest, Streams)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
@@ -553,7 +553,7 @@ TEST_F(RPCUnsubscribeTest, Accounts)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
@@ -577,7 +577,7 @@ TEST_F(RPCUnsubscribeTest, AccountsProposed)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
@@ -612,7 +612,7 @@ TEST_F(RPCUnsubscribeTest, Books)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
@@ -645,7 +645,7 @@ TEST_F(RPCUnsubscribeTest, SingleBooks)
|
||||
|
||||
runSpawn([&, this](auto yield) {
|
||||
auto const handler = AnyHandler{TestUnsubscribeHandler{mockBackendPtr, mockSubscriptionManagerPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield), session_});
|
||||
auto const output = handler.process(input, Context{yield, session_});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_TRUE(output->as_object().empty());
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST_F(RPCVersionHandlerTest, Default)
|
||||
|
||||
runSpawn([&](auto yield) {
|
||||
auto const handler = AnyHandler{VersionHandler{cfg}};
|
||||
auto const output = handler.process(static_cast<json::value>(cfg), Context{std::ref(yield)});
|
||||
auto const output = handler.process(static_cast<json::value>(cfg), Context{yield});
|
||||
ASSERT_TRUE(output);
|
||||
|
||||
// check all against all the correct values
|
||||
|
||||
Reference in New Issue
Block a user