Skip to content

Commit

Permalink
Fix tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding authored and hmalik88 committed Aug 10, 2022
1 parent 450b290 commit b826e12
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
8 changes: 4 additions & 4 deletions packages/controllers/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module.exports = {
coveragePathIgnorePatterns: ['/node_modules/', '/mocks/', '/test/'],
coverageThreshold: {
global: {
branches: 72.31,
functions: 86.32,
lines: 85.23,
statements: 85.31,
branches: 72.83,
functions: 86.38,
lines: 85.42,
statements: 85.5,
},
},
globals: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ControllerMessenger } from '@metamask/controllers';
import { HandlerType } from '@metamask/execution-environments';
import {
ErrorMessageEvent,
ExecutionServiceMessenger,
Expand Down Expand Up @@ -127,9 +128,13 @@ describe('AbstractExecutionService', () => {

const snapId = 'TestSnap';
await expect(
service.handleRpcRequest(snapId, 'foo.com', {
id: 6,
method: 'bar',
service.handleRpcRequest(snapId, {
origin: 'foo.com',
handler: HandlerType.onRpcRequest,
request: {
id: 6,
method: 'bar',
},
}),
).rejects.toThrow(
`Snap execution service returned no RPC handler for running snap "${snapId}".`,
Expand Down
4 changes: 2 additions & 2 deletions packages/controllers/src/services/AbstractExecutionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export abstract class AbstractExecutionService<WorkerType>
private registerMessageHandlers(): void {
this._messenger.registerActionHandler(
`${controllerName}:handleRpcRequest`,
(snapId: string, origin: string, _request: Record<string, unknown>) =>
this.handleRpcRequest(snapId, origin, _request),
(snapId: string, options: SnapRpcHookArgs) =>
this.handleRpcRequest(snapId, options),
);

this._messenger.registerActionHandler(
Expand Down
12 changes: 6 additions & 6 deletions packages/controllers/src/snaps/SnapController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ class ExecutionEnvironmentStub implements ExecutionService {
constructor(messenger: ReturnType<typeof getNodeEESMessenger>) {
messenger.registerActionHandler(
`ExecutionService:handleRpcRequest`,
(snapId: string, origin: string, _request: Record<string, unknown>) =>
this.handleRpcRequest(snapId, origin, _request),
(snapId: string, options: SnapRpcHookArgs) =>
this.handleRpcRequest(snapId, options),
);

messenger.registerActionHandler(
Expand All @@ -275,11 +275,10 @@ class ExecutionEnvironmentStub implements ExecutionService {

async handleRpcRequest(
snapId: string,
origin: string,
request: Record<string, unknown>,
options: SnapRpcHookArgs,
): Promise<unknown> {
const handler = await this.getRpcRequestHandler(snapId);
return handler(origin, request);
return handler(options);
}

async terminateAllSnaps() {
Expand Down Expand Up @@ -1597,9 +1596,10 @@ describe('SnapController', () => {
method: 'bar',
});

expect(spyOnMessengerCall).toHaveBeenCalledTimes(1);
expect(spyOnMessengerCall).toHaveBeenCalledTimes(2);
expect(spyOnMessengerCall).toHaveBeenCalledWith(
'ExecutionService:handleRpcRequest',
snapId,
{
origin: 'foo.com',
handler: HandlerType.onRpcRequest,
Expand Down
1 change: 1 addition & 0 deletions packages/controllers/src/snaps/SnapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
HandleRpcRequestAction,
SnapRpcHook,
SnapRpcHookArgs,
TerminateAllSnapsAction,
TerminateSnapAction,
} from '..';
import { fetchNpmSnap } from './utils';
Expand Down
4 changes: 2 additions & 2 deletions packages/execution-environments/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module.exports = {
coverageReporters: ['clover', 'json', 'lcov', 'text', 'json-summary'],
coverageThreshold: {
global: {
branches: 85.28,
branches: 85.27,
functions: 92.59,
lines: 86.41,
statements: 86.64,
statements: 86.63,
},
},
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
Expand Down

0 comments on commit b826e12

Please sign in to comment.