Remove duplicate method definitions in NodeConnCB subclasses

All Node classes in individual test cases subclass from NodeConnCB. Many
have duplicate definitions for methods that are defined in the base
class. This commit removes those duplicate definitions.

This commit removes ~290 lines of duplicate code.
This commit is contained in:
John Newbery
2017-03-30 08:38:46 -04:00
parent 52e15aa4d0
commit 2a52ae63bf
12 changed files with 144 additions and 451 deletions

View File

@ -20,17 +20,9 @@ banscore = 10
class CLazyNode(NodeConnCB):
def __init__(self):
super().__init__()
self.connection = None
self.unexpected_msg = False
self.connected = False
self.ever_connected = False
def add_connection(self, conn):
self.connection = conn
def send_message(self, message):
self.connection.send_message(message)
def bad_message(self, message):
self.unexpected_msg = True
self.log.info("should not have received message: %s" % message.command)
@ -65,9 +57,6 @@ class CLazyNode(NodeConnCB):
# Node that never sends a version. We'll use this to send a bunch of messages
# anyway, and eventually get disconnected.
class CNodeNoVersionBan(CLazyNode):
def __init__(self):
super().__init__()
# send a bunch of veracks without sending a message. This should get us disconnected.
# NOTE: implementation-specific check here. Remove if bitcoind ban behavior changes
def on_open(self, conn):