diff options
author | John Newbery <john@johnnewbery.com> | 2017-11-17 15:01:24 -0500 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-11-28 12:44:16 -0500 |
commit | dad596fc37c8733ab806a0aa4224ac437d37aee5 (patch) | |
tree | bf014d46fb9d4e0ae865756c422000914dc9c314 /test/functional/sendheaders.py | |
parent | e30d404385f46811eeeea05c55ef786bc4adcb77 (diff) |
[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.
Diffstat (limited to 'test/functional/sendheaders.py')
-rwxr-xr-x | test/functional/sendheaders.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/functional/sendheaders.py b/test/functional/sendheaders.py index 68c0d95b4f..b589d0e8a5 100755 --- a/test/functional/sendheaders.py +++ b/test/functional/sendheaders.py @@ -113,6 +113,7 @@ DIRECT_FETCH_RESPONSE_TIME = 0.05 class BaseNode(NodeConnCB): def __init__(self): super().__init__() + self.block_announced = False self.last_blockhash_announced = None @@ -121,18 +122,18 @@ class BaseNode(NodeConnCB): msg = msg_getdata() for x in block_hashes: msg.inv.append(CInv(2, x)) - self.connection.send_message(msg) + self.send_message(msg) def send_get_headers(self, locator, hashstop): msg = msg_getheaders() msg.locator.vHave = locator msg.hashstop = hashstop - self.connection.send_message(msg) + self.send_message(msg) def send_block_inv(self, blockhash): msg = msg_inv() msg.inv = [CInv(2, blockhash)] - self.connection.send_message(msg) + self.send_message(msg) def send_header_for_blocks(self, new_blocks): headers_message = msg_headers() @@ -155,11 +156,11 @@ class BaseNode(NodeConnCB): test_function = lambda: self.last_blockhash_announced == block_hash wait_until(test_function, timeout=timeout, lock=mininode_lock) - def on_inv(self, conn, message): + def on_inv(self, message): self.block_announced = True self.last_blockhash_announced = message.inv[-1].hash - def on_headers(self, conn, message): + def on_headers(self, message): if len(message.headers): self.block_announced = True message.headers[-1].calc_sha256() |