From 4ada575d6c6880f7d302c1f37581a82f394c0b5e Mon Sep 17 00:00:00 2001 From: Enoch Azariah Date: Wed, 4 Mar 2026 00:25:51 +0100 Subject: [PATCH] test: verify createNewBlock wakes promptly when tip advances This adds a complementary test to interface_ipc_mining.py to ensure that createNewBlock() wakes up immediately once submitblock advances the tip, rather than needlessly waiting for the cooldown timer to expire on its own. --- test/functional/interface_ipc_mining.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py index bcb7f5f5d86..67f77fee5f7 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)