Skip to content

Commit

Permalink
[util] Introduce a SetMockTime that takes chrono time
Browse files Browse the repository at this point in the history
  • Loading branch information
amitiuttarwar committed Feb 16, 2021
1 parent df6a5fc commit 47a7a16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/util/time.cpp
Expand Up @@ -53,6 +53,11 @@ void SetMockTime(int64_t nMockTimeIn)
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
}

void SetMockTime(std::chrono::seconds mock_time_in)
{
nMockTime.store(mock_time_in.count(), std::memory_order_relaxed);
}

std::chrono::seconds GetMockTime()
{
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed));
Expand Down
3 changes: 3 additions & 0 deletions src/util/time.h
Expand Up @@ -46,6 +46,9 @@ int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
void SetMockTime(int64_t nMockTimeIn);

/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
void SetMockTime(std::chrono::seconds mock_time_in);

/** For testing */
std::chrono::seconds GetMockTime();

Expand Down

0 comments on commit 47a7a16

Please sign in to comment.