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

@@ -52,7 +52,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonHexLedgerHash)
"ledger_hash": "xxx"
}})",
NFTID));
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());
@@ -71,7 +71,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NonStringLedgerHash)
"ledger_hash": 123
}})",
NFTID));
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());
@@ -90,7 +90,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, InvalidLedgerIndexString)
"ledger_index": "notvalidated"
}})",
NFTID));
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());
@@ -107,7 +107,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NFTIDInvalidFormat)
auto const input = json::parse(R"({
"nft_id": "00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE7"
})");
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(), "invalidParams");
@@ -123,7 +123,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, NFTIDNotString)
auto const input = json::parse(R"({
"nft_id": 12
})");
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());
@@ -151,7 +151,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, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
@@ -179,7 +179,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, 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");
@@ -209,7 +209,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, 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");
@@ -235,7 +235,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, 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");
@@ -266,7 +266,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, 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(), "objectNotFound");
@@ -284,7 +284,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, MarkerNotString)
"marker": 9
}})",
NFTID));
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());
@@ -305,7 +305,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, InvalidMarker)
"marker": "123invalid"
}})",
NFTID));
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());
@@ -320,7 +320,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, InvalidMarker)
"marker": 250
}})",
NFTID));
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());
@@ -339,7 +339,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, IncorrectLimit)
"limit": 49
}})",
NFTID));
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());
@@ -353,7 +353,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, IncorrectLimit)
"limit": 501
}})",
NFTID));
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());
@@ -420,7 +420,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, DefaultParameters)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(json::parse(correctOutput), *output);
@@ -467,7 +467,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, MultipleResultsWithMarkerAndLimitOutput)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output->at("offers").as_array().size(), 50);
@@ -537,7 +537,7 @@ TEST_F(RPCNFTSellOffersHandlerTest, ResultsForInputWithMarkerAndLimit)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output->at("offers").as_array().size(), 50);
@@ -611,7 +611,7 @@ TEST_F(
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTSellOffersHandler{this->mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output->at("offers").as_array().size(), 50);