-
Notifications
You must be signed in to change notification settings - Fork 224
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
Conversation
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
|
||
/// Terminate the underlying [`Supervisor`]. | ||
fn terminate(&mut self); | ||
} |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this 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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Looks good :) |
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
Updated all relevant documentation in docsWrote tests