Skip to content

ChannelManager public interface tests #529

Closed as not planned
Closed as not planned

Description

@jkczyz

Add unit tests for ChannelManager's public interface.

Activity

  1. TheBlueMatt commented on Mar 3, 2020

    @TheBlueMatt
    Collaborator

    What did you have in mind here - if there's one thing that has good test coverage its the things that ChannelManager exposes - message handling, its public interface, and block connection, even if its all in functional_tests.rs, instead of channelmanager.rs directly.

  2. jkczyz commented on Mar 3, 2020

    @jkczyz
    ContributorAuthor

    Per the description, I was referring to unit tests, which I think compliment functional tests and should be a part of our testing strategy. Unit tests provide more confidence in the code, ease finding the root cause of bugs, help improve system design by identifying complexity, and act to document module behaviors.

  3. tnull commented on Mar 4, 2020

    @tnull
    Contributor

    As suggested by the issue label, I may use this opportunity to get into initial contact with the code base. If that's okay with you, I'll try to write some tests in the coming days.

  4. TheBlueMatt commented on Mar 4, 2020

    @TheBlueMatt
    Collaborator

    Right, I think the "functional_tests" in many ways act as unit tests. You could pull some small bits out, but, for the most part, the functional tests we have call send_payment and then check that the expected messages come back out. I'm really not sure how you'd split them out to be more useful.

  5. jkczyz commented on Mar 4, 2020

    @jkczyz
    ContributorAuthor

    It's entirely possible that the tests wouldn't look much different. I don't think that makes "functional_tests" act as unit tests, though. I'd argue that it could be a sign that this module is doing too much. The number of dependencies that it has could also be indicative of that; unit tests shouldn't require an elaborate setup.

    Another telltale sign is when something is named with a Manager suffix. It could be simple lack of imagination in naming, but more often than not the module has either too much or an unclear responsibility. Here's a sampling of some references on this topic from a quick Google search:

    This is why unit tests are important: they foster better design. So, this issue could potentially be repurposed to refactor ChannelManager into pieces that can be unit tested. I'm not sure exactly what those pieces would look like. But the process of identifying the responsibilities of this module would give a better idea of what those pieces could be.

  6. TheBlueMatt commented on Mar 4, 2020

    @TheBlueMatt
    Collaborator

    Its true, it would be nice to move Channels to be pub and let ChannelManager take on more of a message-passing role, tracking HTLCs as Channels accept/forward them. This is essentially all it does now, but with the underlying Channels being hidden from the end-user, but I'd guess that would be a huge overhaul of the API and with a ton of careful work that would have to go into it. Still, while a good unit test target may be Channels (eg setting a Channel state machine to a certain state and then checking that some method mutates it in the correct way), trying to do so in ChannelManager would require more initialization just in terms of setting the state variables than a functional test does.

    I agree Manager may be the wrong word here - ultimately its not just that its holding all the Channels, but tracking a bunch of HTLC state, implying more of an HTLCMarshallerWithChannelsInside, but that seems like a mouthful. I'm open to better names :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions