Skip to content

Commit

Permalink
change tests to use new API
Browse files Browse the repository at this point in the history
  • Loading branch information
weboko committed Oct 4, 2024
1 parent 9267c70 commit 440f908
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getPublicKey,
symmetric
} from "@waku/message-encryption";
import { utf8ToBytes, waitForRemotePeer } from "@waku/sdk";
import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
import type { Context } from "mocha";

Expand Down
33 changes: 16 additions & 17 deletions packages/tests/tests/relay/multiple_pubsub.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { createRelayNode } from "@waku/relay";
import { waitForRemotePeer } from "@waku/sdk";
import {
contentTopicToPubsubTopic,
pubsubTopicToSingleShardInfo,
Expand Down Expand Up @@ -115,9 +114,9 @@ describe("Waku Relay, multiple pubsub topics", function () {
]);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay]),
waitForRemotePeer(waku3, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay])
]);

await waku1.relay.subscribeWithUnsubscribe(
Expand Down Expand Up @@ -222,9 +221,9 @@ describe("Waku Relay, multiple pubsub topics", function () {
]);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay]),
waitForRemotePeer(waku3, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay]),
waku3.connect([Protocols.Relay])
]);

await waku1.relay.subscribeWithUnsubscribe(
Expand Down Expand Up @@ -290,8 +289,8 @@ describe("Waku Relay, multiple pubsub topics", function () {
]);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay])
]);

const messageText = "Communicating using a custom pubsub topic";
Expand Down Expand Up @@ -420,9 +419,9 @@ describe("Waku Relay (Autosharding), multiple pubsub topics", function () {
]);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay]),
waitForRemotePeer(waku3, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay]),
waku3.connect([Protocols.Relay])
]);

await waku1.relay.subscribeWithUnsubscribe(
Expand Down Expand Up @@ -536,9 +535,9 @@ describe("Waku Relay (Autosharding), multiple pubsub topics", function () {
]);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay]),
waitForRemotePeer(waku3, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay]),
waku3.connect([Protocols.Relay])
]);

await waku1.relay.subscribeWithUnsubscribe(
Expand Down Expand Up @@ -631,8 +630,8 @@ describe("Waku Relay (Autosharding), multiple pubsub topics", function () {
]);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku2.connect([Protocols.Relay])
]);

const messageText = "Communicating using a custom pubsub topic";
Expand Down
3 changes: 1 addition & 2 deletions packages/tests/tests/relay/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ShardInfo
} from "@waku/interfaces";
import { createRelayNode } from "@waku/relay";
import { waitForRemotePeer } from "@waku/sdk";
import { contentTopicToPubsubTopic, Logger } from "@waku/utils";
import { Context } from "mocha";

Expand Down Expand Up @@ -46,7 +45,7 @@ export async function waitForAllRemotePeers(
): Promise<void> {
log.info("Wait for mutual pubsub subscription");
await Promise.all(
nodes.map((node): Promise<void> => waitForRemotePeer(node, RELAY_PROTOCOLS))
nodes.map((node): Promise<void> => node.connect(RELAY_PROTOCOLS))
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/store/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ShardInfo,
type SingleShardInfo
} from "@waku/interfaces";
import { createLightNode, waitForRemotePeer } from "@waku/sdk";
import { createLightNode } from "@waku/sdk";
import { Logger, singleShardInfoToPubsubTopic } from "@waku/utils";
import { expect } from "chai";
import { Context } from "mocha";
Expand Down
8 changes: 4 additions & 4 deletions packages/tests/tests/wait_for_remote_peer.node.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LightNode, RelayNode } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { createRelayNode } from "@waku/relay";
import { createLightNode, waitForRemotePeer } from "@waku/sdk";
import { createLightNode, waku } from "@waku/sdk";

Check warning on line 4 in packages/tests/tests/wait_for_remote_peer.node.spec.ts

View workflow job for this annotation

GitHub Actions / check

'waku' is defined but never used

Check warning on line 4 in packages/tests/tests/wait_for_remote_peer.node.spec.ts

View workflow job for this annotation

GitHub Actions / proto

'waku' is defined but never used
import { expect } from "chai";

import {
Expand Down Expand Up @@ -60,7 +60,7 @@ describe("Wait for remote peer", function () {
});
await waku1.start();

const waitPromise = waitForRemotePeer(waku1, [Protocols.Relay]);
const waitPromise = waku1.connect([Protocols.Relay]);
await delay(1000);
await waku1.dial(multiAddrWithId);
await waitPromise;
Expand All @@ -80,7 +80,7 @@ describe("Wait for remote peer", function () {
})
.then((waku1) => waku1.start().then(() => waku1))
.then((waku1) => {
waitForRemotePeer(waku1, [Protocols.Relay], 200).then(
waku1.connect([Protocols.Relay], 200).then(
() => {
throw "Promise expected to reject on time out";
},
Expand Down Expand Up @@ -138,7 +138,7 @@ describe("Wait for remote peer", function () {
networkConfig: DefaultTestShardInfo
});
await waku2.start();
const waitPromise = waitForRemotePeer(waku2, [Protocols.Store], 2000);
const waitPromise = waku2.connect([Protocols.Store], 2000);
await delay(1000);
await waku2.dial(multiAddrWithId);
await waitPromise;
Expand Down
4 changes: 2 additions & 2 deletions packages/tests/tests/waku.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ describe("Decryption Keys", function () {
await waku1.dial(waku2.libp2p.peerId);

await Promise.all([
waitForRemotePeer(waku1, [Protocols.Relay]),
waitForRemotePeer(waku2, [Protocols.Relay])
waku1.connect([Protocols.Relay]),
waku1.connect([Protocols.Relay])
]);
});

Expand Down

0 comments on commit 440f908

Please sign in to comment.