mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Update chrono types
Conflicts: src/ripple/test/jtx/impl/Env.cpp
This commit is contained in:
@@ -39,19 +39,6 @@ using weeks = std::chrono::duration
|
||||
<int, std::ratio_multiply<
|
||||
days::period, std::ratio<7>>>;
|
||||
|
||||
/** A clock for measuring elapsed time.
|
||||
|
||||
The epoch is unspecified.
|
||||
*/
|
||||
using Stopwatch =
|
||||
beast::abstract_clock<
|
||||
std::chrono::steady_clock>;
|
||||
|
||||
/** A manual clock for unit tests. */
|
||||
using TestClock =
|
||||
beast::manual_clock<
|
||||
Stopwatch::clock_type>;
|
||||
|
||||
/** Clock for measuring Ripple Network Time.
|
||||
|
||||
The epoch is January 1, 2000
|
||||
@@ -77,9 +64,40 @@ public:
|
||||
std::chrono::time_point<
|
||||
NetClock, duration>;
|
||||
|
||||
// VFALCO now() intentionally omitted for the moment
|
||||
static bool const /* constexpr? */ is_steady =
|
||||
std::chrono::system_clock::is_steady;
|
||||
|
||||
static
|
||||
time_point
|
||||
now()
|
||||
{
|
||||
using namespace std;
|
||||
auto const when =
|
||||
chrono::system_clock::now();
|
||||
return time_point(
|
||||
chrono::duration_cast<duration>(
|
||||
when.time_since_epoch() -
|
||||
days(10957)));
|
||||
}
|
||||
};
|
||||
|
||||
/** A manual NetClock for unit tests. */
|
||||
using TestNetClock =
|
||||
beast::manual_clock<NetClock>;
|
||||
|
||||
/** A clock for measuring elapsed time.
|
||||
|
||||
The epoch is unspecified.
|
||||
*/
|
||||
using Stopwatch =
|
||||
beast::abstract_clock<
|
||||
std::chrono::steady_clock>;
|
||||
|
||||
/** A manual Stopwatch for unit tests. */
|
||||
using TestStopwatch =
|
||||
beast::manual_clock<
|
||||
std::chrono::steady_clock>;
|
||||
|
||||
/** Returns an instance of a wall clock. */
|
||||
inline
|
||||
Stopwatch&
|
||||
|
||||
@@ -30,7 +30,7 @@ class KeyCache_test : public beast::unit_test::suite
|
||||
public:
|
||||
void run ()
|
||||
{
|
||||
TestClock clock;
|
||||
TestStopwatch clock;
|
||||
clock.set (0);
|
||||
|
||||
using Key = std::string;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
{
|
||||
beast::Journal const j;
|
||||
|
||||
TestClock clock;
|
||||
TestStopwatch clock;
|
||||
clock.set (0);
|
||||
|
||||
using Key = int;
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
Params m_params;
|
||||
Journal m_journal;
|
||||
int m_next_node_id;
|
||||
TestClock m_clock;
|
||||
TestNetClock m_clock;
|
||||
Peers m_nodes;
|
||||
Table m_table;
|
||||
FunctionQueue m_queue;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace PeerFinder {
|
||||
class Livecache_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
TestClock m_clock;
|
||||
TestStopwatch m_clock;
|
||||
|
||||
// Add the address as an endpoint
|
||||
template <class C>
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
testcase("backoff 1");
|
||||
TestStore store;
|
||||
TestChecker checker;
|
||||
TestClock clock;
|
||||
TestStopwatch clock;
|
||||
Logic<TestChecker> logic (clock, store, checker, beast::Journal{});
|
||||
logic.addFixedPeer ("test",
|
||||
beast::IP::Endpoint::from_string("65.0.0.1:5"));
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
testcase("backoff 2");
|
||||
TestStore store;
|
||||
TestChecker checker;
|
||||
TestClock clock;
|
||||
TestStopwatch clock;
|
||||
Logic<TestChecker> logic (clock, store, checker, beast::Journal{});
|
||||
logic.addFixedPeer ("test",
|
||||
beast::IP::Endpoint::from_string("65.0.0.1:5"));
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/resource/Gossip.h>
|
||||
#include <ripple/resource/impl/Import.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/basics/UnorderedContainers.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
@@ -37,7 +38,7 @@ namespace Resource {
|
||||
class Logic
|
||||
{
|
||||
private:
|
||||
using clock_type = beast::abstract_clock <std::chrono::steady_clock>;
|
||||
using clock_type = Stopwatch;
|
||||
using Imports = hash_map <std::string, Import>;
|
||||
using Table = hash_map <Key, Entry, Key::hasher, Key::key_equal>;
|
||||
using EntryIntrusiveList = beast::List <Entry>;
|
||||
@@ -83,7 +84,7 @@ private:
|
||||
|
||||
SharedState m_state;
|
||||
Stats m_stats;
|
||||
beast::abstract_clock <std::chrono::steady_clock>& m_clock;
|
||||
Stopwatch& m_clock;
|
||||
beast::Journal m_journal;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -31,13 +31,13 @@ class Manager_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
class TestLogic
|
||||
: private boost::base_from_member<TestClock>
|
||||
: private boost::base_from_member<TestStopwatch>
|
||||
, public Logic
|
||||
|
||||
{
|
||||
private:
|
||||
using clock_type =
|
||||
boost::base_from_member<TestClock>;
|
||||
boost::base_from_member<TestStopwatch>;
|
||||
|
||||
public:
|
||||
explicit TestLogic (beast::Journal journal)
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
++member;
|
||||
}
|
||||
|
||||
TestClock& clock ()
|
||||
TestStopwatch& clock ()
|
||||
{
|
||||
return member;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace tests {
|
||||
class TestFamily : public shamap::Family
|
||||
{
|
||||
private:
|
||||
TestClock clock_;
|
||||
TestStopwatch clock_;
|
||||
NodeStore::DummyScheduler scheduler_;
|
||||
TreeNodeCache treecache_;
|
||||
FullBelowCache fullbelow_;
|
||||
|
||||
@@ -117,7 +117,7 @@ noripple (Account const& account,
|
||||
class Env
|
||||
{
|
||||
public:
|
||||
using clock_type = TestClock;
|
||||
using clock_type = TestNetClock;
|
||||
|
||||
clock_type clock;
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
The Env clock is set to the new time.
|
||||
*/
|
||||
void
|
||||
close (TestClock::time_point const& closeTime);
|
||||
close (NetClock::time_point const& closeTime);
|
||||
|
||||
/** Close and advance the ledger.
|
||||
|
||||
@@ -193,6 +193,7 @@ public:
|
||||
close (std::chrono::duration<
|
||||
Rep, Period> const& elapsed)
|
||||
{
|
||||
stopwatch_.advance(elapsed);
|
||||
close (clock.now() + elapsed);
|
||||
}
|
||||
|
||||
@@ -443,6 +444,7 @@ public:
|
||||
protected:
|
||||
int trace_ = 0;
|
||||
bool testing_ = true;
|
||||
TestStopwatch stopwatch_;
|
||||
|
||||
void
|
||||
autofill_sig (JTx& jt);
|
||||
|
||||
@@ -58,7 +58,7 @@ Env::Env (beast::unit_test::suite& test_)
|
||||
generateSeed("masterpassphrase")))
|
||||
, closed_ (std::make_shared<Ledger>(
|
||||
create_genesis, config))
|
||||
, cachedSLEs_ (std::chrono::seconds(5), clock)
|
||||
, cachedSLEs_ (std::chrono::seconds(5), stopwatch_)
|
||||
, openLedger (closed_, config, cachedSLEs_, journal)
|
||||
{
|
||||
memoize(master);
|
||||
@@ -78,8 +78,7 @@ Env::closed() const
|
||||
}
|
||||
|
||||
void
|
||||
Env::close(
|
||||
TestClock::time_point const& closeTime)
|
||||
Env::close(NetClock::time_point const& closeTime)
|
||||
{
|
||||
clock.set(closeTime);
|
||||
// VFALCO TODO Fix the Ledger constructor
|
||||
@@ -111,10 +110,12 @@ Env::close(
|
||||
config, journal);
|
||||
accum.apply(*next);
|
||||
}
|
||||
next->setAccepted(
|
||||
closeTime.time_since_epoch().count(),
|
||||
ledgerPossibleTimeResolutions[0],
|
||||
true);
|
||||
// To ensure that the close time is exact and not rounded, we don't
|
||||
// claim to have reached consensus on what it should be.
|
||||
next->setAccepted (
|
||||
std::chrono::duration_cast<std::chrono::seconds> (
|
||||
closeTime.time_since_epoch ()).count (),
|
||||
ledgerPossibleTimeResolutions[0], false);
|
||||
OrderedTxs locals({});
|
||||
openLedger.accept(next, locals,
|
||||
false, retries, applyFlags(), *router);
|
||||
|
||||
Reference in New Issue
Block a user