mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-02-21 16:43:09 +00:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
|
|
import { LightNode } from "@waku/interfaces";
|
||
|
|
import { utf8ToBytes } from "@waku/utils/bytes";
|
||
|
|
import { expect } from "chai";
|
||
|
|
|
||
|
|
import { MessageCollector, NimGoNode, tearDownNodes } from "../../src/index.js";
|
||
|
|
|
||
|
|
import {
|
||
|
|
messageText,
|
||
|
|
runNodes,
|
||
|
|
TestContentTopic,
|
||
|
|
TestEncoder
|
||
|
|
} from "./utils.js";
|
||
|
|
|
||
|
|
describe("Waku Light Push [node only] - custom pubsub topic", function () {
|
||
|
|
this.timeout(15000);
|
||
|
|
let waku: LightNode;
|
||
|
|
let nwaku: NimGoNode;
|
||
|
|
let messageCollector: MessageCollector;
|
||
|
|
const customPubSubTopic = "/waku/2/custom-dapp/proto";
|
||
|
|
|
||
|
|
beforeEach(async function () {
|
||
|
|
[nwaku, waku] = await runNodes(this, customPubSubTopic);
|
||
|
|
messageCollector = new MessageCollector(
|
||
|
|
TestContentTopic,
|
||
|
|
nwaku,
|
||
|
|
customPubSubTopic
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
this.afterEach(async function () {
|
||
|
|
tearDownNodes([nwaku], [waku]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("Push message", async function () {
|
||
|
|
const nimPeerId = await nwaku.getPeerId();
|
||
|
|
|
||
|
|
const pushResponse = await waku.lightPush.send(TestEncoder, {
|
||
|
|
payload: utf8ToBytes(messageText)
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(pushResponse.recipients[0].toString()).to.eq(nimPeerId.toString());
|
||
|
|
|
||
|
|
expect(await messageCollector.waitForMessages(1)).to.eq(true);
|
||
|
|
messageCollector.verifyReceivedMessage(0, {
|
||
|
|
expectedMessageText: messageText,
|
||
|
|
expectedContentTopic: TestContentTopic
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|