mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-02 01:36:13 +00:00
Merge bitcoin/bitcoin#34241: test: Check that interrupt results in EXIT_SUCCESS
fa16b275fa94f66067c94fb8d0854859df6953b8 test: Check that interrupt results in EXIT_SUCCESS (MarcoFalke) fab7c7f56c1d72178435618c49611a3ecd80b9b8 test: Split large init_stress_test into two smaller functions (MarcoFalke) Pull request description: This is a test for https://github.com/bitcoin/bitcoin/pull/34224. The test can be tested by reverting that pull request and observing the test failure. Also, includes a small test cleanup/refactor. ACKs for top commit: janb84: ACK fa16b275fa94f66067c94fb8d0854859df6953b8 sedited: ACK fa16b275fa94f66067c94fb8d0854859df6953b8 Tree-SHA512: bb6894316fd4f78b3c0cb299cc93abf7f3f794e0507bf7deda7d86f8f45d60299ec0f027c41a6f909c197a1e5fba44fe269ce4165450b89738b82d8ddf196b80
This commit is contained in:
commit
3764746404
@ -30,10 +30,17 @@ class InitTest(BitcoinTestFramework):
|
||||
self.num_nodes = 1
|
||||
self.uses_wallet = None
|
||||
|
||||
def init_stress_test(self):
|
||||
def check_clean_start(self, node, extra_args):
|
||||
"""Ensure that node restarts successfully after various interrupts."""
|
||||
node.start(extra_args)
|
||||
node.wait_for_rpc_connection()
|
||||
height = node.getblockcount()
|
||||
assert_equal(200, height)
|
||||
self.wait_until(lambda: all(i["synced"] and i["best_block_height"] == height for i in node.getindexinfo().values()))
|
||||
|
||||
def init_stress_test_interrupt(self):
|
||||
"""
|
||||
- test terminating initialization after seeing a certain log line.
|
||||
- test removing certain essential files to test startup error paths.
|
||||
"""
|
||||
self.stop_node(0)
|
||||
node = self.nodes[0]
|
||||
@ -46,22 +53,7 @@ class InitTest(BitcoinTestFramework):
|
||||
os.kill(node.process.pid, signal.CTRL_BREAK_EVENT)
|
||||
else:
|
||||
node.process.terminate()
|
||||
node.process.wait()
|
||||
|
||||
def start_expecting_error(err_fragment, args):
|
||||
node.assert_start_raises_init_error(
|
||||
extra_args=args,
|
||||
expected_msg=err_fragment,
|
||||
match=ErrorMatch.PARTIAL_REGEX,
|
||||
)
|
||||
|
||||
def check_clean_start(extra_args):
|
||||
"""Ensure that node restarts successfully after various interrupts."""
|
||||
node.start(extra_args)
|
||||
node.wait_for_rpc_connection()
|
||||
height = node.getblockcount()
|
||||
assert_equal(200, height)
|
||||
self.wait_until(lambda: all(i["synced"] and i["best_block_height"] == height for i in node.getindexinfo().values()))
|
||||
assert_equal(0, node.process.wait())
|
||||
|
||||
lines_to_terminate_after = [
|
||||
b'Validating signatures for all blocks',
|
||||
@ -102,10 +94,23 @@ class InitTest(BitcoinTestFramework):
|
||||
|
||||
# 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)
|
||||
check_clean_start(args)
|
||||
self.check_clean_start(node, args)
|
||||
self.stop_node(0)
|
||||
|
||||
def init_stress_test_removals(self):
|
||||
"""
|
||||
- test removing certain essential files to test startup error paths.
|
||||
"""
|
||||
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(
|
||||
extra_args=args,
|
||||
expected_msg=err_fragment,
|
||||
match=ErrorMatch.PARTIAL_REGEX,
|
||||
)
|
||||
|
||||
deletion_rounds = [
|
||||
{
|
||||
@ -191,7 +196,7 @@ class InitTest(BitcoinTestFramework):
|
||||
self.log.debug(f"Restoring file from {bak_path} and restarting")
|
||||
Path(bak_path).rename(target_file)
|
||||
|
||||
check_clean_start(args)
|
||||
self.check_clean_start(node, args)
|
||||
self.stop_node(0)
|
||||
|
||||
self.log.info("Test startup errors after perturbing certain essential files")
|
||||
@ -292,7 +297,8 @@ class InitTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
self.init_pid_test()
|
||||
self.init_stress_test()
|
||||
self.init_stress_test_interrupt()
|
||||
self.init_stress_test_removals()
|
||||
self.break_wait_test()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user