Skip to content

Commit

Permalink
Caip multichain caip 27 api spec tests (#27229)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This adds api spec tests that utilize `externally_connectable` as well
as `caip-27` requests to wrap the "legacy" api-spec tests.

It refactors a lot into `transform.ts` to help reduce duplication since
we want to test it the same way as our current api-spec tests.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27229?quickstart=1)

## **Related issues**

Fixes:

## **Manual testing steps**

1. `CHAIN_PERMISSIONS=1 BARAD_DUR=1 yarn build:test`
2. `yarn test:api-spec-multichain`
3. see multiple html reporters pop up with all passing.

## **Screenshots/Recordings**
<img width="1309" alt="image"
src="https://github.com/user-attachments/assets/035a1725-b215-4d7c-982c-9867814113b4">

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

---------

Co-authored-by: MetaMask Bot <[email protected]>
  • Loading branch information
shanejonas and metamaskbot authored Sep 25, 2024
1 parent fec21c4 commit dd02132
Show file tree
Hide file tree
Showing 13 changed files with 677 additions and 99 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ licenseInfos.json
# API Spec tests
html-report/
html-report-multichain/
html-report-caip27/

/changed-files
1 change: 1 addition & 0 deletions app/scripts/lib/multichain-api/scope/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const assertScopeSupported = (
const allMethodsSupported = methods.every((method) =>
isSupportedMethod(scopeString, method),
);

if (!allMethodsSupported) {
// not sure which one of these to use
// When provider evaluates requested methods to not be supported
Expand Down
132 changes: 132 additions & 0 deletions html-report-caip27/index.html

Large diffs are not rendered by default.

73 changes: 67 additions & 6 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1459,18 +1459,13 @@
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"jsonschema": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
}
},
"@metamask/message-signing-snap>@noble/ciphers": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -2939,6 +2934,62 @@
"crypto": true
}
},
"@open-rpc/schema-utils-js": {
"packages": {
"@open-rpc/meta-schema": true,
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer": true,
"@open-rpc/schema-utils-js>@json-schema-tools/meta-schema": true,
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": true,
"@open-rpc/schema-utils-js>ajv": true,
"@open-rpc/schema-utils-js>is-url": true,
"eth-rpc-errors>fast-safe-stringify": true
}
},
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer": {
"packages": {
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse": true,
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": true,
"eth-rpc-errors>fast-safe-stringify": true
}
},
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": {
"packages": {
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver>@json-schema-spec/json-pointer": true,
"@open-rpc/test-coverage>isomorphic-fetch": true
}
},
"@open-rpc/schema-utils-js>ajv": {
"globals": {
"console": true
},
"packages": {
"@metamask/snaps-utils>fast-json-stable-stringify": true,
"@open-rpc/schema-utils-js>ajv>json-schema-traverse": true,
"eslint>ajv>uri-js": true,
"eslint>fast-deep-equal": true
}
},
"@open-rpc/test-coverage>isomorphic-fetch": {
"globals": {
"fetch.bind": true
},
"packages": {
"@open-rpc/test-coverage>isomorphic-fetch>whatwg-fetch": true
}
},
"@open-rpc/test-coverage>isomorphic-fetch>whatwg-fetch": {
"globals": {
"AbortController": true,
"Blob": true,
"FileReader": true,
"FormData": true,
"URLSearchParams.prototype.isPrototypeOf": true,
"XMLHttpRequest": true,
"console.warn": true,
"define": true,
"setTimeout": true
}
},
"@popperjs/core": {
"globals": {
"Element": true,
Expand Down Expand Up @@ -3835,6 +3886,11 @@
"koa>is-generator-function>has-tostringtag": true
}
},
"eslint>ajv>uri-js": {
"globals": {
"define": true
}
},
"eth-ens-namehash": {
"globals": {
"name": "write"
Expand Down Expand Up @@ -4571,6 +4627,11 @@
"readable-stream": true
}
},
"jsonschema": {
"packages": {
"browserify>url": true
}
},
"koa>content-disposition>safe-buffer": {
"packages": {
"browserify>buffer": true
Expand Down
73 changes: 67 additions & 6 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1459,18 +1459,13 @@
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"jsonschema": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
}
},
"@metamask/message-signing-snap>@noble/ciphers": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -2939,6 +2934,62 @@
"crypto": true
}
},
"@open-rpc/schema-utils-js": {
"packages": {
"@open-rpc/meta-schema": true,
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer": true,
"@open-rpc/schema-utils-js>@json-schema-tools/meta-schema": true,
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": true,
"@open-rpc/schema-utils-js>ajv": true,
"@open-rpc/schema-utils-js>is-url": true,
"eth-rpc-errors>fast-safe-stringify": true
}
},
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer": {
"packages": {
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse": true,
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": true,
"eth-rpc-errors>fast-safe-stringify": true
}
},
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": {
"packages": {
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver>@json-schema-spec/json-pointer": true,
"@open-rpc/test-coverage>isomorphic-fetch": true
}
},
"@open-rpc/schema-utils-js>ajv": {
"globals": {
"console": true
},
"packages": {
"@metamask/snaps-utils>fast-json-stable-stringify": true,
"@open-rpc/schema-utils-js>ajv>json-schema-traverse": true,
"eslint>ajv>uri-js": true,
"eslint>fast-deep-equal": true
}
},
"@open-rpc/test-coverage>isomorphic-fetch": {
"globals": {
"fetch.bind": true
},
"packages": {
"@open-rpc/test-coverage>isomorphic-fetch>whatwg-fetch": true
}
},
"@open-rpc/test-coverage>isomorphic-fetch>whatwg-fetch": {
"globals": {
"AbortController": true,
"Blob": true,
"FileReader": true,
"FormData": true,
"URLSearchParams.prototype.isPrototypeOf": true,
"XMLHttpRequest": true,
"console.warn": true,
"define": true,
"setTimeout": true
}
},
"@popperjs/core": {
"globals": {
"Element": true,
Expand Down Expand Up @@ -3835,6 +3886,11 @@
"koa>is-generator-function>has-tostringtag": true
}
},
"eslint>ajv>uri-js": {
"globals": {
"define": true
}
},
"eth-ens-namehash": {
"globals": {
"name": "write"
Expand Down Expand Up @@ -4571,6 +4627,11 @@
"readable-stream": true
}
},
"jsonschema": {
"packages": {
"browserify>url": true
}
},
"koa>content-disposition>safe-buffer": {
"packages": {
"browserify>buffer": true
Expand Down
73 changes: 67 additions & 6 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1459,18 +1459,13 @@
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"jsonschema": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
}
},
"@metamask/message-signing-snap>@noble/ciphers": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -2939,6 +2934,62 @@
"crypto": true
}
},
"@open-rpc/schema-utils-js": {
"packages": {
"@open-rpc/meta-schema": true,
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer": true,
"@open-rpc/schema-utils-js>@json-schema-tools/meta-schema": true,
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": true,
"@open-rpc/schema-utils-js>ajv": true,
"@open-rpc/schema-utils-js>is-url": true,
"eth-rpc-errors>fast-safe-stringify": true
}
},
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer": {
"packages": {
"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse": true,
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": true,
"eth-rpc-errors>fast-safe-stringify": true
}
},
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver": {
"packages": {
"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver>@json-schema-spec/json-pointer": true,
"@open-rpc/test-coverage>isomorphic-fetch": true
}
},
"@open-rpc/schema-utils-js>ajv": {
"globals": {
"console": true
},
"packages": {
"@metamask/snaps-utils>fast-json-stable-stringify": true,
"@open-rpc/schema-utils-js>ajv>json-schema-traverse": true,
"eslint>ajv>uri-js": true,
"eslint>fast-deep-equal": true
}
},
"@open-rpc/test-coverage>isomorphic-fetch": {
"globals": {
"fetch.bind": true
},
"packages": {
"@open-rpc/test-coverage>isomorphic-fetch>whatwg-fetch": true
}
},
"@open-rpc/test-coverage>isomorphic-fetch>whatwg-fetch": {
"globals": {
"AbortController": true,
"Blob": true,
"FileReader": true,
"FormData": true,
"URLSearchParams.prototype.isPrototypeOf": true,
"XMLHttpRequest": true,
"console.warn": true,
"define": true,
"setTimeout": true
}
},
"@popperjs/core": {
"globals": {
"Element": true,
Expand Down Expand Up @@ -3835,6 +3886,11 @@
"koa>is-generator-function>has-tostringtag": true
}
},
"eslint>ajv>uri-js": {
"globals": {
"define": true
}
},
"eth-ens-namehash": {
"globals": {
"name": "write"
Expand Down Expand Up @@ -4571,6 +4627,11 @@
"readable-stream": true
}
},
"jsonschema": {
"packages": {
"browserify>url": true
}
},
"koa>content-disposition>safe-buffer": {
"packages": {
"browserify>buffer": true
Expand Down
Loading

0 comments on commit dd02132

Please sign in to comment.