19#include <xrpld/consensus/LedgerTiming.h>
20#include <xrpl/beast/unit_test.h>
42 auto nextCloseResolution = closeResolution;
47 closeResolution, previousAgree, ++round);
48 if (nextCloseResolution < closeResolution)
50 else if (nextCloseResolution > closeResolution)
54 std::swap(nextCloseResolution, closeResolution);
55 }
while (round < rounds);
62 auto decreases = test_res::run(
false, 10);
63 BEAST_EXPECT(decreases.increase == 3);
64 BEAST_EXPECT(decreases.decrease == 0);
65 BEAST_EXPECT(decreases.equal == 7);
69 auto increases = test_res::run(
false, 100);
70 BEAST_EXPECT(increases.increase == 3);
71 BEAST_EXPECT(increases.decrease == 0);
72 BEAST_EXPECT(increases.equal == 97);
78 using namespace std::chrono_literals;
98 using namespace std::chrono_literals;
101 BEAST_EXPECT(close == tp{1s});
104 BEAST_EXPECT(close == tp{30s});
107 BEAST_EXPECT(close == tp{31s});
110 BEAST_EXPECT(close == tp{61s});
113 BEAST_EXPECT(close == tp{30s});
125BEAST_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.