What changed, and why it matters
This is a small cleanup in Bitcoin Core's test suite. It replaces a locally-defined timeout value with a shared class attribute that has the exact same value. The commit message explicitly says it does not change behavior, and the diff confirms that: the same timeout formula is used, just in one place instead of two.
No security action needed. This is a non-functional test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In test/functional/interface_ipc_mining.py, the local variable timeout = 1000.0 * self.options.timeout_factor was removed from two test methods and replaced with self.default_ipc_timeout, which is now initialized in run_test() to the identical expression. The existing self.default_block_wait_options.timeout assignment also now uses the shared attribute. No constants, logic, or runtime behavior changed.
Changed components
test/functional/interface_ipc_mining.pyInspect captured patch +8 / −8
diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py
index 4cd9c17c..5d081a8d 100755
--- a/test/functional/interface_ipc_mining.py
+++ b/test/functional/interface_ipc_mining.py
@@ -131,7 +131,6 @@ class IPCMiningTest(BitcoinTestFramework):
"""Test Mining interface methods."""
self.log.info("Running Mining interface test")
block_hash_size = 32
- timeout = 1000.0 * self.options.timeout_factor # 1000 milliseconds
async def async_routine():
ctx, mining = await make_mining_ctx(self)
@@ -141,19 +140,19 @@ class IPCMiningTest(BitcoinTestFramework):
self.log.debug("Mine a block")
newblockref = (await wait_and_do(
- mining.waitTipChanged(ctx, blockref.result.hash, timeout),
+ mining.waitTipChanged(ctx, blockref.result.hash, self.default_ipc_timeout),
lambda: self.generate(self.nodes[0], 1))).result
assert_equal(len(newblockref.hash), block_hash_size)
assert_equal(newblockref.height, current_block_height + 1)
self.log.debug("Wait for timeout")
- oldblockref = (await mining.waitTipChanged(ctx, newblockref.hash, timeout)).result
+ oldblockref = (await mining.waitTipChanged(ctx, newblockref.hash, self.default_ipc_timeout)).result
assert_equal(len(newblockref.hash), block_hash_size)
assert_equal(oldblockref.hash, newblockref.hash)
assert_equal(oldblockref.height, newblockref.height)
self.log.debug("interrupt() should abort waitTipChanged()")
async def wait_for_tip():
- long_timeout = max(timeout, 60000.0) # at least 1 minute
+ long_timeout = max(self.default_ipc_timeout, 60000.0) # at least 1 minute
result = (await mining.waitTipChanged(ctx, newblockref.hash, long_timeout)).result
# Unlike a timeout, interrupt() returns an empty BlockRef.
assert_equal(len(result.hash), 0)
@@ -197,7 +196,6 @@ class IPCMiningTest(BitcoinTestFramework):
"""Test BlockTemplate interface methods."""
self.log.info("Running BlockTemplate interface test")
block_header_size = 80
- timeout = 1000.0 * self.options.timeout_factor
async def async_routine():
ctx, mining = await make_mining_ctx(self)
@@ -266,7 +264,7 @@ class IPCMiningTest(BitcoinTestFramework):
self.log.debug("Wait for a new template")
waitoptions = self.capnp_modules['mining'].BlockWaitOptions()
- waitoptions.timeout = timeout
+ waitoptions.timeout = self.default_ipc_timeout
waitoptions.feeThreshold = 1
template2 = await wait_and_do(
mining_wait_next_template(template, stack, ctx, waitoptions),
@@ -310,7 +308,7 @@ class IPCMiningTest(BitcoinTestFramework):
self.log.debug("interruptWait should abort the current wait")
async def wait_for_block():
new_waitoptions = self.capnp_modules['mining'].BlockWaitOptions()
- new_waitoptions.timeout = max(timeout, 60000.0) # at least 1 minute
+ new_waitoptions.timeout = max(self.default_ipc_timeout, 60000.0) # at least 1 minute
new_waitoptions.feeThreshold = 1
template7 = await mining_wait_next_template(template6, stack, ctx, new_waitoptions)
assert template7 is None
@@ -702,9 +700,11 @@ class IPCMiningTest(BitcoinTestFramework):
def run_test(self):
self.miniwallet = MiniWallet(self.nodes[0])
+ # Amount of time in milliseconds the test is allowed to wait or be idle before it should fail.
+ self.default_ipc_timeout = 1000.0 * self.options.timeout_factor
self.default_block_create_options = self.capnp_modules['mining'].BlockCreateOptions()
self.default_block_wait_options = self.capnp_modules['mining'].BlockWaitOptions()
- self.default_block_wait_options.timeout = 1000.0 * self.options.timeout_factor
+ self.default_block_wait_options.timeout = self.default_ipc_timeout
self.default_block_wait_options.feeThreshold = 1
self.run_mining_interface_test()
self.run_early_startup_test()
Why this scored 15/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.