Browse Source

[tests] address review comments

0.16
John Newbery 7 years ago
parent
commit
9d42cc3331
  1. 17
      test/functional/sendheaders.py

17
test/functional/sendheaders.py

@ -6,9 +6,11 @@
Setup: Setup:
- Two nodes, two p2p connections to node0. One p2p connection should only ever - Two nodes:
receive inv's (omitted from testing description below, this is our control). - node0 is the node-under-test. We create two p2p connections to it. The
Second node is used for creating reorgs. first p2p connection is a control and should only ever receive inv's. The
second p2p connection tests the headers sending logic.
- node1 is used to create reorgs.
test_null_locators test_null_locators
================== ==================
@ -143,7 +145,9 @@ class BaseNode(NodeConnCB):
self.send_message(getblocks_message) self.send_message(getblocks_message)
def wait_for_getdata(self, hash_list, timeout=60): def wait_for_getdata(self, hash_list, timeout=60):
if hash_list != []: if hash_list == []:
return
test_function = lambda: "getdata" in self.last_message and [x.hash for x in self.last_message["getdata"].inv] == hash_list test_function = lambda: "getdata" in self.last_message and [x.hash for x in self.last_message["getdata"].inv] == hash_list
wait_until(test_function, timeout=timeout, lock=mininode_lock) wait_until(test_function, timeout=timeout, lock=mininode_lock)
@ -229,8 +233,8 @@ class SendHeadersTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Setup the p2p connections and start up the network thread. # Setup the p2p connections and start up the network thread.
inv_node = self.nodes[0].add_p2p_connection(BaseNode()) inv_node = self.nodes[0].add_p2p_connection(BaseNode())
# Set nServices to 0 for test_node, so no block download will occur outside of # Make sure NODE_NETWORK is not set for test_node, so no block download
# direct fetching # will occur outside of direct fetching
test_node = self.nodes[0].add_p2p_connection(BaseNode(), services=NODE_WITNESS) test_node = self.nodes[0].add_p2p_connection(BaseNode(), services=NODE_WITNESS)
NetworkThread().start() # Start up network handling in another thread NetworkThread().start() # Start up network handling in another thread
@ -269,7 +273,6 @@ class SendHeadersTest(BitcoinTestFramework):
inv_node.clear_last_announcement() inv_node.clear_last_announcement()
test_node.send_message(msg_block(block)) test_node.send_message(msg_block(block))
inv_node.check_last_announcement(inv=[int(block.hash, 16)], headers=[]) inv_node.check_last_announcement(inv=[int(block.hash, 16)], headers=[])
inv_node.clear_last_announcement()
def test_nonnull_locators(self, test_node, inv_node): def test_nonnull_locators(self, test_node, inv_node):
tip = int(self.nodes[0].getbestblockhash(), 16) tip = int(self.nodes[0].getbestblockhash(), 16)

Loading…
Cancel
Save