Override the current time with a fixed timestamp for testing.

Synopsis

Declared in <kernel/bitcoinkernel.h>

[[nodiscard]]
int
btck_set_mock_time(int64_t timestamp);

Description

Affects all kernel time reads globally. The caller is responsible for gating usage (e.g. restricting to regtest) if desired.

The upper bound (4294967295) matches the maximum value of a block header timestamp.

Return Value

0 on success, non‐zero if timestamp is outside the valid [0, 4294967295]range.

Note

The return value should not be discarded.

Parameters

Name

Description

timestamp [in]

Unix epoch seconds, or 0 to restore the system clock.

Created with MrDocs