diff --git a/packages/snaps-simulator/src/features/simulation/middleware.test.ts b/packages/snaps-simulator/src/features/simulation/middleware.test.ts index 893caa08a0..3e3e1078ab 100644 --- a/packages/snaps-simulator/src/features/simulation/middleware.test.ts +++ b/packages/snaps-simulator/src/features/simulation/middleware.test.ts @@ -1,11 +1,15 @@ +import { mnemonicPhraseToBytes } from '@metamask/key-tree'; import { JsonRpcEngine } from 'json-rpc-engine'; +import { DEFAULT_SRP } from '../configuration'; import { createMiscMethodMiddleware } from './middleware'; +const hooks = { getMnemonic: async () => mnemonicPhraseToBytes(DEFAULT_SRP) }; + describe('createMiscMethodMiddleware', () => { it('supports metamask_getProviderState', async () => { const engine = new JsonRpcEngine(); - engine.push(createMiscMethodMiddleware()); + engine.push(createMiscMethodMiddleware(hooks)); const response = await engine.handle({ jsonrpc: '2.0', @@ -25,4 +29,40 @@ describe('createMiscMethodMiddleware', () => { }, }); }); + + it('supports eth_accounts', async () => { + const engine = new JsonRpcEngine(); + engine.push(createMiscMethodMiddleware(hooks)); + + const response = await engine.handle({ + jsonrpc: '2.0', + id: 1, + method: 'eth_accounts', + params: [], + }); + + expect(response).toStrictEqual({ + id: 1, + jsonrpc: '2.0', + result: ['0xc6d5a3c98ec9073b54fa0969957bd582e8d874bf'], + }); + }); + + it('supports eth_requestAccounts', async () => { + const engine = new JsonRpcEngine(); + engine.push(createMiscMethodMiddleware(hooks)); + + const response = await engine.handle({ + jsonrpc: '2.0', + id: 1, + method: 'eth_requestAccounts', + params: [], + }); + + expect(response).toStrictEqual({ + id: 1, + jsonrpc: '2.0', + result: ['0xc6d5a3c98ec9073b54fa0969957bd582e8d874bf'], + }); + }); });