From 1d8c7226d0d466e055c4c0243cec743abb0290b5 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 12 Apr 2019 13:37:14 +0200 Subject: [PATCH] Fix race condition in sendheaders.py (#2862) generate() will push INV messages to all nodes, including our test_node. The original check_last_announcement() call done here will then sporadically return Fals when the INV message is received shortly after clear_last_announcement() Solution is to check for the INV announcement first and then continue with the test. --- qa/rpc-tests/sendheaders.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qa/rpc-tests/sendheaders.py b/qa/rpc-tests/sendheaders.py index 4e4977d5fb..83a2c45d02 100755 --- a/qa/rpc-tests/sendheaders.py +++ b/qa/rpc-tests/sendheaders.py @@ -297,6 +297,11 @@ class SendHeadersTest(BitcoinTestFramework): tip = self.nodes[0].getblockheader(self.nodes[0].generate(1)[0]) tip_hash = int(tip["hash"], 16) + # TODO this partly fixes the same thing that is fixed by https://github.com/bitcoin/bitcoin/pull/13192 + # This will later conflict when backporting the actual fix. Just take everything from the Bitcoin fix as a + # resolution + assert_equal(test_node.check_last_announcement(headers=[], inv=[tip_hash]), True) + self.log.info("Verify getheaders with null locator and valid hashstop returns headers.") test_node.clear_last_announcement() test_node.get_headers(locator=[], hashstop=tip_hash)