test: move sync_blocks and sync_mempool functions to test_framework.py #19208

pull ycshao wants to merge 1 commits into bitcoin:master from ycshao:issue-18930 changing 5 files +56 −66
  1. ycshao commented at 12:59 pm on June 8, 2020: contributor

    This PR moves sync_blocks and sync_mempool out from test_framework/util.py to test_framework/test_framework.py so they can take contextual information of test framework into account.

    • Change all reference callers to call functions from test_framework.py
    • Remove **kwargs which is not used
    • Take into account of timeout_factor when respecting timeout in function implementations.
    • Pass all tests by running ./test/functional/test_runner.py

    fixes #18930

  2. fanquake added the label Tests on Jun 8, 2020
  3. ycshao force-pushed on Jun 8, 2020
  4. MarcoFalke commented at 1:03 pm on June 8, 2020: member
    Nice! Concept ACK
  5. ycshao commented at 1:12 pm on June 8, 2020: contributor

    Seems like the style of those files are auto-formatted by autopep8. I’ll leave the reviewers to comment about the format.

    One question about the implementation. Does it make sense to move assert (all([len(x.getpeerinfo()) for x in rpc_connections])) up to immediately after the while loop starts? It will assert sooner and save some time and operations.

  6. ycshao marked this as ready for review on Jun 8, 2020
  7. ycshao commented at 6:03 pm on June 8, 2020: contributor
    Looks like wallet_avoidreuse.py failed in travis but it works fine on my machine. Is there a way to replay the travis failed tests?
  8. ycshao renamed this:
    test: move `sync_blocks` and `sync_mempool` functions to `test_framework.py`
    test: move sync_blocks and sync_mempool functions to test_framework.py
    on Jun 8, 2020
  9. DrahtBot commented at 0:06 am on June 9, 2020: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19198 (test: Check that peers with forcerelay permission are not asked to feefilter by MarcoFalke)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  10. ycshao commented at 1:26 am on June 9, 2020: contributor

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    Could someone explain what does conflicts mean here? Is there a logical order of PRs mentioned + mine to review and merge?

  11. adamjonas commented at 2:03 pm on June 9, 2020: member
    @ycshao DrahtBot crawls over open PRs and alerts you when there is a conflict with the main branch that requires a rebase or, in this case, other PRs that may lead to future conflicts indicating that you are working on similar code. DrahtBot is not sentient enough to decide the merge order. It’s just raising it to your attention.
  12. adamjonas commented at 3:48 pm on June 9, 2020: member

    Re the format - autopep8 is making the diff much larger. I think it’s easier, for now, to keep the diff as minimal as possible so reviewers can focus on the changes relevant to your patch. At the very least, you can break the formatting changes into their own commit and follow the lead of this reformat.

    I’d also suggest squashing your second commit since the first commit doesn’t pass the linter without it.

  13. ycshao commented at 5:32 pm on June 9, 2020: contributor
    @adamjonas thanks for the answer and suggestion. I’ll squash and break formatting into it’s own commit.
  14. in test/functional/test_framework/test_framework.py:545 in 36404ae22c outdated
    574+        Wait until everybody has the same tip.
    575 
    576-    def sync_all(self, nodes=None, **kwargs):
    577-        self.sync_blocks(nodes, **kwargs)
    578-        self.sync_mempools(nodes, **kwargs)
    579+        sync_blocks needs to be called with an rpc_connections set that has least
    


    glozow commented at 7:24 pm on June 9, 2020:
    I have a question - it’s probably not a big deal to require at least one node to be updated, but would it be appropriate to have an optional blockhash parameter and enforce that hash instead?

    ycshao commented at 9:51 pm on June 9, 2020:
    I don’t see a use case like that in current code. But I think one benefit your idea will give is to shorten test run time if the block we need to sync to is not usually the tip.
  15. glozow commented at 7:39 pm on June 9, 2020: member

    Oo first PR? Concept ACK :) I’m guessing “contextual information of test framework” is the timeout_factor? +1 to Jonas, just appeasing test/lint/lint-python.sh for now would be better.

    Does it make sense to move assert (all([len(x.getpeerinfo()) for x in rpc_connections])) up to immediately after the while loop starts? It will assert sooner and save some time and operations.

    I had this thought too. But I think it would fail if the nodes happened to all be synced up (despite not being connected right now) before the first iteration of the while loop. I think it’s possible…?

  16. ycshao force-pushed on Jun 9, 2020
  17. ycshao commented at 9:07 pm on June 9, 2020: contributor

    Oo first PR? Concept ACK :) I’m guessing “contextual information of test framework” is the timeout_factor?

    Yeah for now timeout_factor is easiest to be used. There are other things potentially can be used. I’m open to suggestions.

    • rpc_timeout - I think rpc_timeout is usually sometime different than timeout people want to configure for syncing operations. Unless there is a factor that can be applied to rpc_timeout to estimate syncing timeout. Open to suggestions.
    • nodes - We can by default sync all nodes and take in a parameter in sync_blocks and sync_mempool in case subset of nodes need to be synced. This way we get rid of nodes input of those two functions.

    +1 to Jonas, just appeasing test/lint/lint-python.sh for now would be better.

    lint-python.sh gives me other linting errors which is not related to the file I touched. I guess I’ll just make those five files I touched to be pep8 in a separate commit. If it’s not necessary, it’s easy to take it out.

     0test/functional/p2p_compactblocks.py:688:43: E741 ambiguous variable name 'l'
     1test/functional/p2p_compactblocks.py:694:13: E741 ambiguous variable name 'l'
     2test/functional/p2p_compactblocks.py:697:17: E741 ambiguous variable name 'l'
     3test/functional/p2p_dos_header_tree.py:37:38: E741 ambiguous variable name 'l'
     4test/functional/p2p_dos_header_tree.py:42:31: E741 ambiguous variable name 'l'
     5test/functional/p2p_dos_header_tree.py:43:55: E741 ambiguous variable name 'l'
     6test/functional/test_framework/messages.py:70:22: E741 ambiguous variable name 'l'
     7test/functional/test_framework/messages.py:142:16: E741 ambiguous variable name 'l'
     8test/functional/test_framework/messages.py:161:24: E741 ambiguous variable name 'l'
     9test/functional/test_framework/messages.py:177:23: E741 ambiguous variable name 'l'
    10test/functional/wallet_labels.py:149:13: E741 ambiguous variable name 'l'
    11test/functional/wallet_labels.py:155:13: E741 ambiguous variable name 'l'
    12test/lint/lint-python.sh: line 105: mypy: command not found
    

    Does it make sense to move assert (all([len(x.getpeerinfo()) for x in rpc_connections])) up to immediately after the while loop starts? It will assert sooner and save some time and operations.

    I had this thought too. But I think it would fail if the nodes happened to all be synced up (despite not being connected right now) before the first iteration of the while loop. I think it’s possible…?

    I guess it’s theoretically possible.

  18. in test/functional/test_framework/test_framework.py:222 in 4563520ee3 outdated
    219 
    220         os.environ['PATH'] = os.pathsep.join([
    221             os.path.join(config['environment']['BUILDDIR'], 'src'),
    222-            os.path.join(config['environment']['BUILDDIR'], 'src', 'qt'), os.environ['PATH']
    223+            os.path.join(config['environment']['BUILDDIR'],
    224+                         'src', 'qt'), os.environ['PATH']
    


    MarcoFalke commented at 3:34 pm on June 16, 2020:
    I am not sure it this is actually more readable (we’ve generally been using more a limit of 120 instead of 80). And taking into account the large number of conflicts due to the pep-8 change, maybe leave it out for now?

    ycshao commented at 2:18 am on June 18, 2020:
    Reverted
  19. DrahtBot added the label Needs rebase on Jun 16, 2020
  20. ycshao force-pushed on Jun 18, 2020
  21. DrahtBot removed the label Needs rebase on Jun 18, 2020
  22. in test/functional/test_framework/test_framework.py:552 in 5347a7597b outdated
    545-    def sync_mempools(self, nodes=None, **kwargs):
    546-        sync_mempools(nodes or self.nodes, **kwargs)
    547-
    548-    def sync_all(self, nodes=None, **kwargs):
    549-        self.sync_blocks(nodes, **kwargs)
    550-        self.sync_mempools(nodes, **kwargs)
    


    MarcoFalke commented at 12:21 pm on June 18, 2020:
    why is this changed?

    ycshao commented at 4:49 pm on June 18, 2020:
    I removed **kwargs which are not used.

    MarcoFalke commented at 4:54 pm on June 18, 2020:
    I think they might come in handy in the future. Is there a reason they will be unused forever?

    ycshao commented at 5:05 pm on June 18, 2020:
    I feel it’s better to add it when it will be used in instead of putting it there up front just because some time in the future it might be used. What do you think?
  23. in test/functional/test_framework/test_framework.py:559 in 5347a7597b outdated
    563+                return
    564+            # Check that each peer has at least one connection
    565+            assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
    566+            time.sleep(wait)
    567+        raise AssertionError("Block sync timed out after {}s:{}".format(
    568+            int(timeout * self.options.timeout_factor),
    


    MarcoFalke commented at 12:22 pm on June 18, 2020:
    You don’t need to change this if you just set timeout = int(timeout * self.options.timeout_factor) at the beginning of the function

    ycshao commented at 5:05 pm on June 18, 2020:
    Changed
  24. in test/functional/test_framework/test_framework.py:581 in 5347a7597b outdated
    585+                return
    586+            # Check that each peer has at least one connection
    587+            assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
    588+            time.sleep(wait)
    589+        raise AssertionError("Mempool sync timed out after {}s:{}".format(
    590+            int(timeout * self.options.timeout_factor),
    


    MarcoFalke commented at 12:22 pm on June 18, 2020:
    same

    ycshao commented at 5:05 pm on June 18, 2020:
    changed
  25. MarcoFalke commented at 12:23 pm on June 18, 2020: member

    Concept ACK, but please change the commit title to

    0test: move sync_blocks and sync_mempool functions to test_framework.py
    
  26. MarcoFalke commented at 5:08 pm on June 18, 2020: member
    Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits and change the commit title to something more meaningful: #19208#pullrequestreview-433226219
  27. test: move sync_blocks and sync_mempool functions to test_framework.py cc84460c16
  28. ycshao force-pushed on Jun 18, 2020
  29. MarcoFalke commented at 8:36 pm on June 18, 2020: member

    ACK cc84460c164bcb2a874d4f08b3a2624e5ee9ff0a , reviewed with –color-moved=dimmed-zebra –color-moved-ws=ignore-all-space 💫

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK cc84460c164bcb2a874d4f08b3a2624e5ee9ff0a , reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space 💫
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUh0+gv+MXi8uR6BQOeLwvt+luY9+MDS6qKEVkd1x6tUrhNL4R/1/HzIbCPA0n0O
     8FH/bMuzMk19Fn4qkH4vGEJHPQTeT+CNEf9omuWRSrNU8pqicaBpAN0cpWcHbJSxD
     9A8TC5uecJ1vWLmYruW9mnSTyYFTL7maKas7yKv4JsmsLIRhMPhWnJ2VU7MrCq9Uv
    10UyR5VTYjiqmw3Gz24RJ9QTtJWTDJjlkNXs01ZrO1ijVX5Gak9QLx47wz60lh8wtT
    11XtRQKOxsBGbJfrFexpU3IdThhNTuLTx1zcULgE2S6IOBF1Lph/CrSuZLv69H3bhW
    12S45h7iliCQR5njyC93TB1GB56BDFGcvbFqkjP0jgB0sVdh+pRP4lcgTNRGPD8O+t
    13p4TbuTKMo6P1JbqB1TAzZCmWUjVLmTjReSvGlMKegA3FHTm2XyXQEuOT7KHNk2Bm
    142BHyvABW/hlIB/79YlUQ59pTC8CIvjEl0JQxY5VXOARyESD9PAteaJ5aFplnHtYl
    15eIUZJOgR
    16=adom
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash bea4e035a3dba2f2997391d4f35010649fa6ca21167797054925a5e15c237f47 -

  30. MarcoFalke merged this on Jun 21, 2020
  31. MarcoFalke closed this on Jun 21, 2020

  32. ycshao commented at 5:05 am on June 22, 2020: contributor
    @MarcoFalke @gzhao408 @adamjonas thanks for reviewing and merge!
  33. furszy referenced this in commit a51b254f27 on Mar 20, 2021
  34. Fabcien referenced this in commit 351c23d9d4 on Apr 21, 2021
  35. DrahtBot locked this on Feb 15, 2022

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: 2024-12-27 21:12 UTC

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