mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Expose consensus parameters for simulation (RIPD-1355)
This commit is contained in:
@@ -77,6 +77,7 @@ class LedgerTiming_test : public beast::unit_test::suite
|
||||
|
||||
void testRoundCloseTime()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// A closeTime equal to the epoch is not modified
|
||||
using tp = NetClock::time_point;
|
||||
tp def;
|
||||
@@ -94,67 +95,11 @@ class LedgerTiming_test : public beast::unit_test::suite
|
||||
|
||||
}
|
||||
|
||||
void testShouldCloseLedger()
|
||||
{
|
||||
// Bizarre times forcibly close
|
||||
BEAST_EXPECT(shouldCloseLedger(true, 10, 10, 10, -10s, 10s, 1s, 1s, j));
|
||||
BEAST_EXPECT(shouldCloseLedger(true, 10, 10, 10, 100h, 10s, 1s, 1s, j));
|
||||
BEAST_EXPECT(shouldCloseLedger(true, 10, 10, 10, 10s, 100h, 1s, 1s, j));
|
||||
|
||||
// Rest of network has closed
|
||||
BEAST_EXPECT(shouldCloseLedger(true, 10, 3, 5, 10s, 10s, 10s, 10s, j));
|
||||
|
||||
// No transactions means wait until end of internval
|
||||
BEAST_EXPECT(!shouldCloseLedger(false, 10, 0, 0, 1s, 1s, 1s, 10s, j));
|
||||
BEAST_EXPECT(shouldCloseLedger(false, 10, 0, 0, 1s, 10s, 1s, 10s, j));
|
||||
|
||||
// Enforce minimum ledger open time
|
||||
BEAST_EXPECT(!shouldCloseLedger(true, 10, 0, 0, 10s, 10s, 1s, 10s, j));
|
||||
|
||||
// Don't go too much faster than last time
|
||||
BEAST_EXPECT(!shouldCloseLedger(true, 10, 0, 0, 10s, 10s, 3s, 10s, j));
|
||||
|
||||
BEAST_EXPECT(shouldCloseLedger(true, 10, 0, 0, 10s, 10s, 10s, 10s, j));
|
||||
|
||||
}
|
||||
|
||||
void testCheckConsensus()
|
||||
{
|
||||
// Not enough time has elapsed
|
||||
BEAST_EXPECT( ConsensusState::No
|
||||
== checkConsensus(10, 2, 2, 0, 3s, 2s, true, j));
|
||||
|
||||
// If not enough peers have propsed, ensure
|
||||
// more time for proposals
|
||||
BEAST_EXPECT( ConsensusState::No
|
||||
== checkConsensus(10, 2, 2, 0, 3s, 4s, true, j));
|
||||
|
||||
// Enough time has elapsed and we all agree
|
||||
BEAST_EXPECT( ConsensusState::Yes
|
||||
== checkConsensus(10, 2, 2, 0, 3s, 10s, true, j));
|
||||
|
||||
// Enough time has elapsed and we don't yet agree
|
||||
BEAST_EXPECT( ConsensusState::No
|
||||
== checkConsensus(10, 2, 1, 0, 3s, 10s, true, j));
|
||||
|
||||
// Our peers have moved on
|
||||
// Enough time has elapsed and we all agree
|
||||
BEAST_EXPECT( ConsensusState::MovedOn
|
||||
== checkConsensus(10, 2, 1, 8, 3s, 10s, true, j));
|
||||
|
||||
// No peers makes it easy to agree
|
||||
BEAST_EXPECT( ConsensusState::Yes
|
||||
== checkConsensus(0, 0, 0, 0, 3s, 10s, true, j));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
testGetNextLedgerTimeResolution();
|
||||
testRoundCloseTime();
|
||||
testShouldCloseLedger();
|
||||
testCheckConsensus();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user