feat: clean up new controller #7714
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
This PR adds comprehensive unit tests for the new
@metamask/assets-controllerpackage to ensure code quality and maintainability.Current state: The assets-controller package was recently introduced with a middleware-based architecture for unified asset management across all blockchain networks. However, test coverage was limited, leaving critical code paths untested.
Changes in this PR:
AccountsApiDataSource(18 tests, includes timer cleanup fix using.unref()to prevent Jest worker process hanging)BackendWebsocketDataSource(19 tests)PriceDataSource(29 tests)TokenDataSource(20 tests)SnapDataSource(47 tests)DetectionMiddleware(13 tests, 100% coverage)AssetsController(42 tests, coverage increased from 33% to 81%)Test architecture patterns used:
setupController/withControllerhelper functions for consistent test setupMOCK_ANY_NAMESPACEit.eachfor parameterized tests where applicableReferences
Checklist
Note
Significantly increases test coverage and validates core behaviors across the new middleware-based assets stack.
AssetsController,DetectionMiddleware, and data sources:AbstractDataSource,AccountsApiDataSource,BackendWebsocketDataSource,PriceDataSource,RpcDataSource, andSnapDataSourceRpcDataSourceto importBalanceFetcher,MulticallClient, andTokenDetectorfromevm-rpc-services(wasrpc-datasource)CHANGELOG.mdto note test additionsWritten by Cursor Bugbot for commit 9b08b0a. This will update automatically on new commits. Configure here.