|
6 | 6 |
|
7 | 7 | Setup:
|
8 | 8 |
|
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. |
12 | 14 |
|
13 | 15 | test_null_locators
|
14 | 16 | ==================
|
@@ -143,9 +145,11 @@ def send_getblocks(self, locator):
|
143 | 145 | self.send_message(getblocks_message)
|
144 | 146 |
|
145 | 147 | 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) |
149 | 153 |
|
150 | 154 | def wait_for_block_announcement(self, block_hash, timeout=60):
|
151 | 155 | test_function = lambda: self.last_blockhash_announced == block_hash
|
@@ -229,8 +233,8 @@ def mine_reorg(self, length):
|
229 | 233 | def run_test(self):
|
230 | 234 | # Setup the p2p connections and start up the network thread.
|
231 | 235 | 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 |
234 | 238 | test_node = self.nodes[0].add_p2p_connection(BaseNode(), services=NODE_WITNESS)
|
235 | 239 |
|
236 | 240 | NetworkThread().start() # Start up network handling in another thread
|
@@ -269,7 +273,6 @@ def test_null_locators(self, test_node, inv_node):
|
269 | 273 | inv_node.clear_last_announcement()
|
270 | 274 | test_node.send_message(msg_block(block))
|
271 | 275 | inv_node.check_last_announcement(inv=[int(block.hash, 16)], headers=[])
|
272 |
| - inv_node.clear_last_announcement() |
273 | 276 |
|
274 | 277 | def test_nonnull_locators(self, test_node, inv_node):
|
275 | 278 | tip = int(self.nodes[0].getbestblockhash(), 16)
|
|
0 commit comments