Skip to content

Commit 5bdee7f

Browse files
committed
Add tests
1 parent 92a1921 commit 5bdee7f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

v-next/hardhat/test/internal/builtin-plugins/network-manager/edr/edr-provider.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,17 @@ describe("edr-provider", () => {
470470
{},
471471
);
472472
});
473+
474+
it("should remove all listeners after closing", async () => {
475+
const connection = await hre.network.connect();
476+
477+
connection.provider.on("notification", () => {});
478+
assert.equal(connection.provider.listenerCount("notification"), 1);
479+
480+
await connection.provider.close();
481+
482+
assert.equal(connection.provider.listenerCount("notification"), 0);
483+
});
473484
});
474485

475486
describe("isDefaultEdrNetworkHDAccountsConfig", () => {

v-next/hardhat/test/internal/builtin-plugins/network-manager/http-provider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,5 +579,20 @@ describe("http-provider", () => {
579579
{},
580580
);
581581
});
582+
583+
it("should remove all listeners after closing", async () => {
584+
const provider = await HttpProvider.create({
585+
url: "http://localhost",
586+
networkName: "exampleNetwork",
587+
timeout: 20_000,
588+
});
589+
590+
provider.on("notification", () => {});
591+
assert.equal(provider.listenerCount("notification"), 1);
592+
593+
await provider.close();
594+
595+
assert.equal(provider.listenerCount("notification"), 0);
596+
});
582597
});
583598
});

0 commit comments

Comments
 (0)