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

chore: split the Connection class into smaller chunks and add unit tests #8074

Merged

Conversation

omridan159
Copy link
Contributor

@omridan159 omridan159 commented Dec 12, 2023

Description

Split the Connection class into smaller chunks to make the code more testable and add unit tests.

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

omridan159 and others added 22 commits December 5, 2023 12:03
…_split-the-SDKConnect-class-into-smaller-chunks
…_split-the-SDKConnect-class-into-smaller-chunks
…_split-the-SDKConnect-class-into-smaller-chunks
@omridan159 omridan159 requested a review from a team as a code owner December 12, 2023 08:01
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (d7869a6) 38.90% compared to head (5407c83) 39.27%.

Files Patch % Lines
...ction/EventListenersHandlers/handleClientsReady.ts 33.33% 6 Missing ⚠️
...n/EventListenersHandlers/handleClientsConnected.ts 66.66% 3 Missing and 1 partial ⚠️
app/core/SDKConnect/Connection/Connection.ts 93.61% 1 Missing and 2 partials ⚠️
.../core/SDKConnect/Connection/Auth/sendAuthorized.ts 80.00% 1 Missing ⚠️
...nnect/Connection/ConnectionLifecycle/disconnect.ts 83.33% 1 Missing ⚠️
...ventListenersHandlers/handleClientsDisconnected.ts 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8074      +/-   ##
==========================================
+ Coverage   38.90%   39.27%   +0.36%     
==========================================
  Files        1198     1208      +10     
  Lines       29729    29738       +9     
  Branches     2829     2828       -1     
==========================================
+ Hits        11566    11679     +113     
+ Misses      17479    17371     -108     
- Partials      684      688       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

andreahaku
andreahaku previously approved these changes Dec 12, 2023
Copy link
Member

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

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

LGTM

@andreahaku andreahaku added team-sdk SDK team Code Impact - Medium Average task code change that can relatively safely being applied to the codebase labels Dec 12, 2023
@omridan159 omridan159 added the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Dec 12, 2023
@andreahaku andreahaku added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) needs-qa Any New Features that needs a full manual QA prior to being added to a release. and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Dec 12, 2023
Base automatically changed from chore_split-the-SDKConnect-class-into-smaller-chunks to main December 12, 2023 17:42
@christopherferreira9 christopherferreira9 dismissed andreahaku’s stale review December 12, 2023 17:42

The base branch was changed.

abretonc7s
abretonc7s previously approved these changes Dec 13, 2023
Copy link
Contributor

@abretonc7s abretonc7s left a comment

Choose a reason for hiding this comment

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

LGTM

Eventually we need to finalize a naming convention and enforce it via linters

Copy link
Member

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

sonarcloud bot commented Dec 13, 2023

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
84.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Issue Package Version Note Source
Deprecated figgy-pudding 3.5.2
  • Reason: This module is no longer supported.
Potential typo squat react-native-search-api 1.0.1

Next steps

What is a deprecated package?

The maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.

Research the state of the package and determine if there are non-deprecated versions that can be used, or if it should be replaced with a new, supported solution.

What is a potential typo squat?

Package name is similar to other popular packages and may not be the package you want.

Use care when consuming similarly named packages and ensure that you did not intend to consume a different package. Malicious packages often publish using similar names as existing popular packages.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore figgy-pudding@3.5.2
  • @SocketSecurity ignore react-native-search-api@1.0.1

@christopherferreira9
Copy link
Contributor

Tests on iOS and Android:

  • Overall smoke with a JS SDK dapp
  • Overall smoke with an iOS SDK dapp
  • Overall smoke with a Unity SDK dapp

@christopherferreira9 christopherferreira9 merged commit 3a887c4 into main Dec 13, 2023
23 of 26 checks passed
@christopherferreira9 christopherferreira9 deleted the chore_split-the-Connection-class-into-smaller-chunks branch December 13, 2023 18:37
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@github-actions github-actions bot removed the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Dec 13, 2023
@metamaskbot metamaskbot added the release-7.15.0 Issue or pull request that will be included in release 7.15.0 label Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Code Impact - Medium Average task code change that can relatively safely being applied to the codebase release-7.15.0 Issue or pull request that will be included in release 7.15.0 team-sdk SDK team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants