Skip to content

Commit 47a7a16

Browse files
committed
[util] Introduce a SetMockTime that takes chrono time
1 parent df6a5fc commit 47a7a16

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/util/time.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ void SetMockTime(int64_t nMockTimeIn)
5353
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
5454
}
5555

56+
void SetMockTime(std::chrono::seconds mock_time_in)
57+
{
58+
nMockTime.store(mock_time_in.count(), std::memory_order_relaxed);
59+
}
60+
5661
std::chrono::seconds GetMockTime()
5762
{
5863
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed));

src/util/time.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
4646
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
4747
void SetMockTime(int64_t nMockTimeIn);
4848

49+
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
50+
void SetMockTime(std::chrono::seconds mock_time_in);
51+
4952
/** For testing */
5053
std::chrono::seconds GetMockTime();
5154

0 commit comments

Comments
 (0)