Create ngContext (#579)

Fixes #582
This commit is contained in:
cyan317
2023-04-05 12:46:59 +01:00
committed by GitHub
parent 5d06a79f13
commit 654168efec
51 changed files with 294 additions and 288 deletions

View File

@@ -45,7 +45,8 @@ TEST_F(RPCTransactionEntryHandlerTest, TxHashNotProvide)
runSpawn([this](auto& yield) {
auto const handler =
AnyHandler{TransactionEntryHandler{mockBackendPtr}};
auto const output = handler.process(json::parse("{}"), yield);
auto const output =
handler.process(json::parse("{}"), Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
@@ -60,8 +61,8 @@ 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"})"), yield);
auto const output = handler.process(
json::parse(R"({"tx_hash":"123"})"), Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
@@ -88,7 +89,7 @@ TEST_F(RPCTransactionEntryHandlerTest, NonExistLedgerViaLedgerHash)
runSpawn([&, this](auto& yield) {
auto const handler =
AnyHandler{TransactionEntryHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -116,7 +117,7 @@ TEST_F(RPCTransactionEntryHandlerTest, NonExistLedgerViaLedgerIndex)
runSpawn([&, this](auto& yield) {
auto const handler =
AnyHandler{TransactionEntryHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -143,7 +144,7 @@ TEST_F(RPCTransactionEntryHandlerTest, TXNotFound)
"tx_hash": "{}"
}})",
TXNID));
auto const output = handler.process(req, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "transactionNotFound");
@@ -184,7 +185,7 @@ TEST_F(RPCTransactionEntryHandlerTest, LedgerSeqNotMatch)
"ledger_index": "30"
}})",
TXNID));
auto const output = handler.process(req, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "transactionNotFound");
@@ -269,7 +270,7 @@ TEST_F(RPCTransactionEntryHandlerTest, NormalPath)
}})",
TXNID,
tx.ledgerSequence));
auto const output = handler.process(req, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(json::parse(OUTPUT), *output);
});