Skip to content

Commit

Permalink
Merge pull request #2422 from NomicFoundation/fix-core-tests
Browse files Browse the repository at this point in the history
Use a low keepAlive in the tests http provider
  • Loading branch information
fvictorio authored Feb 28, 2022
2 parents 10291cb + 7188f06 commit 8d2c577
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type WsT from "ws";
import debug from "debug";
import http, { Server } from "http";
import { AddressInfo } from "net";
import { Client } from "undici";

import {
EIP1193Provider,
Expand Down Expand Up @@ -43,9 +44,20 @@ export class JsonRpcServer implements IJsonRpcServer {
}

public getProvider = (name = "json-rpc"): EIP1193Provider => {
const { address, port } = this._httpServer.address() as AddressInfo; // TCP sockets return AddressInfo
const { address, port } = this._httpServer.address() as AddressInfo;

return new HttpProvider(`http://${address}:${port}/`, name);
const dispatcher = new Client(`http://${address}:${port}/`, {
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
});

return new HttpProvider(
`http://${address}:${port}/`,
name,
{},
20000,
dispatcher
);
};

public listen = (): Promise<{ address: string; port: number }> => {
Expand Down

0 comments on commit 8d2c577

Please sign in to comment.