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

@@ -88,11 +88,9 @@ public:
* @return JSON result or @ref RPC::Status on error
*/
[[nodiscard]] ReturnType
process(
boost::json::value const& value,
boost::asio::yield_context& ptrYield) const
process(boost::json::value const& value, Context const& ctx) const
{
return pimpl_->process(value, &ptrYield);
return pimpl_->process(value, ctx);
}
private:
@@ -101,9 +99,10 @@ private:
virtual ~Concept() = default;
[[nodiscard]] virtual ReturnType
process(
boost::json::value const& value,
boost::asio::yield_context* ptrYield = nullptr) const = 0;
process(boost::json::value const& value, Context const& ctx) const = 0;
[[nodiscard]] virtual ReturnType
process(boost::json::value const& value) const = 0;
[[nodiscard]] virtual std::unique_ptr<Concept>
clone() const = 0;
@@ -120,11 +119,16 @@ private:
}
[[nodiscard]] ReturnType
process(
boost::json::value const& value,
boost::asio::yield_context* ptrYield = nullptr) const override
process(boost::json::value const& value) const override
{
return processor(handler, value, ptrYield);
return processor(handler, value);
}
[[nodiscard]] ReturnType
process(boost::json::value const& value, Context const& ctx)
const override
{
return processor(handler, value, &ctx);
}
[[nodiscard]] std::unique_ptr<Concept>

View File

@@ -21,7 +21,6 @@
#include <rpc/common/Types.h>
#include <boost/asio/spawn.hpp>
#include <boost/json/value_from.hpp>
#include <boost/json/value_to.hpp>
@@ -50,17 +49,17 @@ concept Requirement = requires(T a) {
*/
// clang-format off
template <typename T>
concept CoroutineProcess = requires(T a, typename T::Input in, typename T::Output out, boost::asio::yield_context& y) {
concept ContextProcess = requires(T a, typename T::Input in, typename T::Output out, Context const& y) {
{ a.process(in, y) } -> std::same_as<HandlerReturnType<decltype(out)>>; };
template <typename T>
concept NonCoroutineProcess = requires(T a, typename T::Input in, typename T::Output out) {
concept NonContextProcess = requires(T a, typename T::Input in, typename T::Output out) {
{ a.process(in) } -> std::same_as<HandlerReturnType<decltype(out)>>; };
template <typename T>
concept HandlerWithInput = requires(T a, typename T::Input in, typename T::Output out) {
{ a.spec() } -> std::same_as<RpcSpecConstRef>; }
and (CoroutineProcess<T> or NonCoroutineProcess<T>)
and (ContextProcess<T> or NonContextProcess<T>)
and boost::json::has_value_to<typename T::Input>::value;
template <typename T>

View File

@@ -22,8 +22,10 @@
#include <rpc/Errors.h>
#include <util/Expected.h>
#include <boost/asio/spawn.hpp>
#include <boost/json/value.hpp>
class WsBase;
namespace RPCng {
/**
@@ -57,6 +59,14 @@ struct VoidOutput
{
};
struct Context
{
// TODO: we shall change yield_context to const yield_context after we
// update backend interfaces to use const& yield
const std::reference_wrapper<boost::asio::yield_context> yield;
const std::shared_ptr<WsBase> session;
};
inline void
tag_invoke(
boost::json::value_from_tag,

View File

@@ -34,7 +34,7 @@ struct DefaultProcessor final
operator()(
HandlerType const& handler,
boost::json::value const& value,
boost::asio::yield_context* ptrYield = nullptr) const
Context const* ctx = nullptr) const
{
using boost::json::value_from;
using boost::json::value_to;
@@ -46,7 +46,7 @@ struct DefaultProcessor final
return Error{ret.error()}; // forward Status
auto const inData = value_to<typename HandlerType::Input>(value);
if constexpr (NonCoroutineProcess<HandlerType>)
if constexpr (NonContextProcess<HandlerType>)
{
auto const ret = handler.process(inData);
// real handler is given expected Input, not json
@@ -57,7 +57,7 @@ struct DefaultProcessor final
}
else
{
auto const ret = handler.process(inData, *ptrYield);
auto const ret = handler.process(inData, *ctx);
// real handler is given expected Input, not json
if (!ret)
return Error{ret.error()}; // forward Status

View File

@@ -57,12 +57,12 @@ AccountChannelsHandler::addChannel(
AccountChannelsHandler::Result
AccountChannelsHandler::process(
AccountChannelsHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -76,7 +76,7 @@ AccountChannelsHandler::process(
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(
ripple::keylet::account(*accountID).key, lgrInfo.seq, yield);
ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
if (!accountLedgerObject)
return Error{RPC::Status{
RPC::RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
@@ -103,7 +103,7 @@ AccountChannelsHandler::process(
lgrInfo.seq,
input.limit,
input.marker,
yield,
ctx.yield,
addToResponse);
response.account = input.account;

View File

@@ -100,7 +100,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
private:
void

View File

@@ -23,12 +23,12 @@ namespace RPCng {
AccountCurrenciesHandler::Result
AccountCurrenciesHandler::process(
AccountCurrenciesHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -41,7 +41,7 @@ AccountCurrenciesHandler::process(
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(
ripple::keylet::account(*accountID).key, lgrInfo.seq, yield);
ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
if (!accountLedgerObject)
return Error{RPC::Status{
RPC::RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
@@ -75,7 +75,7 @@ AccountCurrenciesHandler::process(
lgrInfo.seq,
std::numeric_limits<std::uint32_t>::max(),
{},
yield,
ctx.yield,
addToResponse);
response.ledgerHash = ripple::strHex(lgrInfo.hash);

View File

@@ -72,7 +72,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -21,9 +21,8 @@
namespace RPCng {
AccountInfoHandler::Result
AccountInfoHandler::process(
AccountInfoHandler::Input input,
boost::asio::yield_context& yield) const
AccountInfoHandler::process(AccountInfoHandler::Input input, Context const& ctx)
const
{
if (!input.account && !input.ident)
return Error{RPC::Status{RPC::RippledError::rpcACT_MALFORMED}};
@@ -31,7 +30,7 @@ AccountInfoHandler::process(
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -45,7 +44,7 @@ AccountInfoHandler::process(
auto const accountID = RPC::accountFromStringStrict(accountStr);
auto const accountKeylet = ripple::keylet::account(*accountID);
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(
accountKeylet.key, lgrInfo.seq, yield);
accountKeylet.key, lgrInfo.seq, ctx.yield);
if (!accountLedgerObject)
return Error{RPC::Status{
RPC::RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
@@ -65,7 +64,7 @@ AccountInfoHandler::process(
// This code will need to be revisited if in the future we
// support multiple SignerLists on one account.
auto const signers = sharedPtrBackend_->fetchLedgerObject(
signersKey.key, lgrInfo.seq, yield);
signersKey.key, lgrInfo.seq, ctx.yield);
std::vector<ripple::STLedgerEntry> signerList;
if (signers)
{

View File

@@ -96,7 +96,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -95,12 +95,12 @@ AccountLinesHandler::addLine(
AccountLinesHandler::Result
AccountLinesHandler::process(
AccountLinesHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -111,7 +111,7 @@ AccountLinesHandler::process(
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(
ripple::keylet::account(*accountID).key, lgrInfo.seq, yield);
ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
if (not accountLedgerObject)
return Error{RPC::Status{
@@ -156,7 +156,7 @@ AccountLinesHandler::process(
lgrInfo.seq,
input.limit,
input.marker,
yield,
ctx.yield,
addToResponse);
response.account = input.account;

View File

@@ -104,7 +104,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
private:
void

View File

@@ -44,12 +44,12 @@ AccountOffersHandler::addOffer(
AccountOffersHandler::Result
AccountOffersHandler::process(
AccountOffersHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -62,7 +62,7 @@ AccountOffersHandler::process(
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(
ripple::keylet::account(*accountID).key, lgrInfo.seq, yield);
ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
if (!accountLedgerObject)
return Error{RPC::Status{
RPC::RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
@@ -87,7 +87,7 @@ AccountOffersHandler::process(
lgrInfo.seq,
input.limit,
input.marker,
yield,
ctx.yield,
addToResponse);
if (auto const status = std::get_if<RPC::Status>(&next))

View File

@@ -86,7 +86,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
private:
void

View File

@@ -25,9 +25,8 @@ clio::Logger gLog{"RPC-AccountTxHandler"};
namespace RPCng {
AccountTxHandler::Result
AccountTxHandler::process(
AccountTxHandler::Input input,
boost::asio::yield_context& yield) const
AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx)
const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto [minIndex, maxIndex] = *range;
@@ -67,7 +66,7 @@ AccountTxHandler::process(
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -94,7 +93,7 @@ AccountTxHandler::process(
auto const limit = input.limit.value_or(limitDefault);
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const [blobs, retCursor] = sharedPtrBackend_->fetchAccountTransactions(
*accountID, limit, input.forward, cursor, yield);
*accountID, limit, input.forward, cursor, ctx.yield);
Output response;
if (retCursor)

View File

@@ -105,7 +105,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -23,7 +23,7 @@
namespace RPCng {
BookOffersHandler::Result
BookOffersHandler::process(Input input, boost::asio::yield_context& yield) const
BookOffersHandler::process(Input input, Context const& ctx) const
{
auto bookMaybe = RPC::parseBook(
input.paysCurrency, input.paysID, input.getsCurrency, input.getsID);
@@ -34,7 +34,7 @@ BookOffersHandler::process(Input input, boost::asio::yield_context& yield) const
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -48,7 +48,7 @@ BookOffersHandler::process(Input input, boost::asio::yield_context& yield) const
// TODO: Add perfomance metrics if needed in future
auto [offers, _] = sharedPtrBackend_->fetchBookOffers(
bookKey, lgrInfo.seq, input.limit, yield);
bookKey, lgrInfo.seq, input.limit, ctx.yield);
BookOffersHandler::Output output;
output.ledgerHash = ripple::strHex(lgrInfo.hash);
@@ -59,7 +59,7 @@ BookOffersHandler::process(Input input, boost::asio::yield_context& yield) const
input.taker ? *(input.taker) : beast::zero,
*sharedPtrBackend_,
lgrInfo.seq,
yield);
ctx.yield);
return output;
}

View File

@@ -102,7 +102,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -24,13 +24,13 @@ namespace RPCng {
GatewayBalancesHandler::Result
GatewayBalancesHandler::process(
GatewayBalancesHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
// check ledger
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -41,7 +41,7 @@ GatewayBalancesHandler::process(
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const accountLedgerObject = sharedPtrBackend_->fetchLedgerObject(
ripple::keylet::account(*accountID).key, lgrInfo.seq, yield);
ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
if (!accountLedgerObject)
return Error{RPC::Status{
RPC::RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
@@ -120,7 +120,7 @@ GatewayBalancesHandler::process(
lgrInfo.seq,
std::numeric_limits<std::uint32_t>::max(),
{},
yield,
ctx.yield,
addToResponse);
if (auto status = std::get_if<RPC::Status>(&ret))

View File

@@ -113,7 +113,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -23,9 +23,8 @@
namespace RPCng {
LedgerEntryHandler::Result
LedgerEntryHandler::process(
LedgerEntryHandler::Input input,
boost::asio::yield_context& yield) const
LedgerEntryHandler::process(LedgerEntryHandler::Input input, Context const& ctx)
const
{
ripple::uint256 key;
if (input.index)
@@ -106,7 +105,7 @@ LedgerEntryHandler::process(
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -116,7 +115,7 @@ LedgerEntryHandler::process(
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
auto const ledgerObject =
sharedPtrBackend_->fetchLedgerObject(key, lgrInfo.seq, yield);
sharedPtrBackend_->fetchLedgerObject(key, lgrInfo.seq, ctx.yield);
if (!ledgerObject || ledgerObject->size() == 0)
return Error{RPC::Status{"entryNotFound"}};

View File

@@ -189,7 +189,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
private:
// dir_root and owner can not be both empty or filled at the same time

View File

@@ -30,10 +30,10 @@ namespace RPCng {
NFTBuyOffersHandler::Result
NFTBuyOffersHandler::process(
NFTBuyOffersHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const tokenID = uint256{input.nftID.c_str()};
auto const directory = keylet::nft_buys(tokenID);
return iterateOfferDirectory(input, tokenID, directory, yield);
return iterateOfferDirectory(input, tokenID, directory, ctx.yield);
}
} // namespace RPCng

View File

@@ -35,6 +35,6 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
} // namespace RPCng

View File

@@ -29,15 +29,13 @@ using namespace ::RPC;
namespace RPCng {
NFTInfoHandler::Result
NFTInfoHandler::process(
NFTInfoHandler::Input input,
boost::asio::yield_context& yield) const
NFTInfoHandler::process(NFTInfoHandler::Input input, Context const& ctx) const
{
auto const tokenID = ripple::uint256{input.nftID.c_str()};
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -46,7 +44,7 @@ NFTInfoHandler::process(
auto const lgrInfo = std::get<LedgerInfo>(lgrInfoOrStatus);
auto const maybeNft =
sharedPtrBackend_->fetchNFT(tokenID, lgrInfo.seq, yield);
sharedPtrBackend_->fetchNFT(tokenID, lgrInfo.seq, ctx.yield);
if (not maybeNft.has_value())
return Error{
Status{RippledError::rpcOBJECT_NOT_FOUND, "NFT not found"}};

View File

@@ -81,7 +81,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -30,11 +30,11 @@ namespace RPCng {
NFTSellOffersHandler::Result
NFTSellOffersHandler::process(
NFTSellOffersHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const tokenID = uint256{input.nftID.c_str()};
auto const directory = keylet::nft_sells(tokenID);
return iterateOfferDirectory(input, tokenID, directory, yield);
return iterateOfferDirectory(input, tokenID, directory, ctx.yield);
}
} // namespace RPCng

View File

@@ -35,6 +35,6 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
} // namespace RPCng

View File

@@ -28,12 +28,12 @@ namespace RPCng {
NoRippleCheckHandler::Result
NoRippleCheckHandler::process(
NoRippleCheckHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -45,7 +45,7 @@ NoRippleCheckHandler::process(
auto const accountID = RPC::accountFromStringStrict(input.account);
auto const keylet = ripple::keylet::account(*accountID).key;
auto const accountObj =
sharedPtrBackend_->fetchLedgerObject(keylet, lgrInfo.seq, yield);
sharedPtrBackend_->fetchLedgerObject(keylet, lgrInfo.seq, ctx.yield);
if (!accountObj)
return Error{RPC::Status{
RPC::RippledError::rpcACT_NOT_FOUND, "accountNotFound"}};
@@ -58,7 +58,7 @@ NoRippleCheckHandler::process(
sle.getFieldU32(ripple::sfFlags) & ripple::lsfDefaultRipple;
auto const fees = input.transactions
? sharedPtrBackend_->fetchFees(lgrInfo.seq, yield)
? sharedPtrBackend_->fetchFees(lgrInfo.seq, ctx.yield)
: std::nullopt;
auto output = NoRippleCheckHandler::Output();
@@ -101,7 +101,7 @@ NoRippleCheckHandler::process(
lgrInfo.seq,
std::numeric_limits<std::uint32_t>::max(),
{},
yield,
ctx.yield,
[&](ripple::SLE&& ownedItem) {
// don't push to result if limit is reached
if (limit != 0 && ownedItem.getType() == ripple::ltRIPPLE_STATE)

View File

@@ -84,7 +84,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -24,12 +24,12 @@ namespace RPCng {
TransactionEntryHandler::Result
TransactionEntryHandler::process(
TransactionEntryHandler::Input input,
boost::asio::yield_context& yield) const
Context const& ctx) const
{
auto const range = sharedPtrBackend_->fetchLedgerRange();
auto const lgrInfoOrStatus = RPC::getLedgerInfoFromHashOrSeq(
*sharedPtrBackend_,
yield,
ctx.yield,
input.ledgerHash,
input.ledgerIndex,
range->maxSequence);
@@ -39,7 +39,7 @@ TransactionEntryHandler::process(
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
auto const dbRet = sharedPtrBackend_->fetchTransaction(
ripple::uint256{input.txHash.c_str()}, yield);
ripple::uint256{input.txHash.c_str()}, ctx.yield);
// Note: transaction_entry is meant to only search a specified ledger for
// the specified transaction. tx searches the entire range of history. For
// rippled, having two separate commands made sense, as tx would use SQLite

View File

@@ -71,7 +71,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -23,7 +23,7 @@
namespace RPCng {
TxHandler::Result
TxHandler::process(Input input, boost::asio::yield_context& yield) const
TxHandler::process(Input input, Context const& ctx) const
{
constexpr static auto maxLedgerRange = 1000u;
auto const rangeSupplied = input.minLedger && input.maxLedger;
@@ -39,7 +39,7 @@ TxHandler::process(Input input, boost::asio::yield_context& yield) const
}
TxHandler::Output output;
auto const dbResponse = sharedPtrBackend_->fetchTransaction(
ripple::uint256{std::string_view(input.transaction)}, yield);
ripple::uint256{std::string_view(input.transaction)}, ctx.yield);
if (!dbResponse)
{
if (rangeSupplied)

View File

@@ -75,7 +75,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const;
process(Input input, Context const& ctx) const;
};
void

View File

@@ -55,7 +55,7 @@ TEST_F(RPCAccountHandlerTest, NonHexLedgerHash)
"ledger_hash": "xxx"
}})",
ACCOUNT));
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());
@@ -75,7 +75,7 @@ TEST_F(RPCAccountHandlerTest, NonStringLedgerHash)
"ledger_hash": 123
}})",
ACCOUNT));
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());
@@ -95,7 +95,7 @@ TEST_F(RPCAccountHandlerTest, InvalidLedgerIndexString)
"ledger_index": "notvalidated"
}})",
ACCOUNT));
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());
@@ -114,7 +114,7 @@ TEST_F(RPCAccountHandlerTest, MarkerNotString)
"marker": 9
}})",
ACCOUNT));
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());
@@ -136,7 +136,7 @@ TEST_F(RPCAccountHandlerTest, InvalidMarker)
"marker": "123invalid"
}})",
ACCOUNT));
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(RPCAccountHandlerTest, InvalidMarker)
"marker": 401
}})",
ACCOUNT));
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());
@@ -170,7 +170,7 @@ TEST_F(RPCAccountHandlerTest, IncorrectLimit)
"limit": 9
}})",
ACCOUNT));
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());
@@ -184,7 +184,7 @@ TEST_F(RPCAccountHandlerTest, IncorrectLimit)
"limit": 401
}})",
ACCOUNT));
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());
@@ -200,7 +200,7 @@ TEST_F(RPCAccountHandlerTest, AccountInvalidFormat)
auto const input = json::parse(R"({
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
})");
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");
@@ -216,7 +216,7 @@ TEST_F(RPCAccountHandlerTest, AccountNotString)
auto const input = json::parse(R"({
"account": 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());
@@ -244,7 +244,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{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());
@@ -272,7 +272,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerStringIndex)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{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");
@@ -298,7 +298,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIntIndex)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{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");
@@ -328,7 +328,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerHash2)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{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");
@@ -354,7 +354,7 @@ TEST_F(RPCAccountHandlerTest, NonExistLedgerViaLedgerIndex2)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{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");
@@ -386,7 +386,7 @@ TEST_F(RPCAccountHandlerTest, NonExistAccount)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountChannelsHandler{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(), "actNotFound");
@@ -469,7 +469,7 @@ TEST_F(RPCAccountHandlerTest, DefaultParameterTest)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{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);
});
@@ -526,7 +526,7 @@ TEST_F(RPCAccountHandlerTest, UseLimit)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{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).as_object().at("channels").as_array().size(), 20);
@@ -600,7 +600,7 @@ TEST_F(RPCAccountHandlerTest, UseDestination)
ACCOUNT3));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{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).as_object().at("channels").as_array().size(), 20);
});
@@ -641,7 +641,7 @@ TEST_F(RPCAccountHandlerTest, EmptyChannel)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{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).as_object().at("channels").as_array().size(), 0);
});
@@ -733,7 +733,7 @@ TEST_F(RPCAccountHandlerTest, OptionalResponseField)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{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);
});
@@ -810,7 +810,7 @@ TEST_F(RPCAccountHandlerTest, MarkerOutput)
limit));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{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).as_object().at("marker").as_string().c_str(),
@@ -877,7 +877,7 @@ TEST_F(RPCAccountHandlerTest, MarkerInput)
nextPage));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountChannelsHandler{this->mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(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

View File

@@ -65,7 +65,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, AccountNotExsit)
ACCOUNT));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), "actNotFound");
@@ -90,7 +90,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaIntSequence)
ACCOUNT));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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");
@@ -118,7 +118,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaStringSequence)
seq));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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");
@@ -145,7 +145,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, LedgerNonExistViaHash)
LEDGERHASH));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -219,7 +219,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, DefaultParameter)
ACCOUNT));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(OUTPUT));
});
@@ -264,7 +264,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderHash)
LEDGERHASH));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
});
}
@@ -309,7 +309,7 @@ TEST_F(RPCAccountCurrenciesHandlerTest, RequestViaLegderSeq)
ledgerSeq));
auto const handler = AnyHandler{AccountCurrenciesHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(
(*output).as_object().at("ledger_index").as_uint64(), ledgerSeq);

View File

@@ -130,7 +130,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, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
@@ -159,7 +159,7 @@ TEST_F(RPCAccountInfoHandlerTest, LedgerNonExistViaIntSequence)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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");
@@ -185,7 +185,7 @@ TEST_F(RPCAccountInfoHandlerTest, LedgerNonExistViaStringSequence)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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");
@@ -212,7 +212,7 @@ TEST_F(RPCAccountInfoHandlerTest, LedgerNonExistViaHash)
LEDGERHASH));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -241,7 +241,7 @@ TEST_F(RPCAccountInfoHandlerTest, AccountNotExsit)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), "actNotFound");
@@ -271,7 +271,7 @@ TEST_F(RPCAccountInfoHandlerTest, AccountInvalid)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), "dbDeserialization");
@@ -310,7 +310,7 @@ TEST_F(RPCAccountInfoHandlerTest, SignerListsInvalid)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), "dbDeserialization");
@@ -403,7 +403,7 @@ TEST_F(RPCAccountInfoHandlerTest, SignerListsTrue)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});
@@ -434,7 +434,7 @@ TEST_F(RPCAccountInfoHandlerTest, IdentAndSignerListsFalse)
ACCOUNT));
auto const handler = AnyHandler{AccountInfoHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_FALSE(output->as_object().contains("signer_lists"));
});

View File

@@ -60,7 +60,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonHexLedgerHash)
"ledger_hash": "xxx"
}})",
ACCOUNT));
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());
@@ -80,7 +80,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonStringLedgerHash)
"ledger_hash": 123
}})",
ACCOUNT));
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());
@@ -100,7 +100,7 @@ TEST_F(RPCAccountLinesHandlerTest, InvalidLedgerIndexString)
"ledger_index": "notvalidated"
}})",
ACCOUNT));
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());
@@ -119,7 +119,7 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerNotString)
"marker": 9
}})",
ACCOUNT));
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());
@@ -141,7 +141,7 @@ TEST_F(RPCAccountLinesHandlerTest, InvalidMarker)
"marker": "123invalid"
}})",
ACCOUNT));
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());
@@ -156,7 +156,7 @@ TEST_F(RPCAccountLinesHandlerTest, InvalidMarker)
"marker": 401
}})",
ACCOUNT));
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());
@@ -175,7 +175,7 @@ TEST_F(RPCAccountLinesHandlerTest, IncorrectLimit)
"limit": 9
}})",
ACCOUNT));
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());
@@ -189,7 +189,7 @@ TEST_F(RPCAccountLinesHandlerTest, IncorrectLimit)
"limit": 401
}})",
ACCOUNT));
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());
@@ -206,7 +206,7 @@ TEST_F(RPCAccountLinesHandlerTest, AccountInvalidFormat)
R"({
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jp"
})");
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");
@@ -223,7 +223,7 @@ TEST_F(RPCAccountLinesHandlerTest, AccountNotString)
R"({
"account": 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());
@@ -251,7 +251,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerHash)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{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());
@@ -279,7 +279,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerStringIndex)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{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");
@@ -305,7 +305,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerIntIndex)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{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");
@@ -335,7 +335,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerHash2)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{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");
@@ -361,7 +361,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistLedgerViaLedgerIndex2)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{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");
@@ -393,7 +393,7 @@ TEST_F(RPCAccountLinesHandlerTest, NonExistAccount)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{AccountLinesHandler{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(), "actNotFound");
@@ -481,7 +481,7 @@ TEST_F(RPCAccountLinesHandlerTest, DefaultParameterTest)
})";
auto handler = AnyHandler{AccountLinesHandler{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);
});
@@ -547,7 +547,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseLimit)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountLinesHandler{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).as_object().at("lines").as_array().size(), 20);
@@ -639,7 +639,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseDestination)
ACCOUNT3));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountLinesHandler{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).as_object().at("lines").as_array().size(), 20);
});
@@ -680,7 +680,7 @@ TEST_F(RPCAccountLinesHandlerTest, EmptyChannel)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountLinesHandler{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).as_object().at("lines").as_array().size(), 0);
});
@@ -775,7 +775,7 @@ TEST_F(RPCAccountLinesHandlerTest, OptionalResponseField)
ACCOUNT));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountLinesHandler{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);
});
@@ -853,7 +853,7 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerOutput)
limit));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountLinesHandler{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).as_object().at("marker").as_string().c_str(),
@@ -920,7 +920,7 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerInput)
nextPage));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{AccountLinesHandler{this->mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(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

View File

@@ -150,7 +150,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, 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(), testBundle.expectedError);
@@ -179,7 +179,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaHash)
LEDGERHASH));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -207,7 +207,7 @@ TEST_F(RPCAccountOffersHandlerTest, LedgerNotFoundViaStringIndex)
seq));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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(RPCAccountOffersHandlerTest, LedgerNotFoundViaIntIndex)
seq));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -264,7 +264,7 @@ TEST_F(RPCAccountOffersHandlerTest, AccountNotFound)
ACCOUNT));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), "actNotFound");
@@ -345,7 +345,7 @@ TEST_F(RPCAccountOffersHandlerTest, DefaultParams)
ACCOUNT));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});
@@ -400,7 +400,7 @@ TEST_F(RPCAccountOffersHandlerTest, Limit)
ACCOUNT));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), 10);
EXPECT_EQ(
@@ -462,7 +462,7 @@ TEST_F(RPCAccountOffersHandlerTest, Marker)
startPage));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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(), 19);
EXPECT_FALSE(output->as_object().contains("marker"));
@@ -504,7 +504,7 @@ TEST_F(RPCAccountOffersHandlerTest, MarkerNotExists)
startPage));
auto const handler = AnyHandler{AccountOffersHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
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");

View File

@@ -215,7 +215,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, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
@@ -287,7 +287,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexSpecificForwardTrue)
ACCOUNT,
MINSEQ + 1,
MAXSEQ - 1));
auto const output = handler.process(input, yield);
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 + 1);
@@ -334,7 +334,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexSpecificForwardFalse)
ACCOUNT,
MINSEQ + 1,
MAXSEQ - 1));
auto const output = handler.process(input, yield);
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 + 1);
@@ -380,7 +380,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexNotSpecificForwardTrue)
ACCOUNT,
-1,
-1));
auto const output = handler.process(input, yield);
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);
@@ -427,7 +427,7 @@ TEST_F(RPCAccountTxHandlerTest, IndexNotSpecificForwardFalse)
ACCOUNT,
-1,
-1));
auto const output = handler.process(input, yield);
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);
@@ -474,7 +474,7 @@ TEST_F(RPCAccountTxHandlerTest, BinaryTrue)
ACCOUNT,
-1,
-1));
auto const output = handler.process(input, yield);
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);
@@ -548,7 +548,7 @@ TEST_F(RPCAccountTxHandlerTest, LimitAndMarker)
ACCOUNT,
-1,
-1));
auto const output = handler.process(input, yield);
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);
@@ -598,7 +598,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificLedgerIndex)
}})",
ACCOUNT,
MAXSEQ - 1));
auto const output = handler.process(input, yield);
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(), MAXSEQ - 1);
@@ -629,7 +629,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificNonexistLedgerIntIndex)
}})",
ACCOUNT,
MAXSEQ - 1));
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");
@@ -657,7 +657,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificNonexistLedgerStringIndex)
}})",
ACCOUNT,
MAXSEQ - 1));
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");
@@ -702,7 +702,7 @@ TEST_F(RPCAccountTxHandlerTest, SpecificLedgerHash)
}})",
ACCOUNT,
LEDGERHASH));
auto const output = handler.process(input, yield);
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(), MAXSEQ - 1);
@@ -747,7 +747,7 @@ TEST_F(RPCAccountTxHandlerTest, TxLessThanMinSeq)
ACCOUNT,
MINSEQ + 2,
MAXSEQ - 1));
auto const output = handler.process(input, yield);
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 + 2);
@@ -792,7 +792,7 @@ TEST_F(RPCAccountTxHandlerTest, TxLargerThanMaxSeq)
ACCOUNT,
MINSEQ + 1,
MAXSEQ - 2));
auto const output = handler.process(input, yield);
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 + 1);

View File

@@ -80,8 +80,8 @@ 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), yield);
auto const output = handler.process(
json::parse(bundle.testJson), Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), bundle.expectedError);
@@ -534,8 +534,8 @@ 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), yield);
auto const output = handler.process(
json::parse(bundle.inputJson), Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output.value(), json::parse(bundle.expectedJson));
});
@@ -1246,7 +1246,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaIntSequence)
ACCOUNT));
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
runSpawn([&](boost::asio::yield_context yield) {
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");
@@ -1280,7 +1280,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaSequence)
ACCOUNT));
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
runSpawn([&](boost::asio::yield_context yield) {
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");
@@ -1315,7 +1315,7 @@ TEST_F(RPCBookOffersHandlerTest, LedgerNonExistViaHash)
ACCOUNT));
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
runSpawn([&](boost::asio::yield_context yield) {
auto const output = handler.process(input);
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");
@@ -1413,9 +1413,8 @@ TEST_F(RPCBookOffersHandlerTest, Limit)
ACCOUNT));
auto const handler = AnyHandler{BookOffersHandler{mockBackendPtr}};
runSpawn([&](boost::asio::yield_context yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
std::cout << output.value() << std::endl;
EXPECT_EQ(output.value().as_object().at("offers").as_array().size(), 5);
});
}

View File

@@ -73,8 +73,8 @@ 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), yield);
auto const output = handler.process(
json::parse(bundle.testJson), Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), bundle.expectedError);
@@ -207,7 +207,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaStringIndex)
}})",
ACCOUNT,
seq)),
yield);
Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -236,7 +236,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaIntIndex)
}})",
ACCOUNT,
seq)),
yield);
Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -264,7 +264,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaHash)
}})",
ACCOUNT,
LEDGERHASH)),
yield);
Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "lgrNotFound");
@@ -299,7 +299,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, AccountNotFound)
"account": "{}"
}})",
ACCOUNT)),
yield);
Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "actNotFound");
@@ -352,7 +352,7 @@ TEST_F(RPCGatewayBalancesHandlerTest, InvalidHotWallet)
}})",
ACCOUNT,
ACCOUNT2)),
yield);
Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
EXPECT_EQ(err.at("error").as_string(), "invalidParams");
@@ -431,7 +431,7 @@ TEST_P(NormalPathTest, CheckOutput)
}})",
ACCOUNT,
bundle.hotwallet)),
yield);
Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output.value(), json::parse(bundle.expectedJson));
});

View File

@@ -552,13 +552,11 @@ 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, 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(), testBundle.expectedError);
std::cout << err.at("error").as_string() << std::endl;
std::cout << err.at("error_message").as_string() << std::endl;
EXPECT_EQ(
err.at("error_message").as_string(),
testBundle.expectedErrorMessage);
@@ -597,7 +595,7 @@ TEST_P(IndexTest, InvalidIndexUint256)
"{}": "invalid"
}})",
index));
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());
@@ -616,7 +614,7 @@ TEST_P(IndexTest, InvalidIndexNotString)
"{}": 123
}})",
index));
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());
@@ -650,7 +648,7 @@ TEST_F(RPCLedgerEntryTest, LedgerEntryNotFound)
"account_root": "{}"
}})",
ACCOUNT));
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(), "entryNotFound");
@@ -951,7 +949,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, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output.value().at("ledger_hash").as_string(), LEDGERHASH);
EXPECT_EQ(output.value().at("ledger_index").as_uint64(), RANGEMAX);
@@ -1012,7 +1010,7 @@ TEST_F(RPCLedgerEntryTest, BinaryFalse)
"payment_channel": "{}"
}})",
INDEX1));
auto const output = handler.process(req, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(OUT));
});
@@ -1045,11 +1043,10 @@ TEST_F(RPCLedgerEntryTest, UnexpectedLedgerType)
"check": "{}"
}})",
INDEX1));
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(), "unexpectedLedgerType");
std::cout << err << std::endl;
});
}
@@ -1072,7 +1069,7 @@ TEST_F(RPCLedgerEntryTest, LedgerNotExistViaIntSequence)
}})",
INDEX1,
RANGEMAX));
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(), "lgrNotFound");
@@ -1099,7 +1096,7 @@ TEST_F(RPCLedgerEntryTest, LedgerNotExistViaStringSequence)
}})",
INDEX1,
RANGEMAX));
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(), "lgrNotFound");
@@ -1126,7 +1123,7 @@ TEST_F(RPCLedgerEntryTest, LedgerNotExistViaHash)
}})",
INDEX1,
LEDGERHASH));
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(), "lgrNotFound");

View File

@@ -52,7 +52,7 @@ TEST_F(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerHash)
LEDGERHASH));
runSpawn([&, this](boost::asio::yield_context yield) {
auto const handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerIndex)
NFTID));
runSpawn([&, this](boost::asio::yield_context yield) {
auto const handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerHash2)
LEDGERHASH));
runSpawn([&, this](boost::asio::yield_context yield) {
auto const handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, NonExistLedgerViaLedgerIndex2)
NFTID));
runSpawn([&, this](boost::asio::yield_context yield) {
auto const handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, NoNFT)
LEDGERHASH));
runSpawn([&, this](boost::asio::yield_context yield) {
auto const handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, 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(RPCNFTBuyOffersHandlerTest, DefaultParameters)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, MultipleResultsWithMarkerAndLimitOutput)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTBuyOffersHandler{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(RPCNFTBuyOffersHandlerTest, ResultsForInputWithMarkerAndLimit)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTBuyOffersHandler{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{NFTBuyOffersHandler{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);

View File

@@ -50,7 +50,7 @@ TEST_F(RPCNFTInfoHandlerTest, 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());
@@ -69,7 +69,7 @@ TEST_F(RPCNFTInfoHandlerTest, 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());
@@ -88,7 +88,7 @@ TEST_F(RPCNFTInfoHandlerTest, 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());
@@ -105,7 +105,7 @@ TEST_F(RPCNFTInfoHandlerTest, 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");
@@ -121,7 +121,7 @@ TEST_F(RPCNFTInfoHandlerTest, 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());
@@ -149,7 +149,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, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
@@ -177,7 +177,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, 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");
@@ -203,7 +203,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, 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");
@@ -233,7 +233,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, 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");
@@ -259,7 +259,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, 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");
@@ -292,7 +292,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, 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");
@@ -339,7 +339,7 @@ TEST_F(RPCNFTInfoHandlerTest, DefaultParameters)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTInfoHandler{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(correntOutput), *output);
});
@@ -383,7 +383,7 @@ TEST_F(RPCNFTInfoHandlerTest, BurnedNFT)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTInfoHandler{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(correntOutput), *output);
});
@@ -428,7 +428,7 @@ TEST_F(RPCNFTInfoHandlerTest, NotBurnedNFTWithoutURI)
NFTID));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTInfoHandler{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(correntOutput), *output);
});
@@ -473,7 +473,7 @@ TEST_F(RPCNFTInfoHandlerTest, NFTWithExtraFieldsSet)
NFTID2));
runSpawn([&, this](auto& yield) {
auto handler = AnyHandler{NFTInfoHandler{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(correntOutput), *output);
});

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

View File

@@ -153,7 +153,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, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_FALSE(output);
auto const err = RPC::makeError(output.error());
@@ -184,7 +184,7 @@ TEST_F(RPCNoRippleCheckTest, LedgerNotExistViaHash)
LEDGERHASH));
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -213,7 +213,7 @@ TEST_F(RPCNoRippleCheckTest, LedgerNotExistViaIntIndex)
seq));
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -242,7 +242,7 @@ TEST_F(RPCNoRippleCheckTest, LedgerNotExistViaStringIndex)
seq));
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
runSpawn([&](auto& yield) {
auto const output = handler.process(input);
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");
@@ -274,7 +274,7 @@ TEST_F(RPCNoRippleCheckTest, AccountNotExist)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{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(), "actNotFound");
@@ -363,7 +363,7 @@ TEST_F(
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});
@@ -429,7 +429,7 @@ TEST_F(
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});
@@ -517,7 +517,7 @@ TEST_F(
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});
@@ -583,7 +583,7 @@ TEST_F(
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});
@@ -644,7 +644,7 @@ TEST_F(
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(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);
@@ -722,7 +722,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathLimit)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(output->as_object().at("problems").as_array().size(), 1);
});
@@ -850,7 +850,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathTransactions)
LEDGERHASH));
runSpawn([&, this](auto& yield) {
auto const handler = AnyHandler{NoRippleCheckHandler{mockBackendPtr}};
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(expectedOutput));
});

View File

@@ -20,6 +20,7 @@
#include <rpc/common/AnyHandler.h>
#include <rpc/handlers/impl/FakesAndMocks.h>
#include <util/Fixtures.h>
#include <util/MockWsBase.h>
#include <boost/json/parse.hpp>
@@ -59,7 +60,7 @@ TEST_F(RPCTestHandlerTest, CoroutineHandlerSuccess)
})");
boost::asio::io_context ctx;
boost::asio::spawn(ctx, [&](boost::asio::yield_context yield) {
auto const output = handler.process(input, yield);
auto const output = handler.process(input, Context{std::ref(yield)});
ASSERT_TRUE(output);
auto const val = output.value();

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

View File

@@ -50,7 +50,7 @@ TEST_F(RPCTxTest, ExcessiveLgrRange)
"max_ledger":1002
}})",
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());
@@ -72,7 +72,7 @@ TEST_F(RPCTxTest, InvalidLgrRange)
"min_ledger": 10
}})",
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());
@@ -96,7 +96,7 @@ TEST_F(RPCTxTest, TxnNotFound)
"transaction": "{}"
}})",
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());
@@ -124,7 +124,7 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllFalse)
"max_ledger":1000
}})",
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());
@@ -153,7 +153,7 @@ TEST_F(RPCTxTest, TxnNotFoundInGivenRangeSearchAllTrue)
"max_ledger":1000
}})",
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());
@@ -223,7 +223,7 @@ TEST_F(RPCTxTest, DefaultParameter)
"transaction": "{}"
}})",
TXNID));
auto const output = handler.process(req, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(OUT));
});
@@ -261,7 +261,7 @@ TEST_F(RPCTxTest, ReturnBinary)
"binary": true
}})",
TXNID));
auto const output = handler.process(req, yield);
auto const output = handler.process(req, Context{std::ref(yield)});
ASSERT_TRUE(output);
EXPECT_EQ(*output, json::parse(OUT));
});

View File

@@ -122,7 +122,7 @@ public:
}
Result
process(Input input, boost::asio::yield_context& yield) const
process(Input input, RPCng::Context const& ctx) const
{
return Output{
input.hello + '_' + std::to_string(input.limit.value_or(0))};