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

Migrate CurrencyRateController to BaseControllerV2 #372

Merged
merged 3 commits into from
May 6, 2021

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Feb 27, 2021

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.

@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from 1ffff86 to eb26f36 Compare February 27, 2021 17:30
Base automatically changed from add-base-controller-metadata to develop March 2, 2021 16:16
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from eb26f36 to fa0d1b9 Compare March 3, 2021 01:00
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from fa0d1b9 to f34e6b6 Compare April 15, 2021 16:21
@Gudahtt Gudahtt changed the base branch from develop to replace-composable-controller April 15, 2021 16:21
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from f34e6b6 to 017c494 Compare April 15, 2021 16:23
@Gudahtt Gudahtt force-pushed the replace-composable-controller branch from 747e9c3 to f63c6f1 Compare April 15, 2021 17:34
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from 017c494 to 14b2f4f Compare April 15, 2021 17:46
Base automatically changed from replace-composable-controller to develop April 15, 2021 18:07
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from 14b2f4f to 7d115f5 Compare April 15, 2021 18:16
@rekmarks rekmarks removed the blocked label Apr 19, 2021
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from 7d115f5 to cd60734 Compare April 19, 2021 19:44
@Gudahtt Gudahtt changed the base branch from develop to composed-controller-v2-compatibility April 19, 2021 19:44
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch 2 times, most recently from 11c6f30 to d3a7adc Compare April 19, 2021 20:13
@Gudahtt
Copy link
Member Author

Gudahtt commented Apr 19, 2021

This depends upon #446 and #447

@Gudahtt Gudahtt force-pushed the composed-controller-v2-compatibility branch from c38021a to 6ee460f Compare April 19, 2021 21:37
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from d3a7adc to f83b388 Compare April 19, 2021 21:39
Base automatically changed from composed-controller-v2-compatibility to develop April 22, 2021 21:49
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch 5 times, most recently from 15d67c8 to e5bb8f4 Compare May 3, 2021 21:38
@Gudahtt Gudahtt marked this pull request as ready for review May 3, 2021 21:44
@Gudahtt Gudahtt requested a review from a team as a code owner May 3, 2021 21:44
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.
@Gudahtt Gudahtt force-pushed the migrate-currency-rate-controller branch from e5bb8f4 to 3947a30 Compare May 3, 2021 21:45
Copy link
Member

@rekmarks rekmarks left a 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?

@Gudahtt
Copy link
Member Author

Gudahtt commented May 4, 2021

The ComposableController has a separate set of unit tests for BaseControllerV2-based controllers (and combinations of both). The test it was removed from was specific to original BaseController controllers, and the CurrencyRateController didn't play any important role in that test (it was just a random assortment of controllers to use as examples).

Copy link
Member

@rekmarks rekmarks left a 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.

src/assets/CurrencyRateController.ts Outdated Show resolved Hide resolved
src/assets/CurrencyRateController.ts Show resolved Hide resolved
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.
@rekmarks rekmarks self-assigned this May 5, 2021
src/assets/CurrencyRateController.test.ts Show resolved Hide resolved
src/assets/CurrencyRateController.ts Outdated Show resolved Hide resolved
They've been renamed to match the terms used in the MDN docs.
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

LGTM!

@Gudahtt Gudahtt merged commit ae510e6 into develop May 6, 2021
@Gudahtt Gudahtt deleted the migrate-currency-rate-controller branch May 6, 2021 13:51
@Gudahtt Gudahtt mentioned this pull request May 18, 2021
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
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.
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants