test: fix a race in rpc_net.py (wait for P2P handshake to complete) #29515

pull vasild wants to merge 1 commits into bitcoin:master from vasild:fix_race_in_rpc_net.py changing 1 files +5 −0
  1. vasild commented at 11:12 AM on February 29, 2024: contributor

    We connect a new peer, wait for it using self.nodes[0].wait_for_new_peer() and then demand that "transport_protocol_type" is either "v1" or "v2". However wait_for_new_peer() may return too early - during the P2P handshake when "transport_protocol_type" is "detecting".

    Fix this by waiting for the P2P handshake to complete and the protocol version to be established.

    An example failure (equal fields removed for clarity):

    AssertionError: not({
        ...
        'session_id': '',
        'transport_protocol_type': 'detecting',
    } == {
        ...
        'session_id': '8fe5902166b892a57ac6849caadd02d2dff83d84f2e57ee50bf894f93cf2f62e',
        'transport_protocol_type': 'v2',
    })
    

    https://cirrus-ci.com/task/5839860502626304?logs=ci#L8326

  2. test: fix a race in rpc_net.py (wait for P2P handshake to complete)
    We connect a new peer, wait for it using `self.nodes[0].wait_for_new_peer()`
    and then demand that "transport_protocol_type" is either "v1" or "v2".
    However `wait_for_new_peer()` may return too early - during the P2P handshake
    when "transport_protocol_type" is "detecting".
    
    Fix this by waiting for the P2P handshake to complete and the protocol
    version to be established.
    
    An example failure (equal fields removed for clarity):
    
    ```
    AssertionError: not({
        ...
        'session_id': '',
        'transport_protocol_type': 'detecting',
    } == {
        ...
        'session_id': '8fe5902166b892a57ac6849caadd02d2dff83d84f2e57ee50bf894f93cf2f62e',
        'transport_protocol_type': 'v2',
    })
    ```
    2052ad5fb3
  3. DrahtBot commented at 11:23 AM on February 29, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. DrahtBot added the label Tests on Feb 29, 2024
  5. maflcko commented at 11:27 AM on February 29, 2024: member

    Generally, it is good to check the open pull requests before opening a pull request, to avoid duplicate patches for the same fix.

  6. maflcko closed this on Feb 29, 2024

  7. maflcko commented at 11:28 AM on February 29, 2024: member
  8. vasild deleted the branch on Feb 29, 2024
  9. bitcoin locked this on Feb 28, 2025
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-25 15:14 UTC

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