Merge #11025: qa: Fix inv race in example_test

faa76d1b7 qa: Fix inv race in example_test (MarcoFalke)

Pull request description:

  There have been intermittent test failures on this script.

  ```py
    File "./test/functional/example_test.py", line 216, in run_test
      assert_equal(block, 1)
  AssertionError: not(2 == 1)
  ```

  Probably the simplest way to fix them is overriding the `on_inv` method, so that no "colliding" getdata for the blocks are sent out.

  Additionally, all getdata are now sent in a single message.

Tree-SHA512: 809c2bbfa90a67fc97905769fcbe90ba9abe1aac1f145530934f56a364835973b94d3302b6be68f4f2987acf333bce146bcc4c878c283301871ba5bb1a9bedb6
This commit is contained in:
MarcoFalke 2017-08-11 16:57:51 +02:00
commit e5d26e47c7
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -58,6 +58,10 @@ class BaseNode(NodeConnCB):
message.block.calc_sha256() message.block.calc_sha256()
self.block_receive_map[message.block.sha256] += 1 self.block_receive_map[message.block.sha256] += 1
def on_inv(self, conn, message):
"""Override the standard on_inv callback"""
pass
def custom_function(): def custom_function():
"""Do some custom behaviour """Do some custom behaviour
@ -198,10 +202,10 @@ class ExampleTest(BitcoinTestFramework):
self.log.info("Wait for node2 reach current tip. Test that it has propogated all the blocks to us") self.log.info("Wait for node2 reach current tip. Test that it has propogated all the blocks to us")
getdata_request = msg_getdata()
for block in blocks: for block in blocks:
getdata_request = msg_getdata()
getdata_request.inv.append(CInv(2, block)) getdata_request.inv.append(CInv(2, block))
node2.send_message(getdata_request) node2.send_message(getdata_request)
# wait_until() will loop until a predicate condition is met. Use it to test properties of the # wait_until() will loop until a predicate condition is met. Use it to test properties of the
# NodeConnCB objects. # NodeConnCB objects.