mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-05 23:33:08 +00:00
test: ensure filter/light push work with message-encryption (#1671)
Co-authored-by: Sasha <118575614+weboko@users.noreply.github.com>
This commit is contained in:
parent
6aade791cc
commit
2af96281cd
@ -6,6 +6,7 @@ import {
|
|||||||
} from "@waku/core";
|
} from "@waku/core";
|
||||||
import type { IFilterSubscription, LightNode } from "@waku/interfaces";
|
import type { IFilterSubscription, LightNode } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
|
import { ecies, symmetric } from "@waku/message-encryption";
|
||||||
import { utf8ToBytes } from "@waku/utils/bytes";
|
import { utf8ToBytes } from "@waku/utils/bytes";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
@ -65,6 +66,49 @@ describe("Waku Filter V2: Subscribe", function () {
|
|||||||
expect((await nwaku.messages()).length).to.eq(1);
|
expect((await nwaku.messages()).length).to.eq(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Subscribe and receive ecies encrypted messages via lightPush", async function () {
|
||||||
|
const privateKey = ecies.generatePrivateKey();
|
||||||
|
const publicKey = ecies.getPublicKey(privateKey);
|
||||||
|
const encoder = ecies.createEncoder({
|
||||||
|
contentTopic: TestContentTopic,
|
||||||
|
publicKey
|
||||||
|
});
|
||||||
|
const decoder = ecies.createDecoder(TestContentTopic, privateKey);
|
||||||
|
|
||||||
|
await subscription.subscribe([decoder], messageCollector.callback);
|
||||||
|
|
||||||
|
await waku.lightPush.send(encoder, messagePayload);
|
||||||
|
|
||||||
|
expect(await messageCollector.waitForMessages(1)).to.eq(true);
|
||||||
|
messageCollector.verifyReceivedMessage(0, {
|
||||||
|
expectedMessageText: messageText,
|
||||||
|
expectedContentTopic: TestContentTopic,
|
||||||
|
expectedVersion: 1
|
||||||
|
});
|
||||||
|
expect((await nwaku.messages()).length).to.eq(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Subscribe and receive symmetrically encrypted messages via lightPush", async function () {
|
||||||
|
const symKey = symmetric.generateSymmetricKey();
|
||||||
|
const encoder = symmetric.createEncoder({
|
||||||
|
contentTopic: TestContentTopic,
|
||||||
|
symKey
|
||||||
|
});
|
||||||
|
const decoder = symmetric.createDecoder(TestContentTopic, symKey);
|
||||||
|
|
||||||
|
await subscription.subscribe([decoder], messageCollector.callback);
|
||||||
|
|
||||||
|
await waku.lightPush.send(encoder, messagePayload);
|
||||||
|
|
||||||
|
expect(await messageCollector.waitForMessages(1)).to.eq(true);
|
||||||
|
messageCollector.verifyReceivedMessage(0, {
|
||||||
|
expectedMessageText: messageText,
|
||||||
|
expectedContentTopic: TestContentTopic,
|
||||||
|
expectedVersion: 1
|
||||||
|
});
|
||||||
|
expect((await nwaku.messages()).length).to.eq(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("Subscribe and receive messages via waku relay post", async function () {
|
it("Subscribe and receive messages via waku relay post", async function () {
|
||||||
await subscription.subscribe([TestDecoder], messageCollector.callback);
|
await subscription.subscribe([TestDecoder], messageCollector.callback);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user