1#include <xrpl/basics/chrono.h>
2#include <xrpl/beast/unit_test/suite.h>
3#include <xrpl/ledger/LedgerTiming.h>
28 auto nextCloseResolution = closeResolution;
34 if (nextCloseResolution < closeResolution)
38 else if (nextCloseResolution > closeResolution)
46 std::swap(nextCloseResolution, closeResolution);
47 }
while (round < rounds);
54 auto decreases = TestRes::run(
false, 10);
55 BEAST_EXPECT(decreases.increase == 3);
56 BEAST_EXPECT(decreases.decrease == 0);
57 BEAST_EXPECT(decreases.equal == 7);
61 auto increases = TestRes::run(
false, 100);
62 BEAST_EXPECT(increases.increase == 3);
63 BEAST_EXPECT(increases.decrease == 0);
64 BEAST_EXPECT(increases.equal == 97);
70 using namespace std::chrono_literals;
90 using namespace std::chrono_literals;
93 BEAST_EXPECT(close == tp{1s});
96 BEAST_EXPECT(close == tp{30s});
99 BEAST_EXPECT(close == tp{31s});
102 BEAST_EXPECT(close == tp{61s});
105 BEAST_EXPECT(close == tp{30s});
std::chrono::time_point< NetClock > time_point
void testRoundCloseTime()
void run() override
Runs the suite.
void testGetNextLedgerTimeResolution()
bool equal(STAmount const &sa1, STAmount const &sa2)
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::chrono::time_point< Clock, Duration > effCloseTime(std::chrono::time_point< Clock, Duration > closeTime, std::chrono::duration< Rep, Period > resolution, std::chrono::time_point< Clock, Duration > priorCloseTime)
Calculate the effective ledger close time.
static FeeLevel64 increase(FeeLevel64 level, std::uint32_t increasePercent)
std::chrono::duration< Rep, Period > getNextLedgerTimeResolution(std::chrono::duration< Rep, Period > previousResolution, bool previousAgree, Seq ledgerSeq)
Calculates the close time resolution for the specified ledger.
std::chrono::time_point< Clock, Duration > roundCloseTime(std::chrono::time_point< Clock, Duration > closeTime, std::chrono::duration< Rep, Period > closeResolution)
Calculates the close time for a ledger, given a close time resolution.
constexpr auto kLedgerDefaultTimeResolution
Initial resolution of ledger close time.