test: Add coverage for restarted node without any block sync
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's test suite. It checks that a node can be stopped and restarted safely even if it has never synced or generated any blocks, including with optional indexes enabled. There is no change to production code, no bug fix, and no security-relevant behavior change.
No action needed. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/feature_init.py. It switches the test to use a clean chain and two nodes, generates 200 blocks on node 0 for the existing stress test, and adds a new init_empty_test() that restarts node 1 with default options and with all optional indexes enabled. This is purely additional test coverage for node initialization/restart paths.
Changed components
test/functional/feature_init.pyInspect captured patch +15 / −3
diff --git a/test/functional/feature_init.py b/test/functional/feature_init.py
index f3572013..332e5e3b 100755
--- a/test/functional/feature_init.py
+++ b/test/functional/feature_init.py
@@ -26,8 +26,8 @@ class InitTest(BitcoinTestFramework):
"""
def set_test_params(self):
- self.setup_clean_chain = False
- self.num_nodes = 1
+ self.setup_clean_chain = True
+ self.num_nodes = 2
self.uses_wallet = None
def init_stress_test(self):
@@ -35,8 +35,10 @@ class InitTest(BitcoinTestFramework):
- test terminating initialization after seeing a certain log line.
- test removing certain essential files to test startup error paths.
"""
- self.stop_node(0)
+ self.start_node(0)
node = self.nodes[0]
+ self.generate(node, 200, sync_fun=self.no_op)
+ self.stop_node(0)
def sigterm_node():
if platform.system() == 'Windows':
@@ -290,10 +292,20 @@ class InitTest(BitcoinTestFramework):
assert_equal(result["height"], current_height)
node.wait_until_stopped()
+ def init_empty_test(self):
+ self.log.info("Test that stopping and restarting a node that has done nothing is not causing a failure")
+ options = [
+ [],
+ ["-txindex=1", "-blockfilterindex=1", "-coinstatsindex=1"],
+ ]
+ for option in options:
+ self.restart_node(1, option)
+
def run_test(self):
self.init_pid_test()
self.init_stress_test()
self.break_wait_test()
+ self.init_empty_test()
if __name__ == '__main__':
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.