mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-03-21 14:23:10 +00:00
fix: tests
This commit is contained in:
parent
fb1ce98039
commit
7e34e5ba11
@ -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
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user