Browse Source

Merge #11319: [qa] Fix error introduced into p2p-segwit.py, and prevent future similar errors

f97ab35fa qa: Fix bug introduced in p2p-segwit.py (Suhas Daftuar)
a7820422e 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
0.16
MarcoFalke 7 years ago
parent
commit
ff4cd6075b
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25
  1. 4
      test/functional/p2p-segwit.py
  2. 6
      test/functional/test_framework/mininode.py

4
test/functional/p2p-segwit.py

@ -32,8 +32,8 @@ def get_virtual_size(witness_block):
return vsize return vsize
class TestNode(NodeConnCB): class TestNode(NodeConnCB):
def set_test_params(self): def __init__(self):
self.num_nodes = 3 super().__init__()
self.getdataset = set() self.getdataset = set()
def on_getdata(self, conn, message): def on_getdata(self, conn, message):

6
test/functional/test_framework/mininode.py

@ -1502,6 +1502,7 @@ class NodeConnCB(object):
except: except:
print("ERROR delivering %s (%s)" % (repr(message), print("ERROR delivering %s (%s)" % (repr(message),
sys.exc_info()[0])) sys.exc_info()[0]))
raise
def get_deliver_sleep_time(self): def get_deliver_sleep_time(self):
with mininode_lock: with mininode_lock:
@ -1702,13 +1703,10 @@ class NodeConn(asyncore.dispatcher):
self.cb.on_close(self) self.cb.on_close(self)
def handle_read(self): def handle_read(self):
try:
t = self.recv(8192) t = self.recv(8192)
if len(t) > 0: if len(t) > 0:
self.recvbuf += t self.recvbuf += t
self.got_data() self.got_data()
except:
pass
def readable(self): def readable(self):
return True return True
@ -1774,8 +1772,10 @@ class NodeConn(asyncore.dispatcher):
self.got_message(t) self.got_message(t)
else: else:
logger.warning("Received unknown command from %s:%d: '%s' %s" % (self.dstaddr, self.dstport, command, repr(msg))) logger.warning("Received unknown command from %s:%d: '%s' %s" % (self.dstaddr, self.dstport, command, repr(msg)))
raise ValueError("Unknown command: '%s'" % (command))
except Exception as e: except Exception as e:
logger.exception('got_data:', repr(e)) logger.exception('got_data:', repr(e))
raise
def send_message(self, message, pushbuf=False): def send_message(self, message, pushbuf=False):
if self.state != "connected" and not pushbuf: if self.state != "connected" and not pushbuf:

Loading…
Cancel
Save