Skip to content

Commit 955fbb8

Browse files
committed
Use random port in JSON-RPC handler test
1 parent 9f162ec commit 955fbb8

File tree

1 file changed

+4
-3
lines changed
  • v-next/hardhat/test/internal/builtin-plugins/node/json-rpc

1 file changed

+4
-3
lines changed

v-next/hardhat/test/internal/builtin-plugins/node/json-rpc/handler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { MockEthereumProvider } from "../../../../utils.js";
2222

2323
describe("JSON-RPC handler", async function () {
2424
const hostname = (await exists("/.dockerenv")) ? "0.0.0.0" : "127.0.0.1";
25-
const port = 8546;
25+
let port: number;
2626
const provider = new MockEthereumProvider({
2727
eth_chainId: "0x7a69", // 31337 in hex
2828
plainError: () => {
@@ -67,12 +67,13 @@ describe("JSON-RPC handler", async function () {
6767
});
6868
const server = new JsonRpcServerImplementation({
6969
hostname,
70-
port,
70+
port: 0, // use a random port
7171
provider,
7272
});
7373

7474
before(async function () {
75-
await server.listen();
75+
const connection = await server.listen();
76+
port = connection.port;
7677
});
7778

7879
after(async function () {

0 commit comments

Comments
 (0)