Skip to content

Commit 9c518af

Browse files
committed
test: add 1 more test for full permission revoke if no accounts remain
1 parent 9a87173 commit 9c518af

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/multichain-api-middleware/src/handlers/wallet-revokeSession.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ describe('wallet_revokeSession', () => {
116116
expect(updateCaveat).not.toHaveBeenCalled();
117117
});
118118

119+
it('fully revokes permission when all accounts are removed after scope removal', async () => {
120+
const { handler, getCaveatForOrigin, updateCaveat, revokePermissionForOrigin } = createMockedHandler();
121+
getCaveatForOrigin.mockImplementation(() => ({
122+
value: {
123+
optionalScopes: {
124+
'eip155:1': {
125+
accounts: ['eip155:1:0xdeadbeef'],
126+
},
127+
'eip155:5': {
128+
accounts: ['eip155:5:0xdeadbeef'],
129+
},
130+
},
131+
requiredScopes: {},
132+
},
133+
}));
134+
135+
await handler({ ...baseRequest, params: { scopes: ['eip155:1', 'eip155:5'] } });
136+
expect(updateCaveat).not.toHaveBeenCalled();
137+
expect(revokePermissionForOrigin).toHaveBeenCalledWith(Caip25EndowmentPermissionName);
138+
});
139+
119140
it('returns true if the CAIP-25 endowment permission does not exist', async () => {
120141
const { handler, response, revokePermissionForOrigin } =
121142
createMockedHandler();

0 commit comments

Comments
 (0)