1#include <xrpl/ledger/LedgerTiming.h>
3#include <xrpl/basics/chrono.h>
5#include <gtest/gtest.h>
13TEST(LedgerTimingTest, get_next_ledger_time_resolution)
27 auto nextCloseResolution = closeResolution;
33 if (nextCloseResolution < closeResolution)
37 else if (nextCloseResolution > closeResolution)
45 std::swap(nextCloseResolution, closeResolution);
46 }
while (round < rounds);
53 auto decreases = TestRes::run(
false, 10);
54 EXPECT_TRUE(decreases.increase == 3);
55 EXPECT_TRUE(decreases.decrease == 0);
56 EXPECT_TRUE(decreases.equal == 7);
60 auto increases = TestRes::run(
false, 100);
61 EXPECT_TRUE(increases.increase == 3);
62 EXPECT_TRUE(increases.decrease == 0);
63 EXPECT_TRUE(increases.equal == 97);
66TEST(LedgerTimingTest, round_close_time)
68 using namespace std::chrono_literals;
85TEST(LedgerTimingTest, eff_close_time)
87 using namespace std::chrono_literals;
90 EXPECT_TRUE(close == tp{1s});
93 EXPECT_TRUE(close == tp{30s});
96 EXPECT_TRUE(close == tp{31s});
99 EXPECT_TRUE(close == tp{61s});
102 EXPECT_TRUE(close == tp{30s});
std::chrono::time_point< NetClock > time_point
bool equal(STAmount const &sa1, STAmount const &sa2)
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.
int run(int argc, char **argv)
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.