diff --git a/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts b/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts index b2edfdf89858..701e4566e84c 100644 --- a/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts +++ b/packages/rollup-full-node/src/app/test-web3-rpc-handler.ts @@ -81,6 +81,9 @@ export class TestWeb3Handler extends DefaultWeb3Handler { case Web3RpcMethods.revert: this.assertParameters(params, 1) return this.revert(params[0]) + case Web3RpcMethods.accounts: + this.assertParameters(params, 0) + return this.accounts() default: return super.handleRequest(method, params) } @@ -147,4 +150,14 @@ export class TestWeb3Handler extends DefaultWeb3Handler { this.timestampIncreaseSeconds = this.timestampIncreaseSnapshots[snapShotId] return response } + + public async accounts(): Promise { + log.debug('Getting accounts') + const response = await this.context.provider.send( + Web3RpcMethods.accounts, + [] + ) + log.debug(`Received accounts [${response}].`) + return response + } } diff --git a/packages/rollup-full-node/src/types/web3-rpc-handler.ts b/packages/rollup-full-node/src/types/web3-rpc-handler.ts index d8f326a1931f..0dde45c1c019 100644 --- a/packages/rollup-full-node/src/types/web3-rpc-handler.ts +++ b/packages/rollup-full-node/src/types/web3-rpc-handler.ts @@ -47,6 +47,7 @@ export enum Web3RpcMethods { chainId = 'eth_chainId', // Test methods: + accounts = 'eth_accounts', snapshot = 'evm_snapshot', revert = 'evm_revert', mine = 'evm_mine', diff --git a/packages/rollup-full-node/test/app/test-web-rpc-handler.spec.ts b/packages/rollup-full-node/test/app/test-web-rpc-handler.spec.ts index 17b699372a1a..a40dfec84c61 100644 --- a/packages/rollup-full-node/test/app/test-web-rpc-handler.spec.ts +++ b/packages/rollup-full-node/test/app/test-web-rpc-handler.spec.ts @@ -261,4 +261,29 @@ describe('TestHandler', () => { res.should.equal(storageValue) }) }) + + describe('the accounts endpoint', () => { + let testRpcServer + let httpProvider + + beforeEach(async () => { + testRpcServer = new FullnodeRpcServer(testHandler, host, port) + testRpcServer.listen() + httpProvider = new ethers.providers.JsonRpcProvider(baseUrl) + }) + + afterEach(async () => { + await testRpcServer.close() + }) + + it('should get accounts', async () => { + const response = await httpProvider.send('eth_accounts', []) + const addresses = getWallets(httpProvider).map((wallet) => + wallet['signingKey']['address'].toLowerCase() + ) + response + .map((address) => address.toLowerCase()) + .should.have.members(addresses) + }) + }) })