Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Jan 10, 2024
1 parent fb1ce98 commit 7e34e5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
16 changes: 10 additions & 6 deletions packages/tests/tests/getPeers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
ShardInfo
} from "@waku/sdk";
import { shardInfoToPubsubTopics } from "@waku/utils";
import { getPeersForProtocolAndShard } from "@waku/utils/libp2p";
import { getConnectedPeersForProtocolAndShard } from "@waku/utils/libp2p";
import { expect } from "chai";

import { makeLogFileName } from "../src/log_file.js";
import { NimGoNode } from "../src/node/node.js";
import { tearDownNodes } from "../src/teardown.js";

describe("getPeersForProtocolAndShard", function () {
describe("getConnectedPeersForProtocolAndShard", function () {
let waku: LightNode;
let serviceNode1: NimGoNode;
let serviceNode2: NimGoNode;
Expand Down Expand Up @@ -51,7 +51,8 @@ describe("getPeersForProtocolAndShard", function () {
await waku.start();
await waku.libp2p.dialProtocol(serviceNodeMa, LightPushCodec);
await waitForRemotePeer(waku, [Protocols.LightPush]);
const peers = await getPeersForProtocolAndShard(
const peers = await getConnectedPeersForProtocolAndShard(
waku.libp2p.getConnections(),
waku.libp2p.peerStore,
waku.libp2p.getProtocols(),
shardInfo
Expand Down Expand Up @@ -82,7 +83,8 @@ describe("getPeersForProtocolAndShard", function () {
await waku.start();
await waitForRemotePeer(waku, [Protocols.LightPush]);

const peers = await getPeersForProtocolAndShard(
const peers = await getConnectedPeersForProtocolAndShard(
waku.libp2p.getConnections(),
waku.libp2p.peerStore,
waku.libp2p.getProtocols(),
shardInfo
Expand Down Expand Up @@ -131,7 +133,8 @@ describe("getPeersForProtocolAndShard", function () {
await waku.start();
await waitForRemotePeer(waku, [Protocols.LightPush]);

const peers = await getPeersForProtocolAndShard(
const peers = await getConnectedPeersForProtocolAndShard(
waku.libp2p.getConnections(),
waku.libp2p.peerStore,
waku.libp2p.getProtocols(),
shardInfo2
Expand Down Expand Up @@ -180,7 +183,8 @@ describe("getPeersForProtocolAndShard", function () {
await waku.start();
await waitForRemotePeer(waku, [Protocols.LightPush]);

const peers = await getPeersForProtocolAndShard(
const peers = await getConnectedPeersForProtocolAndShard(
waku.libp2p.getConnections(),
waku.libp2p.peerStore,
waku.libp2p.getProtocols(),
shardInfo2
Expand Down
16 changes: 1 addition & 15 deletions packages/tests/tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import type { PeerStore } from "@libp2p/interface/peer-store";
import type { Peer } from "@libp2p/interface/peer-store";
import { createSecp256k1PeerId } from "@libp2p/peer-id-factory";
import { createDecoder, createEncoder, waitForRemotePeer } from "@waku/core";
import { LightPushCodec } from "@waku/core";
import { DefaultPubsubTopic, LightNode } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { createLightNode } from "@waku/sdk";
import { toAsyncIterator } from "@waku/utils";
import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
import {
getConnectedPeersForProtocol,
selectPeerForProtocol
} from "@waku/utils/libp2p";
import { selectPeerForProtocol } from "@waku/utils/libp2p";
import chai, { expect } from "chai";
import chaiAsPromised from "chai-as-promised";
import sinon from "sinon";
Expand Down Expand Up @@ -288,14 +284,4 @@ describe("getConnectedPeersForProtocol", function () {
this.timeout(10000);
await tearDownNodes(nwaku, waku);
});

it("returns all connected peers that support the protocol", async function () {
const peers = await getConnectedPeersForProtocol(
waku.libp2p.getConnections(),
waku.libp2p.peerStore,
[LightPushCodec]
);

expect(peers.length).to.eq(1);
});
});

0 comments on commit 7e34e5b

Please sign in to comment.