[tests] Improve mempool_persist test #10342

pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:improve_wait_until_test changing 1 files +20 −21
  1. jnewbery commented at 1:35 PM on May 5, 2017: member

    mempool_persist.py was failing very intermittently because after starting the node, there was a race between calling getrawmempool and the mempool being reloaded by a background thread.

    This PR removes that raciness in the test. It also removes the is_network_split parameter and tidies up the start of the test (this test was written between #10198 being opened and merged)

  2. fanquake added the label Tests on May 5, 2017
  3. in test/functional/mempool_persist.py:72 in 86a5f0dcf9 outdated
      65 | @@ -72,20 +66,24 @@ def run_test(self):
      66 |          self.nodes = []
      67 |          self.nodes.append(start_node(0, self.options.tmpdir))
      68 |          self.nodes.append(start_node(1, self.options.tmpdir))
      69 | -        assert_equal(len(self.nodes[0].getrawmempool()), 5)
      70 | -        assert_equal(len(self.nodes[1].getrawmempool()), 0)
      71 | +        # Give bitcoind a second to reload the mempool
      72 | +        time.sleep(1)
      73 | +        assert wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5)
      74 | +        assert wait_until(lambda: len(self.nodes[1].getrawmempool()) == 0)
    


    sdaftuar commented at 4:51 PM on May 5, 2017:

    Does the wait_until accomplish anything here, or at line 80 below? Either the mempool will be empty when this RPC is first invoked, in which case the wait_until will immediately return, or else it will have something -- in which case waiting and then failing later doesn't seem useful?


    jnewbery commented at 5:09 PM on May 5, 2017:

    No - this could just as well be a straight assert that node1's mempool is empty. The time.sleep(1) above is what actually guarantees that we're not just hitting a window before node1's mempool fills up.

    I changed this to a wait_until() call for consistency with the line above, but could quite easily change it back if you think that would be clearer for the reader.


    sdaftuar commented at 4:47 PM on May 6, 2017:

    Yeah imo it would be clearer without the wait_until.

  4. in test/functional/mempool_persist.py:46 in 86a5f0dcf9 outdated
      51 | -        self.nodes.append(start_node(1, self.options.tmpdir, ["-persistmempool=false"]))
      52 | -        self.nodes.append(start_node(2, self.options.tmpdir))
      53 | -        connect_nodes_bi(self.nodes, 0, 2)
      54 | -        connect_nodes_bi(self.nodes, 1, 2)
      55 | -        self.is_network_split = False
      56 | +        self.extra_args = [[], ["-persistmempool=false"], []]
    


    MarcoFalke commented at 10:27 AM on May 6, 2017:

    Our parser does not support string representations of booleans. You should only use integers here...


    MarcoFalke commented at 10:57 AM on May 6, 2017:
    :%s/false/0/g
    
  5. MarcoFalke commented at 10:58 AM on May 6, 2017: member

    utACK after global substitution.

  6. jnewbery commented at 1:46 PM on May 8, 2017: member

    Added fixup commit:

    • replaces persistmempool=false with -persistmempool=0
    • reverts the assert wait_until(lambda: len(self.nodes[1].getrawmempool()) == 0) to assert_equal(len(self.nodes[1].getrawmempool()), 0)
    • adds a sync_all() call after self.nodes[0].generate(1) to ensure that we really are out of IBD.

    Will squash once this is ACKed and ready for merge.

  7. sdaftuar commented at 3:18 PM on May 8, 2017: member

    ACK

  8. MarcoFalke commented at 5:31 PM on May 8, 2017: member

    utACK 6658e7fc4f3117beb82d02d71f2de2f0500d37c1, please squash.

  9. [tests] use wait_until in mempool_persist.py 329ac3bab1
  10. jnewbery force-pushed on May 8, 2017
  11. jnewbery commented at 6:01 PM on May 8, 2017: member

    squashed

  12. MarcoFalke merged this on May 8, 2017
  13. MarcoFalke closed this on May 8, 2017

  14. MarcoFalke referenced this in commit 6a796b2b53 on May 8, 2017
  15. jnewbery deleted the branch on May 8, 2017
  16. PastaPastaPasta referenced this in commit cb2ff3564f on Jun 10, 2019
  17. PastaPastaPasta referenced this in commit a88687388f on Jun 10, 2019
  18. PastaPastaPasta referenced this in commit 4662bd06fb on Jun 10, 2019
  19. PastaPastaPasta referenced this in commit b054a6942f on Jun 11, 2019
  20. PastaPastaPasta referenced this in commit 7154850016 on Jun 11, 2019
  21. PastaPastaPasta referenced this in commit c04abd96a8 on Jun 15, 2019
  22. PastaPastaPasta referenced this in commit 14efb88eec on Jun 19, 2019
  23. PastaPastaPasta referenced this in commit 07c83c552a on Jun 19, 2019
  24. PastaPastaPasta referenced this in commit 69ffcb453c on Jun 19, 2019
  25. PastaPastaPasta referenced this in commit 7b858f8ba8 on Jun 19, 2019
  26. PastaPastaPasta referenced this in commit 4a997f45f5 on Jun 19, 2019
  27. PastaPastaPasta referenced this in commit 5b99bfc6fa on Jun 19, 2019
  28. PastaPastaPasta referenced this in commit b8d9d5a574 on Jun 19, 2019
  29. PastaPastaPasta referenced this in commit 9d6eccea33 on Jun 20, 2019
  30. barrystyle referenced this in commit 3a6e69c3ce on Jan 22, 2020
  31. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me