20 #include <ripple/app/tx/impl/Taker.h>
21 #include <ripple/beast/core/LexicalCast.h>
22 #include <ripple/beast/unit_test.h>
29 static bool const Buy =
false;
30 static bool const Sell =
true;
40 Amounts
const& amount,
41 Quality
const& quality,
74 cross(Amounts offer, Quality quality)
77 return Amounts(offer.in.zeroed(), offer.out.zeroed());
81 return Amounts(offer.in.zeroed(), offer.out.zeroed());
84 return Amounts(offer.in.zeroed(), offer.out.zeroed());
105 Amounts{offer1.in.zeroed(), offer1.out.zeroed()},
106 Amounts{offer2.in.zeroed(), offer2.out.zeroed()});
110 Amounts{offer1.in.zeroed(), offer1.out.zeroed()},
111 Amounts{offer2.in.zeroed(), offer2.out.zeroed()});
129 static Issue const issue(
137 static Issue const issue(
158 Issue const& issue_in,
160 Issue const& issue_out)
193 Quality taker_quality,
196 Quality cross_quality,
200 Issue const& issue_in,
201 Issue const& issue_out,
213 if (
isXRP(issue_out))
215 else if (
isXRP(issue_in))
233 auto result = taker.
cross(cross_offer, cross_quality);
235 Amounts
const expected(
238 BEAST_EXPECT(expected == result);
240 if (expected != result)
272 testcase(
"XRP Quantization: input");
589 testcase(
"XRP Quantization: output");
906 testcase(
"IOU to IOU");
940 {
"2.666666666666666",
"2.666666666666666"},
982 {
"0.6666666666666667",
"0.6666666666666667"},
996 {
"1.666666666666666",
"1.666666666666666"},
void set_funds(STAmount const &funds)
A currency issued by an account.
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, ripple)
Represents a transfer rate.
Quality composed_quality(Quality const &lhs, Quality const &rhs)
Issue const & issue() const
Issue const & xrp() const
void attempt(bool sell, std::string name, Quality taker_quality, cross_attempt_offer const offer, std::string const funds, Quality cross_quality, cross_attempt_offer const cross, std::string const cross_funds, cross_attempt_offer const flow, Issue const &issue_in, Issue const &issue_out, Rate rate_in=parityRate, Rate rate_out=parityRate)
BasicTaker::Flow do_cross(Amounts offer, Quality quality, AccountID const &owner)
Perform direct crossing through given offer.
bool reject(Quality const &quality) const noexcept
Returns true if the quality does not meet the taker's requirements.
std::string getText() const override
State for the active party during order book or payment operations.
Issue const & eur() const
Amounts cross(Amounts offer, Quality quality)
CrossType cross_type() const
Returns the type of crossing that is being performed.
const Rate parityRate(QUALITY_ONE)
A transfer rate signifying a 1:1 exchange.
Amounts parse_amounts(std::string const &amount_in, Issue const &issue_in, std::string const &amount_out, Issue const &issue_out)
std::string format_amount(STAmount const &amount)
path::RippleCalc::Output flow(PaymentSandbox &view, STAmount const &deliver, AccountID const &src, AccountID const &dst, STPathSet const &paths, bool defaultPaths, bool partialPayment, bool ownerPaysTransferFee, bool offerCrossing, std::optional< Quality > const &limitQuality, std::optional< STAmount > const &sendMax, beast::Journal j, path::detail::FlowDebugInfo *flowDebugInfo=nullptr)
Make a payment from the src account to the dst account.
CrossType
The flavor of an offer crossing.
STAmount get_funds(AccountID const &owner, STAmount const &funds) const override
AccountID const & xrpAccount()
Compute AccountID from public key.
bool isXRP(AccountID const &c)
cross_attempt_offer(std::string const &in_, std::string const &out_)
TestTaker(CrossType cross_type, Amounts const &amount, Quality const &quality, STAmount const &funds, std::uint32_t flags, Rate const &rate_in, Rate const &rate_out)
Issue const & usd() const
STAmount parse_amount(std::string const &amount, Issue const &issue)
bool done() const
Returns true if order crossing should not continue.
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
STAmount amountFromString(Issue const &issue, std::string const &amount)
constexpr std::uint32_t tfSell
std::pair< Amounts, Amounts > cross(Amounts offer1, Quality quality1, Amounts offer2, Quality quality2)
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Quality get_quality(std::string in, std::string out)
AccountID const & account() const noexcept
Returns the account identifier of the taker.
Currency const & xrpCurrency()
XRP currency.
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.