20#include <xrpld/consensus/LedgerTiming.h>
21#include <xrpl/beast/unit_test.h>
43 auto nextCloseResolution = closeResolution;
48 closeResolution, previousAgree, ++round);
49 if (nextCloseResolution < closeResolution)
51 else if (nextCloseResolution > closeResolution)
55 std::swap(nextCloseResolution, closeResolution);
56 }
while (round < rounds);
63 auto decreases = test_res::run(
false, 10);
64 BEAST_EXPECT(decreases.increase == 3);
65 BEAST_EXPECT(decreases.decrease == 0);
66 BEAST_EXPECT(decreases.equal == 7);
70 auto increases = test_res::run(
false, 100);
71 BEAST_EXPECT(increases.increase == 3);
72 BEAST_EXPECT(increases.decrease == 0);
73 BEAST_EXPECT(increases.equal == 97);
79 using namespace std::chrono_literals;
99 using namespace std::chrono_literals;
102 BEAST_EXPECT(close == tp{1s});
105 BEAST_EXPECT(close == tp{30s});
108 BEAST_EXPECT(close == tp{31s});
111 BEAST_EXPECT(close == tp{61s});
114 BEAST_EXPECT(close == tp{30s});
126BEAST_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.