1#include <xrpld/consensus/LedgerTiming.h>
3#include <xrpl/beast/unit_test.h>
25 auto nextCloseResolution = closeResolution;
30 closeResolution, previousAgree, ++round);
31 if (nextCloseResolution < closeResolution)
33 else if (nextCloseResolution > closeResolution)
37 std::swap(nextCloseResolution, closeResolution);
38 }
while (round < rounds);
45 auto decreases = test_res::run(
false, 10);
46 BEAST_EXPECT(decreases.increase == 3);
47 BEAST_EXPECT(decreases.decrease == 0);
48 BEAST_EXPECT(decreases.equal == 7);
52 auto increases = test_res::run(
false, 100);
53 BEAST_EXPECT(increases.increase == 3);
54 BEAST_EXPECT(increases.decrease == 0);
55 BEAST_EXPECT(increases.equal == 97);
61 using namespace std::chrono_literals;
81 using namespace std::chrono_literals;
84 BEAST_EXPECT(close == tp{1s});
87 BEAST_EXPECT(close == tp{30s});
90 BEAST_EXPECT(close == tp{31s});
93 BEAST_EXPECT(close == tp{61s});
96 BEAST_EXPECT(close == tp{30s});
108BEAST_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.