-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Migrate CurrencyRateController to BaseControllerV2 #372
Conversation
1ffff86
to
eb26f36
Compare
eb26f36
to
fa0d1b9
Compare
fa0d1b9
to
f34e6b6
Compare
f34e6b6
to
017c494
Compare
747e9c3
to
f63c6f1
Compare
017c494
to
14b2f4f
Compare
14b2f4f
to
7d115f5
Compare
7d115f5
to
cd60734
Compare
11c6f30
to
d3a7adc
Compare
c38021a
to
6ee460f
Compare
d3a7adc
to
f83b388
Compare
15d67c8
to
e5bb8f4
Compare
The CurrencyRateController has been migrated to the new base controller. The configuration can now only be set during construction, as it was never changed at runtime in practice with the old controller. Similarly, the `disable` function was removed as it wasn't relied upon in practice. One major change is that the controller doesn't poll after being constructed. The "start" method must be called for polling to start. The "start" and "stop" methods have been added to loosely follow the conventions used in `metamask-extension` to allow starting and stopping polling for the purpose of reducing network traffic. A few tests required substantial updates because of this change. The ComposableController tests were easiest to fix by deleting the use of the CurrencyRateController completely, since that test was intended to test BaseController-based controllers specifically. The last TokenRatesController test managed to mark the state change handlers in that controller as 'covered' without actually asserting anything related to that functionality. That broken test was split into two pieces, one for each state change handler. Those two tests still rely upon mocking a would-be private function, which isn't great, but it matches the patterns used elsewhere in that test module. To improve it would take a great deal of work, enough for a separate PR.
e5bb8f4
to
3947a30
Compare
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.
Just got started on this.
Since mobile wants to continue using it with ComposableController
, why shouldn't we continue to test the CurrencyRateController
in the ComposableController
tests?
The |
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.
Made an initial pass at the controller itself. Moving on to tests.
The `handle` private variable has been renamed to better reflect what it is. Also the type was updated to the more-specific `NodeJS.Timeout`. It seems a bit odd to call this a "timeout" given that it's for a repeating interval, but this is the term the Node.js docs use, and I can't think of a better one.
They've been renamed to match the terms used in the MDN docs.
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!
The CurrencyRateController has been migrated to the new base controller. The configuration can now only be set during construction, as it was never changed at runtime in practice with the old controller. Similarly, the `disable` function was removed as it wasn't relied upon in practice. One major change is that the controller doesn't poll after being constructed. The "start" method must be called for polling to start. The "start" and "stop" methods have been added to loosely follow the conventions used in `metamask-extension` to allow starting and stopping polling for the purpose of reducing network traffic. A few tests required substantial updates because of this change. The ComposableController tests were easiest to fix by deleting the use of the CurrencyRateController completely, since that test was intended to test BaseController-based controllers specifically. The last TokenRatesController test managed to mark the state change handlers in that controller as 'covered' without actually asserting anything related to that functionality. That broken test was split into two pieces, one for each state change handler. Those two tests still rely upon mocking a would-be private function, which isn't great, but it matches the patterns used elsewhere in that test module. To improve it would take a great deal of work, enough for a separate PR.
The CurrencyRateController has been migrated to the new base controller. The configuration can now only be set during construction, as it was never changed at runtime in practice with the old controller. Similarly, the `disable` function was removed as it wasn't relied upon in practice. One major change is that the controller doesn't poll after being constructed. The "start" method must be called for polling to start. The "start" and "stop" methods have been added to loosely follow the conventions used in `metamask-extension` to allow starting and stopping polling for the purpose of reducing network traffic. A few tests required substantial updates because of this change. The ComposableController tests were easiest to fix by deleting the use of the CurrencyRateController completely, since that test was intended to test BaseController-based controllers specifically. The last TokenRatesController test managed to mark the state change handlers in that controller as 'covered' without actually asserting anything related to that functionality. That broken test was split into two pieces, one for each state change handler. Those two tests still rely upon mocking a would-be private function, which isn't great, but it matches the patterns used elsewhere in that test module. To improve it would take a great deal of work, enough for a separate PR.
The CurrencyRateController has been migrated to the new base controller. The configuration can now only be set during construction, as it was never changed at runtime in practice with the old controller. Similarly, the
disable
function was removed as it wasn't relied upon in practice.One major change is that the controller doesn't poll after being constructed. The "start" method must be called for polling to start. The "start" and "stop" methods have been added to loosely follow the conventions used in
metamask-extension
to allow starting and stopping polling for the purpose of reducing network traffic.A few tests required substantial updates because of this change. The ComposableController tests were easiest to fix by deleting the use of the CurrencyRateController completely, since that test was intended to test BaseController-based controllers specifically.
The last TokenRatesController test managed to mark the state change handlers in that controller as 'covered' without actually asserting anything related to that functionality. That broken test was split into two pieces, one for each state change handler. Those two tests still rely upon mocking a would-be private function, which isn't great, but it matches the patterns used elsewhere in that test module. To improve it would take a great deal of work, enough for a separate PR.