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

test: increase test coverage #51

Merged
merged 79 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
30c5dba
Init: broke up config validation into separate function in keyring an…
k-g-j Feb 13, 2024
2e40b58
Debuging: aaOwnerPK is undefined in config tests
k-g-j Feb 14, 2024
1d74c48
Feat: moved ChainConfig validation into util and changed test to dyna…
k-g-j Feb 14, 2024
da24aca
Feat: added JSDoc comments to public Keyring methods
k-g-j Feb 14, 2024
3014b85
Fix: eslint errors
k-g-j Feb 14, 2024
86d76d9
Fix: remove localhost:8080 from allowed origins
k-g-j Feb 14, 2024
d0dff9d
Feat: implemented superstruct in validation util
k-g-j Feb 15, 2024
54c5cd5
Fix: lint errors
k-g-j Feb 15, 2024
6d8bd61
Init: added jest coverage script to snap
k-g-j Feb 15, 2024
20c3c90
Fix: duplicate address checks for AA address not admin
k-g-j Feb 15, 2024
7de1e38
Feat: added listAccounts test and fixed bugs in test setup
k-g-j Feb 15, 2024
22f9b7b
Debugging: account collision test
k-g-j Feb 16, 2024
d2303e6
Feat: Update validation.ts to invert throw condition
k-g-j Feb 16, 2024
ba7c204
Moved chain config keys and errors into constant and changed pk valid…
k-g-j Feb 16, 2024
703efa7
Fix: changed JSDOC from account abstraction keyring account to smart …
k-g-j Feb 16, 2024
60ee50b
Fix: update ethereum address validation to use metamask utils function
k-g-j Feb 16, 2024
419bc60
Feat: moved constants into proper folder and updated url regex and co…
k-g-j Feb 16, 2024
32bb109
Fix: rebuilt shasum
k-g-j Feb 16, 2024
de1bcde
Fix: update shasum conflicts
k-g-j Feb 16, 2024
ee4910d
Merge branch 'main' into feat/improve-code-quality
k-g-j Feb 16, 2024
c85db80
Fix: lint errors
k-g-j Feb 16, 2024
1c09e95
Merge remote-tracking branch 'origin/feat/improve-code-quality' into …
k-g-j Feb 16, 2024
4f1b96a
Updating deploy account collision testing
k-g-j Feb 20, 2024
67dceeb
Fix: build clean test
k-g-j Feb 20, 2024
301fb96
Fix: fixed typos in set config test it statements
k-g-j Feb 20, 2024
39e96b5
Feat: updated chain config validation to use 'exactOptional'
k-g-j Feb 20, 2024
72b1f88
Merge remote-tracking branch 'origin/feat/improve-code-quality' into …
k-g-j Feb 20, 2024
6141c98
Fix: consistent spacing in beforeEach hooks
k-g-j Feb 20, 2024
ed00aee
Merge remote-tracking branch 'origin/feat/improve-code-quality' into …
k-g-j Feb 20, 2024
584f397
Feat: implemented filterAccountChains test
k-g-j Feb 20, 2024
1b3c1b4
Feat: added test for updateAccount
k-g-j Feb 20, 2024
820dc73
Feat: added deleteAccount tests
k-g-j Feb 20, 2024
b8563f1
Feat: added tests for catch when saveState fails
k-g-j Feb 20, 2024
59ccd7f
Fix: added length check to private key validation
k-g-j Feb 20, 2024
2004df7
Merge remote-tracking branch 'origin/feat/improve-code-quality' into …
k-g-j Feb 20, 2024
b5c2b22
Feat: added tests for approve, reject, and submit requests
k-g-j Feb 20, 2024
098450b
Fix: only statements in test
k-g-j Feb 20, 2024
64f1c3a
reorganized tests and added TODO note
k-g-j Feb 20, 2024
ad64895
Init: remove 'pendingRequests' from KeyringState and associated methods
k-g-j Feb 20, 2024
462c270
Merge remote-tracking branch 'origin/main' into feat/remove-async-flo…
k-g-j Feb 21, 2024
a154268
Feat: merged with latest changes on main branch
k-g-j Feb 21, 2024
ce5d548
Merge remote-tracking branch 'origin/main' into feat/remove-async-flo…
k-g-j Feb 21, 2024
34bff80
Fix: rebuilt clean shasum
k-g-j Feb 21, 2024
50f7054
Merge remote-tracking branch 'origin/main' into feat/remove-async-flo…
k-g-j Feb 21, 2024
6674a50
Feat: removed async methods and request methods from front end
k-g-j Feb 21, 2024
3b4c0c8
Merge remote-tracking branch 'origin/main' into feat/increase-test-co…
k-g-j Feb 21, 2024
c560289
Fix: updated tests to match current refactors in main for setConfig
k-g-j Feb 21, 2024
c975928
Fix: lint errors for unused vars for requestId and pendingRequestId
k-g-j Feb 21, 2024
af528a0
Merge branch 'feat/remove-async-flow-methods' into feat/increase-test…
k-g-j Feb 21, 2024
bd34875
Feat: added test for getWalletById for non-existent ID
k-g-j Feb 21, 2024
7dde88d
Feat: added test for invalid private key in create account
k-g-j Feb 21, 2024
e282c8c
Merge branch 'main' into feat/increase-test-coverage
k-g-j Feb 22, 2024
0ff0209
Feat: added test for unsupported chain check
k-g-j Feb 22, 2024
81fd997
Feat: added test for transactions length in prepareUserOp
k-g-j Feb 22, 2024
3622413
Feat: added test for 0x when not setting paymaster and unsupport chai…
k-g-j Feb 22, 2024
6066516
Feat: reorganized tests for private methods
k-g-j Feb 22, 2024
4040736
Fix: lint errors and rebuilt snap
k-g-j Feb 22, 2024
4ddafb2
Feat: added KeyringState to getInitialState in test
k-g-j Feb 27, 2024
b1c79b4
Feat: added scope to keyring request tests and validation for scope w…
k-g-j Feb 28, 2024
10b4e73
Feat: set jest threshold and added scope to syncSubmitRequest
k-g-j Feb 29, 2024
5f5e26a
Fix: reverted using jest.fn to mock uuid in tests
k-g-j Mar 5, 2024
1aae6a3
Fix: check for '#doesAccountSupportChain' to use that the scope exist…
k-g-j Mar 5, 2024
9f22b45
Fix: lint errors
k-g-j Mar 5, 2024
c5a0ecc
Fix: rebuilt snap
k-g-j Mar 5, 2024
b568fd8
Fix: updated coverage threshold to only include 'keyring.ts' and fixe…
k-g-j Mar 5, 2024
95d3b99
feat: used metamask utils function to parse scope and validate in sub…
k-g-j Mar 6, 2024
866b34c
Feat: implemented caip util and refactored scope and chain parsing lo…
k-g-j Mar 6, 2024
c229f6d
Refactor: changed 'aaOwnerPk' to 'aaOwnerSk' for accuracy
k-g-j Mar 6, 2024
79736ab
Refactor: use jest extended and 'toIncludeSameMembers'
k-g-j Mar 6, 2024
36e7162
Refactor: moved 'non-existent-id' into variable
k-g-j Mar 6, 2024
a1cea9c
Refactor: moved nonExistentAccountId into global constant in tests
k-g-j Mar 6, 2024
0188d49
Refactor: moved save state failures in test into helper function and …
k-g-j Mar 6, 2024
67263a2
Fix: rebuilt snap
k-g-j Mar 6, 2024
0a6e970
Refactor: use 'toCaipChainId' util instead of string interpolation
k-g-j Mar 7, 2024
1615c23
Fix: rebuilt snap
k-g-j Mar 7, 2024
e1c4fcc
Fix: scope check and not chainId check in prepareUserOp
k-g-j Mar 7, 2024
3549eca
Feat: use toCaipChainId in test for unsupported chain
k-g-j Mar 7, 2024
bb80a9a
Fix: rebuilt snap
k-g-j Mar 7, 2024
18da79e
Doc: added comment explaining UUID mock in test
k-g-j Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@emotion/styled": "^11.11.0",
"@metamask/keyring-api": "^3.0.0",
"@metamask/providers": "^14.0.2",
"@metamask/snap-account-abstraction-keyring": "workspace:^",
"@mui/icons-material": "^5.14.0",
"@mui/material": "^5.14.0",
"@types/react-helmet": "^6.1.6",
Expand Down
10 changes: 9 additions & 1 deletion packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';
import { KeyringSnapRpcClient } from '@metamask/keyring-api';
import {
CaipNamespaces,
toCaipChainId,
} from '@metamask/snap-account-abstraction-keyring/src/utils/caip';
import Grid from '@mui/material/Grid';
import React, { useContext, useEffect, useState } from 'react';
import * as uuid from 'uuid';
Expand Down Expand Up @@ -99,9 +103,13 @@ const Index = () => {
if (!chainConfig) {
return;
}
const reference = window.ethereum.chainId;
if (!reference) {
throw new Error('No chain ID found');
}
const request: KeyringRequest = {
id: uuid.v4(),
scope: '',
scope: `${toCaipChainId(CaipNamespaces.Eip155, reference)}`,
account: uuid.v4(),
request: {
method: 'snap.internal.setConfig',
Expand Down
7 changes: 7 additions & 0 deletions packages/snap/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ module.exports = {
'contracts',
'artifacts',
],
coverageThreshold: {
'./src/keyring.ts': {
statements: 95,
functions: 95,
lines: 95,
},
},
};
4 changes: 3 additions & 1 deletion packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"lint:types": "tsc --noEmit",
"serve": "mm-snap serve",
"start": "NODE_ENV='development' mm-snap watch",
"test": "jest --detectOpenHandles"
"test": "jest --detectOpenHandles",
"test:coverage": "jest --detectOpenHandles --coverage"
},
"dependencies": {
"@ethereumjs/tx": "^5.1.0",
Expand Down Expand Up @@ -86,6 +87,7 @@
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.8",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"solidity-coverage": "^0.8.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "git+https://github.com/MetaMask/snap-account-abstraction-keyring.git"
},
"source": {
"shasum": "WfB+J7Rzl/po7NKMCmFe9KLNUfps/dncIaWtCm/WvWQ=",
"shasum": "yGUjODv2K9nZZ0a2us4NLGJPmV61Rtz0tXoIKOB00cU=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Loading
Loading