Skip to content

Commit

Permalink
test: add
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Mar 30, 2024
1 parent 70f3f2e commit b8fe3e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/clients/transports/http.test.ts
Expand Up @@ -271,7 +271,7 @@ describe('request', () => {
await server.close()
})

test.only('behavior: onFetchRequest', async () => {
test('behavior: onFetchRequest', async () => {
const server = await createHttpServer((_, res) => {
res.end(JSON.stringify({ result: '0x1' }))
})
Expand Down
26 changes: 26 additions & 0 deletions src/utils/rpc/http.test.ts
Expand Up @@ -151,6 +151,32 @@ describe('request', () => {
await server.close()
})

test('onRequest', async () => {
const server = await createHttpServer((_, res) => {
res.end(JSON.stringify({ result: '0x1' }))
})

const requests: Request[] = []
const client = getHttpRpcClient(server.url, {
onRequest: (request) => {
requests.push(request)
},
})
await client.request({
body: { method: 'web3_clientVersion' },
})
await client.request({
body: { method: 'web3_clientVersion' },
onRequest: (request) => {
requests.push(request)
},
})

expect(requests.length).toBe(2)

await server.close()
})

test('onResponse', async () => {
const server = await createHttpServer((_, res) => {
res.end(JSON.stringify({ result: '0x1' }))
Expand Down

0 comments on commit b8fe3e4

Please sign in to comment.