From c2a0010a74fa6b807f9c88954ef60e3d0365b788 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Fri, 15 Nov 2024 15:09:55 +0100 Subject: [PATCH] [WIP] Test --- .../src/snaps/SnapController.test.tsx | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/snaps-controllers/src/snaps/SnapController.test.tsx b/packages/snaps-controllers/src/snaps/SnapController.test.tsx index a21b00125d..b88d2f1eca 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.test.tsx +++ b/packages/snaps-controllers/src/snaps/SnapController.test.tsx @@ -1033,15 +1033,32 @@ describe('SnapController', () => { }), ); - const snap = await snapController.installSnaps(MOCK_ORIGIN, { + await snapController.installSnaps(MOCK_ORIGIN, { [MOCK_SNAP_ID]: {}, }); - const permissions = (snap[MOCK_SNAP_ID] as Snap).initialPermissions; - - expect(permissions).toStrictEqual({ - [handlerEndowments.onRpcRequest as string]: { snaps: false, dapps: true }, - }); + expect(messenger.call).toHaveBeenNthCalledWith( + 5, + 'PermissionController:grantPermissions', + { + approvedPermissions: { + [SnapEndowments.Rpc]: { + caveats: [ + { type: 'rpcOrigin', value: { dapps: true, snaps: false } }, + ], + }, + }, + subject: { origin: MOCK_SNAP_ID }, + requestData: { + metadata: { + dappOrigin: MOCK_ORIGIN, + id: expect.any(String), + origin: MOCK_SNAP_ID, + }, + snapId: MOCK_SNAP_ID, + }, + }, + ); snapController.destroy(); });