Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

light-client: turn Handle into a trait #401

Merged
merged 3 commits into from
Jul 1, 2020
Merged

Conversation

xla
Copy link
Contributor

@xla xla commented Jun 30, 2020

As we start to depend on the surface of the Handle we benefit from it being a trait that can be implemented on a per need basis. This will result in less overhead constructing object graphs in places where we want to assert behaviour of other types in remote places, i.e. the light-node RPC server. Overall we hope for an increased ease in writing tests on module level.

Ref #219
Ref #398

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGES.md

As we start to depend on the surface of the `Handle` we benefit from it
being a trait that can be implemented on a per need basis. This will
result in less overhead constructing object graphs in places where we
wannt to assert behaviour of other types in remote places, i.e. the
light-node rpc server. Overall we hope for an increased ease in writing
tests on module level.

Ref #219
@xla xla added enhancement New feature or request light-client Issues/features which involve the light client labels Jun 30, 2020
@xla xla added this to the Light Node milestone Jun 30, 2020
@xla xla requested review from brapse, romac, ebuchman and liamsi June 30, 2020 20:05
@xla xla self-assigned this Jun 30, 2020

/// Terminate the underlying [`Supervisor`].
fn terminate(&mut self);
}
Copy link
Member

@liamsi liamsi Jul 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍 My understanding of why making this a trait is cool is because it makes testability easier. Is there a (wip) example of such a test that would be annoying to write without this (maybe in another PR)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit a452244 shows the start, where the test code implements a mockHandle. Generally it means a reduction of the objects that need constructing. If something was dependent on the Handle before, one had to provide a PeerList, ForkDetector, EvidenceProvider to construct the Supervisor. On all the state inside had to be correct in order to produce output as expected, which means the correct state in peer(s) stores, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

CHANGES.md Outdated Show resolved Hide resolved
liamsi
liamsi previously approved these changes Jul 1, 2020
Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM, but would appreciate a 2nd pair of eyes (cc @romac)

Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com>
Copy link
Contributor

@brapse brapse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@brapse brapse merged commit c118b4a into master Jul 1, 2020
@brapse brapse deleted the xla/219-handle-trait branch July 1, 2020 08:01
@romac
Copy link
Member

romac commented Jul 1, 2020

Looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request light-client Issues/features which involve the light client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants