mining: handle negative and NaN wait timeouts

bitcoin/bitcoin: PR #36940

1 suggestion

Optional improvements

Link

[suggestion] · The waitNext test misses the extra NaN wait tick

Removing the waitNext timeout normalization would leave the new assertions passing, allowing the one-second NaN delay to return unnoticed.

Location: test/functional/interface_ipc_mining.py:344 (head).

Details and suggested fix

With template6 on the unchanged tip and feeThreshold = MAX_MONEY, the base implementation returns None without logging CreateNewBlock() for both inputs. For NaN, std::min(now + tick, deadline) selects the one-second tick; afterward, now < deadline is false and the loop exits. A negative timeout already returns promptly at base. Neither mining_wait_next_template nor assert_debug_log bounds the call's elapsed time, so these assertions cannot detect removal of the clamp.

Time the calls with time.monotonic() and assert completion comfortably below one second, for example < 0.5 seconds when self.options.timeout_factor <= 1, following the existing timing-check gate. Keep MAX_MONEY to exclude template-construction cost from the measurement.


Coverage details