Skip to content

Commit fa2e614

Browse files
author
MarcoFalke
committed
test: Fix off-by-one in mockscheduler test RPC
1 parent 61fea52 commit fa2e614

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/rpc/misc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ static RPCHelpMan mockscheduler()
424424
// check params are valid values
425425
RPCTypeCheck(request.params, {UniValue::VNUM});
426426
int64_t delta_seconds = request.params[0].get_int64();
427-
if ((delta_seconds <= 0) || (delta_seconds > 3600)) {
427+
if (delta_seconds <= 0 || delta_seconds > 3600) {
428428
throw std::runtime_error("delta_time must be between 1 and 3600 seconds (1 hr)");
429429
}
430430

src/scheduler.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <scheduler.h>
66

77
#include <random.h>
8+
#include <util/time.h>
89

910
#include <assert.h>
1011
#include <functional>
@@ -80,7 +81,7 @@ void CScheduler::schedule(CScheduler::Function f, std::chrono::system_clock::tim
8081

8182
void CScheduler::MockForward(std::chrono::seconds delta_seconds)
8283
{
83-
assert(delta_seconds.count() > 0 && delta_seconds < std::chrono::hours{1});
84+
assert(delta_seconds > 0s && delta_seconds <= 1h);
8485

8586
{
8687
LOCK(newTaskMutex);

0 commit comments

Comments
 (0)