Skip to content

Commit d53eddb

Browse files
add test to check for active connections
1 parent ca17b30 commit d53eddb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/tests/tests/metadata.spec.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { NimGoNode } from "../src/node/node.js";
1111

1212
chai.use(chaiAsPromised);
1313

14-
describe("Metadata Protocol", () => {
14+
describe.only("Metadata Protocol", () => {
1515
let waku: LightNode;
1616
let nwaku1: NimGoNode;
1717

@@ -52,6 +52,9 @@ describe("Metadata Protocol", () => {
5252
expect(shardInfoRes).to.not.be.undefined;
5353
expect(shardInfoRes?.clusterId).to.equal(shardInfo.clusterId);
5454
expect(shardInfoRes?.shards).to.deep.equal(shardInfo.shards);
55+
56+
const activeConnections = waku.libp2p.getConnections();
57+
expect(activeConnections.length).to.equal(1);
5558
});
5659

5760
it("same cluster, different shard: nodes connect", async function () {
@@ -87,6 +90,9 @@ describe("Metadata Protocol", () => {
8790
expect(shardInfoRes).to.not.be.undefined;
8891
expect(shardInfoRes?.clusterId).to.equal(shardInfo1.clusterId);
8992
expect(shardInfoRes?.shards).to.deep.equal(shardInfo1.shards);
93+
94+
const activeConnections = waku.libp2p.getConnections();
95+
expect(activeConnections.length).to.equal(1);
9096
});
9197

9298
it("different cluster, same shard: nodes don't connect", async function () {
@@ -120,6 +126,9 @@ describe("Metadata Protocol", () => {
120126
await expect(
121127
waku.libp2p.services.metadata?.query(nwaku1PeerId)
122128
).to.be.rejectedWith("the connection is being closed");
129+
130+
const activeConnections = waku.libp2p.getConnections();
131+
expect(activeConnections.length).to.equal(0);
123132
});
124133

125134
it("different cluster, different shard: nodes don't connect", async function () {
@@ -153,5 +162,8 @@ describe("Metadata Protocol", () => {
153162
await expect(
154163
waku.libp2p.services.metadata?.query(nwaku1PeerId)
155164
).to.be.rejectedWith("the connection is being closed");
165+
166+
const activeConnections = waku.libp2p.getConnections();
167+
expect(activeConnections.length).to.equal(0);
156168
});
157169
});

0 commit comments

Comments
 (0)