MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/feature_init.py:24–125  ·  view source on GitHub ↗

- test terminating initialization after seeing a certain log line. - test removing certain essential files to test startup error paths.

(self)

Source from the content-addressed store, hash-verified

22 self.num_nodes = 1
23
24 def run_test(self):
25 """
26 - test terminating initialization after seeing a certain log line.
27 - test removing certain essential files to test startup error paths.
28 """
29 # TODO: skip Windows for now since it isn't clear how to SIGTERM.
30 #
31 # Windows doesn't support `process.terminate()`.
32 # and other approaches (like below) don't work:
33 #
34 # os.kill(node.process.pid, signal.CTRL_C_EVENT)
35 if os.name == 'nt':
36 raise SkipTest("can't SIGTERM on Windows")
37
38 self.stop_node(0)
39 node = self.nodes[0]
40
41 def sigterm_node():
42 node.process.terminate()
43 node.process.wait()
44
45 def check_clean_start():
46 """Ensure that node restarts successfully after various interrupts."""
47 node.start()
48 node.wait_for_rpc_connection()
49 assert_equal(200, node.getblockcount())
50
51 lines_to_terminate_after = [
52 'Validating signatures for all blocks',
53 'scheduler thread start',
54 'Starting HTTP server',
55 'Loading P2P addresses',
56 'Loading banlist',
57 'Loading block index',
58 'Switching active chainstate',
59 'Checking all blk files are present',
60 'Loaded best chain:',
61 'init message: Verifying blocks',
62 'init message: Starting network threads',
63 'net thread start',
64 'addcon thread start',
65 'loadblk thread start',
66 'txindex thread start',
67 'block filter index thread start',
68 'coinstatsindex thread start',
69 'msghand thread start',
70 'net thread start',
71 'addcon thread start',
72 ]
73 if self.is_wallet_compiled():
74 lines_to_terminate_after.append('Verifying wallet')
75
76 for terminate_line in lines_to_terminate_after:
77 self.log.info(f"Starting node and will exit after line '{terminate_line}'")
78 with node.wait_for_debug_log([terminate_line], ignore_case=True):
79 node.start(extra_args=['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1'])
80 self.log.debug("Terminating node after terminate line was found")
81 sigterm_node()

Callers

nothing calls this directly

Calls 8

SkipTestClass · 0.90
infoMethod · 0.80
wait_for_debug_logMethod · 0.80
stop_nodeMethod · 0.45
is_wallet_compiledMethod · 0.45
startMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected