Return error when limit<=0 (#804)

Fix #806
This commit is contained in:
cyan317
2023-08-02 15:34:42 +01:00
committed by GitHub
parent 1804e3e9c0
commit c90bc15959
45 changed files with 832 additions and 562 deletions

View File

@@ -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);
});