[tests] Make NodeConnCB a subclass of NodeConn

This makes NodeConnCB a subclass of NodeConn, and
removes the need for the client code to know
anything about the implementation details of NodeConnCB.

NodeConn can now be swapped out for any other implementation
of a low-level connection without changing client code.
This commit is contained in:
John Newbery 2017-11-17 15:01:24 -05:00
parent e30d404385
commit dad596fc37
14 changed files with 194 additions and 194 deletions
test/functional

View file

@ -49,14 +49,14 @@ class BaseNode(NodeConnCB):
# Stores a dictionary of all blocks received
self.block_receive_map = defaultdict(int)
def on_block(self, conn, message):
def on_block(self, message):
"""Override the standard on_block callback
Store the hash of a received block in the dictionary."""
message.block.calc_sha256()
self.block_receive_map[message.block.sha256] += 1
def on_inv(self, conn, message):
def on_inv(self, message):
"""Override the standard on_inv callback"""
pass