[qa] mininode: Expose connection state through is_connected #13512

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1806-qaMininodeState changing 5 files +51 −47
  1. MarcoFalke commented at 1:45 am on June 21, 2018: member

    This gets rid of some non-type safe string comparisons and access to members that are implementation details of class P2PConnection(asyncore.dispatcher). Such refactoring is required to replace the deprecated asyncore with something more sane.

    Changes:

    • Get rid of non-enum member state and replace is with bool connected
    • Get rid of confusing argument pushbuf and literally just push to the buffer at the call site
  2. MarcoFalke added the label Tests on Jun 21, 2018
  3. MarcoFalke force-pushed on Jun 21, 2018
  4. in test/functional/test_framework/mininode.py:83 in fa1a3f5be9 outdated
    76@@ -77,14 +77,19 @@ def __init__(self):
    77 
    78         super().__init__(map=mininode_socket_map)
    79 
    80+        self.conn_open = False
    81+
    82+    def is_connected(self):
    


    jnewbery commented at 5:39 pm on June 21, 2018:
    suggestion: change this to a property (use @property decorator)

    MarcoFalke commented at 6:15 pm on June 21, 2018:
    I believe this doesn’t work when the implementation details change and we no longer return a member. That is, when we derive the return value with an expression. E.g. self._transport is not None or self._state == State.CONNECTED or …

    jnewbery commented at 7:16 pm on June 21, 2018:
    It should still work. a @property decorated method can do anything any other method can do.

    MarcoFalke commented at 7:27 pm on June 21, 2018:
    Ah thanks for clarifying. Reworked the patch to make it a property.
  5. jnewbery commented at 5:40 pm on June 21, 2018: member
    Great. Definitely concept ACK changing P2PConnection.state from a string and making it private, however I think it’d be a cleaner implementation to just turn state into an Enum class rather than two bools (asyncore_pre_connection and conn_open). Also rename to _state to indicate that it’s private.
  6. MarcoFalke commented at 6:07 pm on June 21, 2018: member
    The reason I split those into two bools is that we are only really interested in one (conn_open) and a bool can represent all states we are interested in. The asyncore_pre_connection is an implementation detail of asyncore and will disappear the same time asyncore disappears. Imo, no need to artificially introduce an enum and then flatten it again to a bool in a follow up commit.
  7. MarcoFalke force-pushed on Jun 21, 2018
  8. MarcoFalke force-pushed on Jun 21, 2018
  9. jnewbery commented at 7:27 pm on June 21, 2018: member

    no need to artificially introduce an enum and then flatten it again

    I disagree that this is artificially introducing an enum. P2PConnection.state already is an enum, just implemented in a really bad way :) why not just wait to flatten it to a bool when the P2PConnection implementation is changed to asyncio or whatever?

    tbh though, this is just nitting. Fine to split this to two bools now if that’s what you prefer. I would suggest you name them _conn_open and _asyncore_pre_connection to indicate that they’re private.

  10. MarcoFalke force-pushed on Jun 21, 2018
  11. MarcoFalke commented at 7:31 pm on June 21, 2018: member
    Made both bools private members
  12. jnewbery commented at 9:28 pm on June 21, 2018: member
    p2p_sendheaders.py fails. I have logs from a local failure if you want them.
  13. MarcoFalke commented at 1:25 am on June 22, 2018: member

    No need to ask for permission. Just throw them at me

    On Thu, Jun 21, 2018, 17:29 John Newbery notifications@github.com wrote:

    p2p_sendheaders.py fails. I have logs from a local failure if you want them.

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/13512#issuecomment-399249293, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGmv0vzYfGiS1Xd-kCvjPDwTpowq3Qbks5t_BBKgaJpZM4UxRTg .

  14. [qa] mininode: Expose connection state through is_connected fa1eac9cdb
  15. MarcoFalke force-pushed on Jun 22, 2018
  16. jnewbery commented at 4:00 pm on June 22, 2018: member

    I coudn’t repro the p2p_sendheaders failure.

    Investigating a bit, I see that there’s a pre-existing race condition in that test: #13522, so the failure that I saw locally and on travis isn’t related to this PR.

  17. jnewbery commented at 4:02 pm on June 22, 2018: member
    Tested ACK fa1eac9cdb1a491d5947b6972b87833792a16fe3
  18. MarcoFalke merged this on Jun 23, 2018
  19. MarcoFalke closed this on Jun 23, 2018

  20. MarcoFalke referenced this in commit 3a4549301a on Jun 23, 2018
  21. MarcoFalke deleted the branch on Jun 24, 2018
  22. PastaPastaPasta referenced this in commit ea33d327a8 on Dec 16, 2020
  23. PastaPastaPasta referenced this in commit 76a430f377 on Dec 18, 2020
  24. random-zebra referenced this in commit bffe509aed on Jun 28, 2021
  25. MarcoFalke 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: 2024-11-17 18:12 UTC

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