20#include <xrpld/consensus/LedgerTiming.h>
22#include <xrpl/beast/unit_test.h>
44 auto nextCloseResolution = closeResolution;
49 closeResolution, previousAgree, ++round);
50 if (nextCloseResolution < closeResolution)
52 else if (nextCloseResolution > closeResolution)
56 std::swap(nextCloseResolution, closeResolution);
57 }
while (round < rounds);
64 auto decreases = test_res::run(
false, 10);
65 BEAST_EXPECT(decreases.increase == 3);
66 BEAST_EXPECT(decreases.decrease == 0);
67 BEAST_EXPECT(decreases.equal == 7);
71 auto increases = test_res::run(
false, 100);
72 BEAST_EXPECT(increases.increase == 3);
73 BEAST_EXPECT(increases.decrease == 0);
74 BEAST_EXPECT(increases.equal == 97);
80 using namespace std::chrono_literals;
100 using namespace std::chrono_literals;
103 BEAST_EXPECT(close == tp{1s});
106 BEAST_EXPECT(close == tp{30s});
109 BEAST_EXPECT(close == tp{31s});
112 BEAST_EXPECT(close == tp{61s});
115 BEAST_EXPECT(close == tp{30s});
127BEAST_DEFINE_TESTSUITE(LedgerTiming, consensus,
ripple);
std::chrono::time_point< NetClock > time_point
void testGetNextLedgerTimeResolution()
void run() override
Runs the suite.
void testRoundCloseTime()
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.
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.
auto constexpr ledgerDefaultTimeResolution
Initial resolution of ledger close time.
int run(int argc, char **argv)
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.