Skip to content

Commit

Permalink
Use process execution service for network access example (#2177)
Browse files Browse the repository at this point in the history
This (hopefully) fixes the network access example E2Es sometimes getting
stuck.
  • Loading branch information
Mrtenz authored Feb 9, 2024
1 parent 1ada339 commit 01829d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/examples/packages/network-access/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/snaps-cli": "workspace:^",
"@metamask/snaps-controllers": "workspace:^",
"@metamask/snaps-jest": "workspace:^",
"@swc/core": "1.3.78",
"@swc/jest": "^0.2.26",
Expand Down
9 changes: 7 additions & 2 deletions packages/examples/packages/network-access/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { expect } from '@jest/globals';
import { NodeProcessExecutionService } from '@metamask/snaps-controllers';
import { installSnap } from '@metamask/snaps-jest';

describe('onRpcRequest', () => {
it('throws an error if the requested method does not exist', async () => {
const { request } = await installSnap();
const { request } = await installSnap({
executionService: NodeProcessExecutionService,
});

const response = await request({
method: 'foo',
Expand All @@ -22,7 +25,9 @@ describe('onRpcRequest', () => {

describe('fetch', () => {
it('fetches a URL and returns the JSON response', async () => {
const { request } = await installSnap();
const { request } = await installSnap({
executionService: NodeProcessExecutionService,
});

const url = 'https://dummyjson.com/http/200';
const response = await request({
Expand Down
3 changes: 3 additions & 0 deletions packages/examples/packages/network-access/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
},
{
"path": "../../../snaps-cli"
},
{
"path": "../../../snaps-controllers"
}
]
}
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4872,6 +4872,7 @@ __metadata:
"@metamask/eslint-config-typescript": ^12.1.0
"@metamask/rpc-errors": ^6.1.0
"@metamask/snaps-cli": "workspace:^"
"@metamask/snaps-controllers": "workspace:^"
"@metamask/snaps-jest": "workspace:^"
"@metamask/snaps-sdk": "workspace:^"
"@metamask/utils": ^8.3.0
Expand Down

0 comments on commit 01829d3

Please sign in to comment.