fix: tests

This commit is contained in:
danisharora099 2024-01-10 13:47:32 +05:30
parent fb1ce98039
commit 7e34e5ba11
No known key found for this signature in database
GPG Key ID: FBD2BF500037F135
2 changed files with 11 additions and 21 deletions

View File

@ -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;
@ -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
@ -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
@ -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
@ -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

View File

@ -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";
@ -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);
});
});