Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Conversation

@mikesposito
Copy link
Member

@mikesposito mikesposito commented Nov 28, 2023

Description

This PR increases the unit test coverage of the controller.

Current change:

branches    80.18 → 90.09  +9.91
functions   93.54 → 96.77  +3.23
lines       91.69 → 97.44  +5.75
statements  91.87 → 97.5  +5.63

Changes

n/a

References

n/a

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation for new or updated code as appropriate (note: this will usually be JSDoc)
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@mikesposito mikesposito requested a review from a team as a code owner November 28, 2023 11:10
@mikesposito mikesposito force-pushed the bump-coverage branch 2 times, most recently from b3cec81 to aa1c9ac Compare November 28, 2023 12:57
Gudahtt
Gudahtt previously approved these changes Nov 29, 2023
Copy link
Member

@Gudahtt Gudahtt 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 previously approved these changes Nov 29, 2023
mikesposito and others added 3 commits January 15, 2024 15:27
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* feat: add UserOperation methods

* build: ignore errors from Snap packages

* fix: fix return type of `prepareUserOperation`

* chore: enable lcov coverage

* test: add missing unit tests

* chore: update `yarn.lock`

* chore: apply linter

* chore: update @metamask/keyring-api version to 2.0.0
@mikesposito mikesposito requested a review from Gudahtt January 15, 2024 14:58
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for doing this. All of my comments are minor, but it might be nice to be a bit more descriptive with the test names.

});

describe('signMessage', () => {
it('should sign message', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we go into a little more detail on what the expected behavior here is? What does "signing" mean? It looks like the input data is encrypted using the seed phrase? Does signMessage on the keyring do most of the work? If so, it might be important to highlight the keyring being used in this test, since the exact keyring being used affects the signing.

Copy link
Member Author

Choose a reason for hiding this comment

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

The data is usually a digest of the message encoded as hex (so it is not encrypted, just hashed with keccak256), ready to be signed with an ecdsa private key, that in our case is handled by the Keyring linked to the from account.

So, the target Keyring must indeed support the signMessage method, and the "real work" is done by it.

Because of this, I would be inclined to change it to forwards the message to the keyring for signing (using signTransaction tests as an example) - but on the other hand this test case doesn't only check if the message gets forwarded to the Keyring: it also checks for the signature correctness, and this is the reason why we use a seed phrase with a known and predictable first-account-address

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, yeah that's a bit tricky. Okay, perhaps we can think of a better name later.

@mikesposito mikesposito merged commit 9d0b37f into main Jan 18, 2024
@mikesposito mikesposito deleted the bump-coverage branch January 18, 2024 09:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team-accounts This should be handled by the Accounts Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants