|
10 | 10 | receive inv's (omitted from testing description below, this is our control).
|
11 | 11 | Second node is used for creating reorgs.
|
12 | 12 |
|
| 13 | +test_null_locators |
| 14 | +================== |
| 15 | +
|
| 16 | +Sends two getheaders requests with null locator values. First request's hashstop |
| 17 | +value refers to validated block, while second request's hashstop value refers to |
| 18 | +a block which hasn't been validated. Verifies only the first request returns |
| 19 | +headers. |
| 20 | +
|
| 21 | +test_nonnull_locators |
| 22 | +===================== |
| 23 | +
|
13 | 24 | Part 1: No headers announcements before "sendheaders"
|
14 | 25 | a. node mines a block [expect: inv]
|
15 | 26 | send getdata for the block [expect: block]
|
@@ -229,6 +240,29 @@ def run_test(self):
|
229 | 240 | inv_node.sync_with_ping()
|
230 | 241 | test_node.sync_with_ping()
|
231 | 242 |
|
| 243 | + self.test_null_locators(test_node) |
| 244 | + self.test_nonnull_locators(test_node, inv_node) |
| 245 | + |
| 246 | + def test_null_locators(self, test_node): |
| 247 | + tip = self.nodes[0].getblockheader(self.nodes[0].generate(1)[0]) |
| 248 | + tip_hash = int(tip["hash"], 16) |
| 249 | + |
| 250 | + self.log.info("Verify getheaders with null locator and valid hashstop returns headers.") |
| 251 | + test_node.clear_last_announcement() |
| 252 | + test_node.get_headers(locator=[], hashstop=tip_hash) |
| 253 | + assert_equal(test_node.check_last_announcement(headers=[tip_hash]), True) |
| 254 | + |
| 255 | + self.log.info("Verify getheaders with null locator and invalid hashstop does not return headers.") |
| 256 | + block = create_block(int(tip["hash"], 16), create_coinbase(tip["height"] + 1), tip["mediantime"] + 1) |
| 257 | + block.solve() |
| 258 | + test_node.send_header_for_blocks([block]) |
| 259 | + test_node.clear_last_announcement() |
| 260 | + test_node.get_headers(locator=[], hashstop=int(block.hash, 16)) |
| 261 | + test_node.sync_with_ping() |
| 262 | + assert_equal(test_node.block_announced, False) |
| 263 | + test_node.send_message(msg_block(block)) |
| 264 | + |
| 265 | + def test_nonnull_locators(self, test_node, inv_node): |
232 | 266 | tip = int(self.nodes[0].getbestblockhash(), 16)
|
233 | 267 |
|
234 | 268 | # PART 1
|
|
0 commit comments