mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Format first-party source according to .clang-format
This commit is contained in:
committed by
manojsdoshi
parent
65dfc5d19e
commit
50760c6935
@@ -24,7 +24,8 @@ namespace test {
|
||||
|
||||
class LedgerTiming_test : public beast::unit_test::suite
|
||||
{
|
||||
void testGetNextLedgerTimeResolution()
|
||||
void
|
||||
testGetNextLedgerTimeResolution()
|
||||
{
|
||||
// helper to iteratively call into getNextLedgerTimeResolution
|
||||
struct test_res
|
||||
@@ -33,7 +34,8 @@ class LedgerTiming_test : public beast::unit_test::suite
|
||||
std::uint32_t equal = 0;
|
||||
std::uint32_t increase = 0;
|
||||
|
||||
static test_res run(bool previousAgree, std::uint32_t rounds)
|
||||
static test_res
|
||||
run(bool previousAgree, std::uint32_t rounds)
|
||||
{
|
||||
test_res res;
|
||||
auto closeResolution = ledgerDefaultTimeResolution;
|
||||
@@ -41,38 +43,37 @@ class LedgerTiming_test : public beast::unit_test::suite
|
||||
std::uint32_t round = 0;
|
||||
do
|
||||
{
|
||||
nextCloseResolution = getNextLedgerTimeResolution(
|
||||
closeResolution, previousAgree, ++round);
|
||||
if (nextCloseResolution < closeResolution)
|
||||
++res.decrease;
|
||||
else if (nextCloseResolution > closeResolution)
|
||||
++res.increase;
|
||||
else
|
||||
++res.equal;
|
||||
std::swap(nextCloseResolution, closeResolution);
|
||||
nextCloseResolution = getNextLedgerTimeResolution(
|
||||
closeResolution, previousAgree, ++round);
|
||||
if (nextCloseResolution < closeResolution)
|
||||
++res.decrease;
|
||||
else if (nextCloseResolution > closeResolution)
|
||||
++res.increase;
|
||||
else
|
||||
++res.equal;
|
||||
std::swap(nextCloseResolution, closeResolution);
|
||||
} while (round < rounds);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// If we never agree on close time, only can increase resolution
|
||||
// until hit the max
|
||||
auto decreases = test_res::run(false, 10);
|
||||
BEAST_EXPECT(decreases.increase == 3);
|
||||
BEAST_EXPECT(decreases.decrease == 0);
|
||||
BEAST_EXPECT(decreases.equal == 7);
|
||||
BEAST_EXPECT(decreases.equal == 7);
|
||||
|
||||
// If we always agree on close time, only can decrease resolution
|
||||
// until hit the min
|
||||
auto increases = test_res::run(false, 100);
|
||||
BEAST_EXPECT(increases.increase == 3);
|
||||
BEAST_EXPECT(increases.decrease == 0);
|
||||
BEAST_EXPECT(increases.equal == 97);
|
||||
|
||||
BEAST_EXPECT(increases.equal == 97);
|
||||
}
|
||||
|
||||
void testRoundCloseTime()
|
||||
void
|
||||
testRoundCloseTime()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// A closeTime equal to the epoch is not modified
|
||||
@@ -82,17 +83,17 @@ class LedgerTiming_test : public beast::unit_test::suite
|
||||
|
||||
// Otherwise, the closeTime is rounded to the nearest
|
||||
// rounding up on ties
|
||||
BEAST_EXPECT(tp{ 0s } == roundCloseTime(tp{ 29s }, 60s));
|
||||
BEAST_EXPECT(tp{ 30s } == roundCloseTime(tp{ 30s }, 1s));
|
||||
BEAST_EXPECT(tp{ 60s } == roundCloseTime(tp{ 31s }, 60s));
|
||||
BEAST_EXPECT(tp{ 60s } == roundCloseTime(tp{ 30s }, 60s));
|
||||
BEAST_EXPECT(tp{ 60s } == roundCloseTime(tp{ 59s }, 60s));
|
||||
BEAST_EXPECT(tp{ 60s } == roundCloseTime(tp{ 60s }, 60s));
|
||||
BEAST_EXPECT(tp{ 60s } == roundCloseTime(tp{ 61s }, 60s));
|
||||
|
||||
BEAST_EXPECT(tp{0s} == roundCloseTime(tp{29s}, 60s));
|
||||
BEAST_EXPECT(tp{30s} == roundCloseTime(tp{30s}, 1s));
|
||||
BEAST_EXPECT(tp{60s} == roundCloseTime(tp{31s}, 60s));
|
||||
BEAST_EXPECT(tp{60s} == roundCloseTime(tp{30s}, 60s));
|
||||
BEAST_EXPECT(tp{60s} == roundCloseTime(tp{59s}, 60s));
|
||||
BEAST_EXPECT(tp{60s} == roundCloseTime(tp{60s}, 60s));
|
||||
BEAST_EXPECT(tp{60s} == roundCloseTime(tp{61s}, 60s));
|
||||
}
|
||||
|
||||
void testEffCloseTime()
|
||||
void
|
||||
testEffCloseTime()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
using tp = NetClock::time_point;
|
||||
@@ -119,9 +120,8 @@ class LedgerTiming_test : public beast::unit_test::suite
|
||||
testRoundCloseTime();
|
||||
testEffCloseTime();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(LedgerTiming, consensus, ripple);
|
||||
} // test
|
||||
} // ripple
|
||||
} // namespace test
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user