Skip to content

Commit

Permalink
Merge bitcoin#11319: [qa] Fix error introduced into p2p-segwit.py, an…
Browse files Browse the repository at this point in the history
…d 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:

  bitcoin#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
  • Loading branch information
MarcoFalke committed Sep 29, 2017
2 parents 9c3c9cd + f97ab35 commit ff4cd60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/functional/p2p-segwit.py
Expand Up @@ -32,8 +32,8 @@ def get_virtual_size(witness_block):
return vsize

class TestNode(NodeConnCB):
def set_test_params(self):
self.num_nodes = 3
def __init__(self):
super().__init__()
self.getdataset = set()

def on_getdata(self, conn, message):
Expand Down
14 changes: 7 additions & 7 deletions test/functional/test_framework/mininode.py
Expand Up @@ -1502,6 +1502,7 @@ def deliver(self, conn, message):
except:
print("ERROR delivering %s (%s)" % (repr(message),
sys.exc_info()[0]))
raise

def get_deliver_sleep_time(self):
with mininode_lock:
Expand Down Expand Up @@ -1702,13 +1703,10 @@ def handle_close(self):
self.cb.on_close(self)

def handle_read(self):
try:
t = self.recv(8192)
if len(t) > 0:
self.recvbuf += t
self.got_data()
except:
pass
t = self.recv(8192)
if len(t) > 0:
self.recvbuf += t
self.got_data()

def readable(self):
return True
Expand Down Expand Up @@ -1774,8 +1772,10 @@ def got_data(self):
self.got_message(t)
else:
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:
logger.exception('got_data:', repr(e))
raise

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

0 comments on commit ff4cd60

Please sign in to comment.