[test] Fix sync issue in disconnect_p2ps #20522

pull amitiuttarwar wants to merge 1 commits into bitcoin:master from amitiuttarwar:2020-11-disconnect-p2ps changing 1 files +1 −1
  1. amitiuttarwar commented at 11:04 pm on November 27, 2020: contributor

    #19315 currently has a test failure because of a race. disconnect_p2ps is intended to have a wait_until clause that prevents this race, but the conditional doesn’t match since its comparing two different object types. MY_SUBVERSION is defined in messages.py as a byte string, but is compared to the value returned by the RPC. This PR simply converts types to ensure they match, which should prevent the race from occurring.

    HUGE PROPS TO jnewbery for discovering the issue 🔎

  2. [test] Fix wait condition in disconnect_p2ps
    MY_SUBVERSION is defined in messages.py as a byte string, but here we were
    comparing this value to the value returned by the RPC. Convert to ensure the
    types match.
    3ebde2143a
  3. fanquake added the label Tests on Nov 27, 2020
  4. amitiuttarwar commented at 1:24 am on November 28, 2020: contributor
  5. amitiuttarwar commented at 1:27 am on November 28, 2020: contributor

    the CI failure is a FileNotFoundError from feature_config_args, so seems unrelated

    image

  6. glozow commented at 1:40 am on November 28, 2020: member
  7. in test/functional/test_framework/test_node.py:547 in 3ebde2143a
    543@@ -544,7 +544,7 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
    544 
    545     def num_test_p2p_connections(self):
    546         """Return number of test framework p2p connections to the node."""
    547-        return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION])
    548+        return len([peer for peer in self.getpeerinfo() if peer['subver'] == MY_SUBVERSION.decode("utf-8")])
    


    MarcoFalke commented at 10:15 am on November 28, 2020:
    It might be better to leave this as-is and call encode where it is needed. Doing so will prevent similar issues in the future. Missing an encode, however, can’t result in a hard-to-debug issue because it is detected immediately as a type error (either by mypy or at runtime)
  8. jonatack commented at 11:13 am on November 28, 2020: member
    Concept ACK. A passing/failing test would be good to demonstrate that this works and document the case (and possibly added to the test framework tests).
  9. jnewbery commented at 12:48 pm on November 28, 2020: member

    ACK 3ebde2143aa98af213872b98b474d904e55056f7

    It might be better to leave this as-is and call encode where it is needed. Doing so will prevent similar issues in the future.

    I agree. However, I think this fix is good enough for now and unblocks #19315, so we should merge it.

    I have a branch here: https://github.com/jnewbery/bitcoin/tree/pr20522.1 which changes MY_SUBVERSION to be a string, and does a lot more cleaning up of the msg_version handing by the test framework. I’ll open a PR for that after this is merged.

  10. MarcoFalke merged this on Nov 28, 2020
  11. MarcoFalke closed this on Nov 28, 2020

  12. sidhujag referenced this in commit 795d0905a4 on Nov 29, 2020
  13. laanwj referenced this in commit 860f916803 on Feb 18, 2021
  14. Fabcien referenced this in commit 9ed55ccf96 on Jan 19, 2022
  15. MarcoFalke 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-18 21:12 UTC

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