test: Add missing txospenderindex coverage in feature_init

Also refactors the list of all index args into a constant that can be reused across tests.

Co-authored-by: sedited <seb.kung@gmail.com>
This commit is contained in:
Fabian Jahr 2026-03-05 13:37:13 +01:00
parent a1074d852a
commit f8b9595aaa
No known key found for this signature in database
GPG Key ID: F13D1E9D890798CD

View File

@ -18,6 +18,12 @@ from test_framework.test_node import (
)
from test_framework.util import assert_equal
ALL_INDEX_ARGS = [
'-txindex=1',
'-blockfilterindex=1',
'-coinstatsindex=1',
'-txospenderindex=1',
]
class InitTest(BitcoinTestFramework):
"""
@ -74,6 +80,7 @@ class InitTest(BitcoinTestFramework):
b'txindex thread start',
b'block filter index thread start',
b'coinstatsindex thread start',
b'txospenderindex thread start',
b'msghand thread start',
b'net thread start',
b'addcon thread start',
@ -81,22 +88,21 @@ class InitTest(BitcoinTestFramework):
if self.is_wallet_compiled():
lines_to_terminate_after.append(b'Verifying wallet')
args = ['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1', '-txospenderindex=1']
for terminate_line in lines_to_terminate_after:
self.log.info(f"Starting node and will terminate after line {terminate_line}")
with node.busy_wait_for_debug_log([terminate_line]):
if platform.system() == 'Windows':
# CREATE_NEW_PROCESS_GROUP is required in order to be able
# to terminate the child without terminating the test.
node.start(extra_args=args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
node.start(extra_args=ALL_INDEX_ARGS, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
else:
node.start(extra_args=args)
node.start(extra_args=ALL_INDEX_ARGS)
self.log.debug("Terminating node after terminate line was found")
sigterm_node()
# Prior to deleting/perturbing index files, start node with all indexes enabled.
# 'check_clean_start' will ensure indexes are synchronized (i.e., data exists to modify)
self.check_clean_start(node, args)
self.check_clean_start(node, ALL_INDEX_ARGS)
self.stop_node(0)
def init_stress_test_removals(self):
@ -105,7 +111,6 @@ class InitTest(BitcoinTestFramework):
"""
self.log.info("Test startup errors after removing certain essential files")
node = self.nodes[0]
args = ['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1']
def start_expecting_error(err_fragment, args):
node.assert_start_raises_init_error(
@ -209,7 +214,7 @@ class InitTest(BitcoinTestFramework):
self.log.debug(f"Restoring file from {bak_path} and restarting")
Path(bak_path).rename(target_file)
self.check_clean_start(node, args)
self.check_clean_start(node, ALL_INDEX_ARGS)
self.stop_node(0)
self.log.info("Test startup errors after perturbing certain essential files")
@ -313,7 +318,7 @@ class InitTest(BitcoinTestFramework):
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"],
ALL_INDEX_ARGS,
]
for option in options:
self.restart_node(1, option)