From b826e12784e75fb70a9403bcc130c84a86cfd7c2 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Fri, 22 Jul 2022 14:02:00 +0200 Subject: [PATCH] Fix tests after rebase --- packages/controllers/jest.config.js | 8 ++++---- .../src/services/AbstractExecutionService.test.ts | 11 ++++++++--- .../src/services/AbstractExecutionService.ts | 4 ++-- .../controllers/src/snaps/SnapController.test.ts | 12 ++++++------ packages/controllers/src/snaps/SnapController.ts | 1 + packages/execution-environments/jest.config.js | 4 ++-- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/controllers/jest.config.js b/packages/controllers/jest.config.js index 720b43d672..d0341b2d6d 100644 --- a/packages/controllers/jest.config.js +++ b/packages/controllers/jest.config.js @@ -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: { diff --git a/packages/controllers/src/services/AbstractExecutionService.test.ts b/packages/controllers/src/services/AbstractExecutionService.test.ts index 7733067374..60d13eb7e1 100644 --- a/packages/controllers/src/services/AbstractExecutionService.test.ts +++ b/packages/controllers/src/services/AbstractExecutionService.test.ts @@ -1,4 +1,5 @@ import { ControllerMessenger } from '@metamask/controllers'; +import { HandlerType } from '@metamask/execution-environments'; import { ErrorMessageEvent, ExecutionServiceMessenger, @@ -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}".`, diff --git a/packages/controllers/src/services/AbstractExecutionService.ts b/packages/controllers/src/services/AbstractExecutionService.ts index 09d3c59282..3e07ab4dd6 100644 --- a/packages/controllers/src/services/AbstractExecutionService.ts +++ b/packages/controllers/src/services/AbstractExecutionService.ts @@ -99,8 +99,8 @@ export abstract class AbstractExecutionService private registerMessageHandlers(): void { this._messenger.registerActionHandler( `${controllerName}:handleRpcRequest`, - (snapId: string, origin: string, _request: Record) => - this.handleRpcRequest(snapId, origin, _request), + (snapId: string, options: SnapRpcHookArgs) => + this.handleRpcRequest(snapId, options), ); this._messenger.registerActionHandler( diff --git a/packages/controllers/src/snaps/SnapController.test.ts b/packages/controllers/src/snaps/SnapController.test.ts index 964b2e1180..ee1130583d 100644 --- a/packages/controllers/src/snaps/SnapController.test.ts +++ b/packages/controllers/src/snaps/SnapController.test.ts @@ -254,8 +254,8 @@ class ExecutionEnvironmentStub implements ExecutionService { constructor(messenger: ReturnType) { messenger.registerActionHandler( `ExecutionService:handleRpcRequest`, - (snapId: string, origin: string, _request: Record) => - this.handleRpcRequest(snapId, origin, _request), + (snapId: string, options: SnapRpcHookArgs) => + this.handleRpcRequest(snapId, options), ); messenger.registerActionHandler( @@ -275,11 +275,10 @@ class ExecutionEnvironmentStub implements ExecutionService { async handleRpcRequest( snapId: string, - origin: string, - request: Record, + options: SnapRpcHookArgs, ): Promise { const handler = await this.getRpcRequestHandler(snapId); - return handler(origin, request); + return handler(options); } async terminateAllSnaps() { @@ -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, diff --git a/packages/controllers/src/snaps/SnapController.ts b/packages/controllers/src/snaps/SnapController.ts index 982f652756..998598264c 100644 --- a/packages/controllers/src/snaps/SnapController.ts +++ b/packages/controllers/src/snaps/SnapController.ts @@ -55,6 +55,7 @@ import { HandleRpcRequestAction, SnapRpcHook, SnapRpcHookArgs, + TerminateAllSnapsAction, TerminateSnapAction, } from '..'; import { fetchNpmSnap } from './utils'; diff --git a/packages/execution-environments/jest.config.js b/packages/execution-environments/jest.config.js index 7336255782..20d0986150 100644 --- a/packages/execution-environments/jest.config.js +++ b/packages/execution-environments/jest.config.js @@ -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'],