[qa] util: Remove unused sync_chain #12643

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1803-qaUtilSyncChain changing 2 files +10 −36
  1. MarcoFalke commented at 2:09 AM on March 8, 2018: member

    The util function sync_blocks already checks for equal chains, so we can remove the unused sync_chain.

    Also cleaned up the errors that are printed in case of timeout:

    AssertionError: Block sync timed out:
      '72a3a3e9dcfd0a09204c3447af0f481d19641eeadbe6a91b8e680ed614bc7712'
      '5032af4ae22ae7a21afdc9d9f516877309c4dd8ef2ecadb9354be7088439b4a6'
      '5032af4ae22ae7a21afdc9d9f516877309c4dd8ef2ecadb9354be7088439b4a6'
    

    and

    AssertionError: Mempool sync timed out:
      {'c2af943d9b321c36e0f5a153a9d3d8b11bdd46ceb28e38f5fd2c722e3edb3563'}
      set()
      set()
    
  2. fanquake added the label Tests on Mar 8, 2018
  3. MarcoFalke force-pushed on Mar 8, 2018
  4. in test/functional/test_framework/util.py:369 in fa91820244 outdated
     384 | -    """
     385 | -    while timeout > 0:
     386 |          best_hash = [x.getbestblockhash() for x in rpc_connections]
     387 |          if best_hash == [best_hash[0]] * len(best_hash):
     388 |              return
     389 |          time.sleep(wait)
    


    conscott commented at 11:44 PM on March 10, 2018:

    Keeping in line with #12553, preferring wait_until when possible, this whole function could just be cleaned up as

    def sync_blocks(rpc_connections, *, wait=1, timeout=60):
        wait_until(lambda: len(set([x.getbestblockhash() for x in rpc_connections])) is 1, timeout=timeout, wait=wait)
    

    Although a wait argument (or maybe sleep is a better name) needs to be added to wait_until, specifying the sleep period between checks.

  5. in test/functional/test_framework/util.py:387 in fa91820244 outdated
     413 |                      r.syncwithvalidationinterfacequeue()
     414 |              return
     415 |          time.sleep(wait)
     416 | -        timeout -= wait
     417 | -    raise AssertionError("Mempool sync failed")
     418 | +        cur_time = time.time()
    


    conscott commented at 11:49 PM on March 10, 2018:

    Similar to the above comment, this can just be cleaned up to use wait_util like

    def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
        """
        Wait until everybody has the same transactions in their memory
        pools
        """
        def equal_mempool():
            mempool_sets = [set(r.getrawmempool()) for r in rpc_connections]
            return mempool_sets.count(mempool_sets[0]) == len(mempool_sets)
    
        wait_until(equal_mempool, timeout=timeout, wait=wait)
        if flush_scheduler:
            for r in rpc_connections:
                r.syncwithvalidationinterfacequeue()
    

    I tested both changes in this commit and everything seems to pass, however let me know if you thinks its better suited for a follow up PR.


    MarcoFalke commented at 8:05 PM on March 11, 2018:

    It seems that this would make it harder to print the mempools in case of an error, which seems useful to me.

    Though, I switched to your code suggesting count.


    conscott commented at 7:31 AM on March 12, 2018:

    Makes sense


    promag commented at 12:10 AM on March 13, 2018:

    I switched to your code suggesting count.

    Nice @conscott.

  6. MarcoFalke force-pushed on Mar 11, 2018
  7. conscott commented at 7:32 AM on March 12, 2018: contributor

    Tested ACK faed9d59a9fffa01debc41121deccfdeb28f35cb

  8. in test/functional/test_framework/util.py:365 in faed9d59a9 outdated
     365 | -    # initial max height because the two RPCs look at different internal global
     366 | -    # variables (chainActive vs latestBlock) and the former gets updated
     367 | -    # earlier.
     368 | -    maxheight = max(x.getblockcount() for x in rpc_connections)
     369 |      start_time = cur_time = time.time()
     370 |      while cur_time <= start_time + timeout:
    


    promag commented at 12:14 AM on March 13, 2018:

    Nit, simplification:

    stop_time = time.time() + timeout;
    while time.time() <= stop_time:
    

    MarcoFalke commented at 12:40 AM on March 13, 2018:

    Done

  9. promag commented at 12:15 AM on March 13, 2018: member

    utACK faed9d5.

  10. [qa] util: Remove unused sync_chain fa1436c429
  11. MarcoFalke force-pushed on Mar 13, 2018
  12. laanwj merged this on Mar 13, 2018
  13. laanwj closed this on Mar 13, 2018

  14. laanwj referenced this in commit 0f0229d0c3 on Mar 13, 2018
  15. MarcoFalke deleted the branch on Mar 13, 2018
  16. random-zebra referenced this in commit 6bc917e859 on Jul 6, 2020
  17. PastaPastaPasta referenced this in commit 9a28448b58 on Dec 12, 2020
  18. PastaPastaPasta referenced this in commit 974741e278 on Dec 12, 2020
  19. PastaPastaPasta referenced this in commit 9b3d61e5f1 on Dec 12, 2020
  20. PastaPastaPasta referenced this in commit 823156c843 on Dec 15, 2020
  21. PastaPastaPasta referenced this in commit c7a5be4d6b on Dec 15, 2020
  22. PastaPastaPasta referenced this in commit 9d34d92722 on Dec 18, 2020
  23. MarcoFalke locked this on Sep 8, 2021
Labels

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-13 18:15 UTC

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