test: verify createNewBlock wakes promptly when tip advances
What changed, and why it matters
This commit adds a new automated test to Bitcoin Core. It checks that a mining-related function called createNewBlock() wakes up quickly when a new block is submitted, instead of waiting for an internal cooldown timer. There is no code change to the actual Bitcoin node software—only a new test in the test suite.
No security action needed. This is a test-only change improving coverage for mining IPC behavior.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a functional test case in test/functional/interface_ipc_mining.py. It uses an async wait_and_do helper to run createNewBlock() concurrently with a submitblock() call that advances the chain tip. The test asserts that createNewBlock() returns promptly (under 3 seconds with normal timeout factor) after the tip advances, rather than sleeping until the cooldown expires. No production code is modified.
Changed components
test/functional/interface_ipc_mining.pyInspect captured patch +19 / −0
diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py
index bcb7f5f5..67f77fee 100755
--- a/test/functional/interface_ipc_mining.py
+++ b/test/functional/interface_ipc_mining.py
@@ -199,6 +199,25 @@ class IPCMiningTest(BitcoinTestFramework):
# spurious failures.
assert_greater_than_or_equal(time.time() - start, 0.9)
+ self.log.debug("createNewBlock() should wake up promptly after tip advances")
+ success = False
+ duration = 0.0
+ async def wait_fn():
+ nonlocal success, duration
+ start = time.time()
+ res = await mining.createNewBlock(ctx, self.default_block_create_options)
+ duration = time.time() - start
+ success = res._has("result")
+ def do_fn():
+ block_hex = self.nodes[1].getblock(node1_block_hash, False)
+ self.nodes[0].submitblock(block_hex)
+ await wait_and_do(wait_fn(), do_fn)
+ assert_equal(success, True)
+ if self.options.timeout_factor <= 1:
+ assert duration < 3.0, f"createNewBlock took {duration:.2f}s, did not wake up promptly after tip advances"
+ else:
+ self.log.debug("Skipping strict wake-up duration check because timeout_factor > 1")
+
self.log.debug("interrupt() should abort createNewBlock() during cooldown")
async def create_block():
result = await mining.createNewBlock(ctx, self.default_block_create_options)
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.