Nit: Could replace the two boolean with a single undo_immutable
, which holds an optional lambda to run. (a no-op by default, and set to None if the test should terminate early, and the respective undo command if an util helper was used?)
This should reduce the number of symbols, and reduce the mix of if-else
vs early-return
. The diff below would look like:
0diff --git a/test/functional/feature_reindex_readonly.py b/test/functional/feature_reindex_readonly.py
1index 26531f472b..77716b371e 100755
2--- a/test/functional/feature_reindex_readonly.py
3+++ b/test/functional/feature_reindex_readonly.py
4@@ -53,12 +53,11 @@ class BlockstoreReindexTest(BitcoinTestFramework):
5 return
6
7 self.log.debug("Attempt to restart and reindex the node with the unwritable block file")
8- with self.nodes[0].assert_debug_log(expected_msgs=['FlushStateToDisk', 'failed to open file'], unexpected_msgs=[]):
9+ if undo_immutable:
10+ with self.nodes[0].assert_debug_log(expected_msgs=['FlushStateToDisk', 'failed to open file'], unexpected_msgs=[]):
11 self.nodes[0].assert_start_raises_init_error(extra_args=['-reindex', '-fastprune'],
12 expected_msg="Error: A fatal internal error occurred, see debug.log for details")
13-
14- if used_chattr:
15- subprocess.check_call(['chattr', '-i', filename])
16+ undo_immutable()
17
18 filename.chmod(0o777)
19