1#include <xrpl/basics/base_uint.h>
2#include <xrpl/beast/hash/uhash.h>
3#include <xrpl/beast/unit_test/suite.h>
4#include <xrpl/beast/utility/Zero.h>
5#include <xrpl/protocol/AccountID.h>
6#include <xrpl/protocol/Feature.h>
7#include <xrpl/protocol/Issue.h>
8#include <xrpl/protocol/Quality.h>
9#include <xrpl/protocol/Rules.h>
10#include <xrpl/protocol/STAmount.h>
11#include <xrpl/protocol/UintTypes.h>
12#include <xrpl/protocol/XRPAmount.h>
32 template <
class Integer>
41 template <
class Integer>
52 template <
class In,
class Out>
59 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
61 ceilIn(
Quality const& q, In1 in, Out1 out, Int limit, In2 inExpected, Out2 outExpected)
63 auto const expectResult(
amounts(inExpected, outExpected));
66 BEAST_EXPECT(actualResult == expectResult);
69 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
71 ceilOut(
Quality const& q, In1 in, Out1 out, Int limit, In2 inExpected, Out2 outExpected)
73 auto const expectResult(
amounts(inExpected, outExpected));
76 BEAST_EXPECT(actualResult == expectResult);
271 Quality const q(0x5d048191fb9130daull);
274 raw(2755280000000000ull, -15));
287 Amounts const value(in,
raw(9'999'999'999'999'995ull, -15));
288 STAmount const limit(
raw(9'999'999'999'999'994ull, -15));
291 auto const rules = [](
bool const fix) {
296 return Rules{fix ? kFixFeatures : kNoFeatures};
305 for (
auto const&
ceilOut : ceilOuts)
324 BEAST_EXPECT(result.
in == in);
325 BEAST_EXPECT(result.
out == limit);
331 BEAST_EXPECT(result.
in == in);
332 BEAST_EXPECT(result.
out == limit);
342 Quality const q(0x59148191fb913522ull);
374 BEAST_EXPECT(q11 == q11);
375 BEAST_EXPECT(q11 < q12);
376 BEAST_EXPECT(q12 < q13);
377 BEAST_EXPECT(q31 < q21);
378 BEAST_EXPECT(q21 < q11);
379 BEAST_EXPECT(q11 >= q11);
380 BEAST_EXPECT(q12 >= q11);
381 BEAST_EXPECT(q13 >= q12);
382 BEAST_EXPECT(q21 >= q31);
383 BEAST_EXPECT(q11 >= q21);
384 BEAST_EXPECT(q12 > q11);
385 BEAST_EXPECT(q13 > q12);
386 BEAST_EXPECT(q21 > q31);
387 BEAST_EXPECT(q11 > q21);
388 BEAST_EXPECT(q11 <= q11);
389 BEAST_EXPECT(q11 <= q12);
390 BEAST_EXPECT(q12 <= q13);
391 BEAST_EXPECT(q31 <= q21);
392 BEAST_EXPECT(q21 <= q11);
393 BEAST_EXPECT(q31 != q21);
416 BEAST_EXPECT(q1331 == q3113);
417 BEAST_EXPECT(q1331 == q11);
430 BEAST_EXPECT(qa == qb);
431 BEAST_EXPECT(++qa != q11);
432 BEAST_EXPECT(qa != qb);
433 BEAST_EXPECT(--qb != q11);
434 BEAST_EXPECT(qa != qb);
435 BEAST_EXPECT(qb < qa);
436 BEAST_EXPECT(qb++ < qa);
437 BEAST_EXPECT(qb++ < qa);
438 BEAST_EXPECT(qb++ == qa);
439 BEAST_EXPECT(qa < qb);
TestcaseT testcase
Memberspace for declaring test cases.
RAII class to set and restore the current transaction rules.
A currency issued by an account.
void testCeilOutClampNative()
static STAmount amount(Integer integer)
static STAmount raw(std::uint64_t mantissa, int exponent)
static STAmount amount(Integer integer)
void ceilOut(Quality const &q, In1 in, Out1 out, Int limit, In2 inExpected, Out2 outExpected)
void run() override
Runs the suite.
void ceilIn(Quality const &q, In1 in, Out1 out, Int limit, In2 inExpected, Out2 outExpected)
static Amounts amounts(In in, Out out)
Represents the logical ratio of output currency to input currency.
STAmount rate() const
Returns the quality as STAmount.
Quality round(int tickSize) const
Returns the quality rounded up to the specified number of decimal digits.
Amounts ceilOut(Amounts const &amount, STAmount const &limit) const
Returns the scaled amount with out capped.
Amounts ceilIn(Amounts const &amount, STAmount const &limit) const
Returns the scaled amount with in capped.
Amounts ceilOutStrict(Amounts const &amount, STAmount const &limit, bool roundUp) const
Rules controlling protocol behavior.
std::string getText() const override
static constexpr std::uint64_t kMaxNativeN
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TAmounts< STAmount, STAmount > Amounts
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Issue const & noIssue()
Returns an asset specifier that represents no account and currency.
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, xrpl)
Quality composedQuality(Quality const &lhs, Quality const &rhs)
Calculate the quality of a two-hop path given the two hops.