Skip to content

Commit 9d42cc3

Browse files
committed
[tests] address review comments
1 parent f0c4ab9 commit 9d42cc3

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/functional/sendheaders.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
77
Setup:
88
9-
- Two nodes, two p2p connections to node0. One p2p connection should only ever
10-
receive inv's (omitted from testing description below, this is our control).
11-
Second node is used for creating reorgs.
9+
- Two nodes:
10+
- node0 is the node-under-test. We create two p2p connections to it. The
11+
first p2p connection is a control and should only ever receive inv's. The
12+
second p2p connection tests the headers sending logic.
13+
- node1 is used to create reorgs.
1214
1315
test_null_locators
1416
==================
@@ -143,9 +145,11 @@ def send_getblocks(self, locator):
143145
self.send_message(getblocks_message)
144146

145147
def wait_for_getdata(self, hash_list, timeout=60):
146-
if hash_list != []:
147-
test_function = lambda: "getdata" in self.last_message and [x.hash for x in self.last_message["getdata"].inv] == hash_list
148-
wait_until(test_function, timeout=timeout, lock=mininode_lock)
148+
if hash_list == []:
149+
return
150+
151+
test_function = lambda: "getdata" in self.last_message and [x.hash for x in self.last_message["getdata"].inv] == hash_list
152+
wait_until(test_function, timeout=timeout, lock=mininode_lock)
149153

150154
def wait_for_block_announcement(self, block_hash, timeout=60):
151155
test_function = lambda: self.last_blockhash_announced == block_hash
@@ -229,8 +233,8 @@ def mine_reorg(self, length):
229233
def run_test(self):
230234
# Setup the p2p connections and start up the network thread.
231235
inv_node = self.nodes[0].add_p2p_connection(BaseNode())
232-
# Set nServices to 0 for test_node, so no block download will occur outside of
233-
# direct fetching
236+
# Make sure NODE_NETWORK is not set for test_node, so no block download
237+
# will occur outside of direct fetching
234238
test_node = self.nodes[0].add_p2p_connection(BaseNode(), services=NODE_WITNESS)
235239

236240
NetworkThread().start() # Start up network handling in another thread
@@ -269,7 +273,6 @@ def test_null_locators(self, test_node, inv_node):
269273
inv_node.clear_last_announcement()
270274
test_node.send_message(msg_block(block))
271275
inv_node.check_last_announcement(inv=[int(block.hash, 16)], headers=[])
272-
inv_node.clear_last_announcement()
273276

274277
def test_nonnull_locators(self, test_node, inv_node):
275278
tip = int(self.nodes[0].getbestblockhash(), 16)

0 commit comments

Comments
 (0)