Skip to content

Commit ff4cd60

Browse files
author
MarcoFalke
committed
Merge #11319: [qa] Fix error introduced into p2p-segwit.py, and prevent future similar errors
f97ab35 qa: Fix bug introduced in p2p-segwit.py (Suhas Daftuar) a782042 qa: Treat mininode p2p exceptions as fatal (Suhas Daftuar) Pull request description: #11121 inadvertently broke the constructor for the `TestNode()` object in `p2p-segwit.py`, silently breaking at least one of the tests. Although the python code was raising exceptions due to a `TestNode()` object not existing (or having the right type), mininode was masking these from anyone running the test through the test_runner (like travis), because it catches all exceptions during message delivery and just prints a log message and continues. Such "graceful" handling of errors is almost certainly something we don't want in our test suite, so the first commit here attempts to prevent that type of failure from ever being masked. The second commit fixes the particular bug in `p2p-segwit.py`. Tree-SHA512: b6646e3cb1e05c35c28e8899c44104bf2e2d0384643ca87042ab7f6ec0960d89f5bf25a7b95bab6e32d401c20a6018226160500f6ddceb923e81ffb04adb4f2f
2 parents 9c3c9cd + f97ab35 commit ff4cd60

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

test/functional/p2p-segwit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def get_virtual_size(witness_block):
3232
return vsize
3333

3434
class TestNode(NodeConnCB):
35-
def set_test_params(self):
36-
self.num_nodes = 3
35+
def __init__(self):
36+
super().__init__()
3737
self.getdataset = set()
3838

3939
def on_getdata(self, conn, message):

test/functional/test_framework/mininode.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,7 @@ def deliver(self, conn, message):
15021502
except:
15031503
print("ERROR delivering %s (%s)" % (repr(message),
15041504
sys.exc_info()[0]))
1505+
raise
15051506

15061507
def get_deliver_sleep_time(self):
15071508
with mininode_lock:
@@ -1702,13 +1703,10 @@ def handle_close(self):
17021703
self.cb.on_close(self)
17031704

17041705
def handle_read(self):
1705-
try:
1706-
t = self.recv(8192)
1707-
if len(t) > 0:
1708-
self.recvbuf += t
1709-
self.got_data()
1710-
except:
1711-
pass
1706+
t = self.recv(8192)
1707+
if len(t) > 0:
1708+
self.recvbuf += t
1709+
self.got_data()
17121710

17131711
def readable(self):
17141712
return True
@@ -1774,8 +1772,10 @@ def got_data(self):
17741772
self.got_message(t)
17751773
else:
17761774
logger.warning("Received unknown command from %s:%d: '%s' %s" % (self.dstaddr, self.dstport, command, repr(msg)))
1775+
raise ValueError("Unknown command: '%s'" % (command))
17771776
except Exception as e:
17781777
logger.exception('got_data:', repr(e))
1778+
raise
17791779

17801780
def send_message(self, message, pushbuf=False):
17811781
if self.state != "connected" and not pushbuf:

0 commit comments

Comments
 (0)