| 248 | |
| 249 | @contextlib.contextmanager |
| 250 | def assert_debug_log(self, expected_msgs): |
| 251 | debug_log = os.path.join(self.datadir, 'regtest', 'debug.log') |
| 252 | with open(debug_log, encoding='utf-8') as dl: |
| 253 | dl.seek(0, 2) |
| 254 | prev_size = dl.tell() |
| 255 | try: |
| 256 | yield |
| 257 | finally: |
| 258 | with open(debug_log, encoding='utf-8') as dl: |
| 259 | dl.seek(prev_size) |
| 260 | log = dl.read() |
| 261 | print_log = " - " + "\n - ".join(log.splitlines()) |
| 262 | for expected_msg in expected_msgs: |
| 263 | if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None: |
| 264 | self._raise_assertion_error('Expected message "{}" does not partially match log:\n\n{}\n\n'.format(expected_msg, print_log)) |
| 265 | |
| 266 | def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, match=ErrorMatch.FULL_TEXT, *args, **kwargs): |
| 267 | """Attempt to start the node and expect it to raise an error. |