mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Reduce coupling to date.h by calling C++17 chrono functions
This commit is contained in:
committed by
manojsdoshi
parent
64e4a89470
commit
9932a19139
@@ -32,6 +32,7 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <chrono>
|
||||
#include <date/date.h>
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/TrustedPublisherServer.h>
|
||||
#include <test/unit_test/FileDirGuard.h>
|
||||
|
||||
@@ -40,7 +40,7 @@ class ByzantineFailureSim_test : public beast::unit_test::suite
|
||||
ConsensusParms const parms{};
|
||||
|
||||
SimDuration const delay =
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
PeerGroup a = sim.createGroup(1);
|
||||
PeerGroup b = sim.createGroup(1);
|
||||
PeerGroup c = sim.createGroup(1);
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
// Connected trust and network graphs with single fixed delay
|
||||
peers.trustAndConnect(
|
||||
peers, date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
peers, round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
|
||||
// everyone submits their own ID as a TX
|
||||
for (Peer* p : peers)
|
||||
@@ -199,11 +199,10 @@ public:
|
||||
|
||||
// Fast and slow network connections
|
||||
fast.connect(
|
||||
fast, date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
fast, round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
|
||||
slow.connect(
|
||||
network,
|
||||
date::round<milliseconds>(1.1 * parms.ledgerGRANULARITY));
|
||||
network, round<milliseconds>(1.1 * parms.ledgerGRANULARITY));
|
||||
|
||||
// All peers submit their own ID as a transaction
|
||||
for (Peer* peer : network)
|
||||
@@ -256,12 +255,11 @@ public:
|
||||
|
||||
// Fast and slow network connections
|
||||
fast.connect(
|
||||
fast,
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
fast, round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
|
||||
slow.connect(
|
||||
network,
|
||||
date::round<milliseconds>(1.1 * parms.ledgerGRANULARITY));
|
||||
round<milliseconds>(1.1 * parms.ledgerGRANULARITY));
|
||||
|
||||
for (Peer* peer : slow)
|
||||
peer->runAsValidator = isParticipant;
|
||||
@@ -384,7 +382,7 @@ public:
|
||||
|
||||
network.trust(network);
|
||||
network.connect(
|
||||
network, date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
network, round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
|
||||
// Run consensus without skew until we have a short close time
|
||||
// resolution
|
||||
@@ -454,7 +452,7 @@ public:
|
||||
PeerGroup network = minority + majority;
|
||||
|
||||
SimDuration delay =
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
minority.trustAndConnect(minority + majorityA, delay);
|
||||
majority.trustAndConnect(majority, delay);
|
||||
|
||||
@@ -559,8 +557,7 @@ public:
|
||||
|
||||
PeerGroup network = loner + clique;
|
||||
network.connect(
|
||||
network,
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
network, round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
|
||||
// initial round to set prior state
|
||||
sim.run(1);
|
||||
@@ -609,10 +606,9 @@ public:
|
||||
network.trust(network);
|
||||
|
||||
// Fast and slow network connections
|
||||
fast.connect(
|
||||
fast, date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
fast.connect(fast, round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
slow.connect(
|
||||
network, date::round<milliseconds>(1.1 * parms.ledgerGRANULARITY));
|
||||
network, round<milliseconds>(1.1 * parms.ledgerGRANULARITY));
|
||||
|
||||
// Run to the ledger *prior* to decreasing the resolution
|
||||
sim.run(increaseLedgerTimeResolutionEvery - 2);
|
||||
@@ -712,7 +708,7 @@ public:
|
||||
PeerGroup network = a + b;
|
||||
|
||||
SimDuration delay =
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
a.trustAndConnect(a, delay);
|
||||
b.trustAndConnect(b, delay);
|
||||
|
||||
@@ -758,8 +754,7 @@ public:
|
||||
validators.trust(validators);
|
||||
center.trust(validators);
|
||||
|
||||
SimDuration delay =
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
SimDuration delay = round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
validators.connect(center, delay);
|
||||
|
||||
center[0]->runAsValidator = false;
|
||||
@@ -879,10 +874,8 @@ public:
|
||||
PeerGroup groupNotFastC = groupABD + groupCsplit;
|
||||
PeerGroup network = groupABD + groupCsplit + groupCfast;
|
||||
|
||||
SimDuration delay =
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
SimDuration fDelay =
|
||||
date::round<milliseconds>(0.1 * parms.ledgerGRANULARITY);
|
||||
SimDuration delay = round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
SimDuration fDelay = round<milliseconds>(0.1 * parms.ledgerGRANULARITY);
|
||||
|
||||
network.trust(network);
|
||||
// C must have a shorter delay to see all the validations before the
|
||||
@@ -992,8 +985,7 @@ public:
|
||||
|
||||
ConsensusParms const parms{};
|
||||
Sim sim;
|
||||
SimDuration delay =
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
SimDuration delay = round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
|
||||
|
||||
PeerGroup behind = sim.createGroup(3);
|
||||
PeerGroup ahead = sim.createGroup(2);
|
||||
|
||||
@@ -59,7 +59,7 @@ class ScaleFreeSim_test : public beast::unit_test::suite
|
||||
|
||||
// nodes with a trust line in either direction are network-connected
|
||||
network.connectFromTrust(
|
||||
date::round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
round<milliseconds>(0.2 * parms.ledgerGRANULARITY));
|
||||
|
||||
// Initialize collectors to track statistics to report
|
||||
TxCollector txCollector;
|
||||
|
||||
Reference in New Issue
Block a user