Skip to content

Commit cbde2bc

Browse files
committed
Merge #16804: test: Remove unused try-block in assert_debug_log
fae91a0 test: Remove incorrect and unused try-block in assert_debug_log (MarcoFalke) Pull request description: This try block has accidentally been added by me in fa3e9f7. It was unused all the time, but commit 6011c9d added a `return` in the finally block, muting all exceptions. This can be tested by adding an `assert False` after any `with ...assert_debug_log...:` line. ACKs for top commit: laanwj: ACK fae91a0 ryanofsky: utACK fae91a0. I didn't know returning inside a `finally` block would cancel pending exceptions or return values, but I guess this makes sense and is a good thing to be aware of. Tree-SHA512: 47ed0165062060e9af055a3e92f1a529cd41d00476bfad64e3cd141ae084d22f926a343bb1257717e164e15459a59ab66aed198c95d18bf780d8cb0b76aa3298
2 parents 45be44c + fae91a0 commit cbde2bc

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

test/functional/rpc_setban.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def run_test(self):
2626
self.nodes[1].setban("127.0.0.1", "add")
2727

2828
# Node 0 should not be able to reconnect
29-
with self.nodes[1].assert_debug_log(expected_msgs=['dropped (banned)\n'],timeout=5):
29+
with self.nodes[1].assert_debug_log(expected_msgs=['dropped (banned)\n'], timeout=5):
3030
self.restart_node(1, [])
3131
self.nodes[0].addnode("127.0.0.1:" + str(p2p_port(1)), "onetry")
3232

test/functional/test_framework/test_node.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,24 +313,24 @@ def assert_debug_log(self, expected_msgs, timeout=2):
313313
with open(debug_log, encoding='utf-8') as dl:
314314
dl.seek(0, 2)
315315
prev_size = dl.tell()
316-
try:
317-
yield
318-
finally:
319-
while True:
320-
found = True
321-
with open(debug_log, encoding='utf-8') as dl:
322-
dl.seek(prev_size)
323-
log = dl.read()
324-
print_log = " - " + "\n - ".join(log.splitlines())
325-
for expected_msg in expected_msgs:
326-
if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
327-
found = False
328-
if found:
329-
return
330-
if time.time() >= time_end:
331-
break
332-
time.sleep(0.05)
333-
self._raise_assertion_error('Expected messages "{}" does not partially match log:\n\n{}\n\n'.format(str(expected_msgs), print_log))
316+
317+
yield
318+
319+
while True:
320+
found = True
321+
with open(debug_log, encoding='utf-8') as dl:
322+
dl.seek(prev_size)
323+
log = dl.read()
324+
print_log = " - " + "\n - ".join(log.splitlines())
325+
for expected_msg in expected_msgs:
326+
if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
327+
found = False
328+
if found:
329+
return
330+
if time.time() >= time_end:
331+
break
332+
time.sleep(0.05)
333+
self._raise_assertion_error('Expected messages "{}" does not partially match log:\n\n{}\n\n'.format(str(expected_msgs), print_log))
334334

335335
@contextlib.contextmanager
336336
def assert_memory_usage_stable(self, *, increase_allowed=0.03):

0 commit comments

Comments
 (0)