Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/rollup-full-node/src/app/test-web3-rpc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -147,4 +150,14 @@ export class TestWeb3Handler extends DefaultWeb3Handler {
this.timestampIncreaseSeconds = this.timestampIncreaseSnapshots[snapShotId]
return response
}

public async accounts(): Promise<string> {
log.debug('Getting accounts')
const response = await this.context.provider.send(
Web3RpcMethods.accounts,
[]
)
log.debug(`Received accounts [${response}].`)
return response
}
}
1 change: 1 addition & 0 deletions packages/rollup-full-node/src/types/web3-rpc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export enum Web3RpcMethods {
chainId = 'eth_chainId',

// Test methods:
accounts = 'eth_accounts',
snapshot = 'evm_snapshot',
revert = 'evm_revert',
mine = 'evm_mine',
Expand Down
25 changes: 25 additions & 0 deletions packages/rollup-full-node/test/app/test-web-rpc-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})