Skip to content

Commit 6d973f8

Browse files
committed
Merge bitcoin/bitcoin#31408: test: Avoid logging error when logging error
cccca8a test: Avoid logging error when logging error (MarcoFalke) Pull request description: Currently a logging error in the form of `--- Logging error ---` happens when an error is logged in the `_on_data` helper. Fix it by properly logging the error. Also, treat pylint errors as errors, to avoid this problem in the future. Can be tested by running `p2p_addrv2_relay.py` with the following example diff: ```diff diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 523e1bd..0f1eb29d13 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -137,7 +137,7 @@ MESSAGEMAP = { b"notfound": msg_notfound, b"ping": msg_ping, b"pong": msg_pong, - b"sendaddrv2": msg_sendaddrv2, + #b"sendaddrv2": msg_sendaddrv2, b"sendcmpct": msg_sendcmpct, b"sendheaders": msg_sendheaders, b"sendtxrcncl": msg_sendtxrcncl, ACKs for top commit: fanquake: ACK cccca8a Tree-SHA512: dd19f3feed0093246cb205903529fb9ebd5ad9a6c9330cfc5987c0154253c9dcec8d0e25ff99e4ac806a464ff58c3787a205378b8dfb7a1a521da25eac429136
2 parents 6a1e613 + cccca8a commit 6d973f8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

test/functional/test_framework/p2p.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# Copyright (c) 2010 ArtForz -- public domain half-a-node
33
# Copyright (c) 2012 Jeff Garzik
4-
# Copyright (c) 2010-2022 The Bitcoin Core developers
4+
# Copyright (c) 2010-present The Bitcoin Core developers
55
# Distributed under the MIT software license, see the accompanying
66
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
77
"""Test objects for interacting with a bitcoind node over the p2p protocol.
@@ -369,7 +369,7 @@ def _on_data(self):
369369
self.on_message(t)
370370
except Exception as e:
371371
if not self.reconnect:
372-
logger.exception('Error reading message:', repr(e))
372+
logger.exception(f"Error reading message: {repr(e)}")
373373
raise
374374

375375
def on_message(self, message):
@@ -659,7 +659,7 @@ def wait_for_getheaders(self, block_hash=None, *, timeout=60):
659659
def test_function():
660660
last_getheaders = self.last_message.pop("getheaders", None)
661661
if block_hash is None:
662-
return last_getheaders
662+
return last_getheaders
663663
if last_getheaders is None:
664664
return False
665665
return block_hash == last_getheaders.locator.vHave[0]

test/lint/test_runner/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ fn lint_py_lint() -> LintResult {
236236
"F822", // undefined name name in __all__
237237
"F823", // local variable name … referenced before assignment
238238
"F841", // local variable 'foo' is assigned to but never used
239+
"PLE", // Pylint errors
239240
"W191", // indentation contains tabs
240241
"W291", // trailing whitespace
241242
"W292", // no newline at end of file

0 commit comments

Comments
 (0)