test: usage of `DecodedMessage` class is preferred

This is because `IDecodedMessage` does not include all possible field of
messages from a specific decoder (ie, signature public key, etc) so
usage of the `DecodedMessage` class associated with the used decoder is
preferred.
This commit is contained in:
fryorcraken.eth 2022-12-06 12:33:06 +11:00
parent cc691e26ce
commit 8f01a453f7
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 16 additions and 12 deletions

View File

@ -1,7 +1,12 @@
import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils";
import { createDecoder, createEncoder, waitForRemotePeer } from "@waku/core";
import {
createDecoder,
createEncoder,
DecodedMessage,
waitForRemotePeer,
} from "@waku/core";
import { createLightNode } from "@waku/create";
import type { IDecodedMessage, WakuLight } from "@waku/interfaces";
import type { WakuLight } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { expect } from "chai";
import debug from "debug";
@ -43,7 +48,7 @@ describe("Waku Filter", () => {
const messageText = "Filtering works!";
const message = { payload: utf8ToBytes(messageText) };
const callback = (msg: IDecodedMessage): void => {
const callback = (msg: DecodedMessage): void => {
log("Got a message");
messageCount++;
expect(msg.contentTopic).to.eq(TestContentTopic);
@ -67,7 +72,7 @@ describe("Waku Filter", () => {
this.timeout(10000);
let messageCount = 0;
const callback = (msg: IDecodedMessage): void => {
const callback = (msg: DecodedMessage): void => {
messageCount++;
expect(msg.contentTopic).to.eq(TestContentTopic);
};

View File

@ -1,14 +1,13 @@
import { bootstrap } from "@libp2p/bootstrap";
import type { PeerId } from "@libp2p/interface-peer-id";
import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils";
import { DefaultUserAgent, waitForRemotePeer } from "@waku/core";
import {
DecodedMessage,
DefaultUserAgent,
waitForRemotePeer,
} from "@waku/core";
import { createLightNode, createPrivacyNode } from "@waku/create";
import type {
IDecodedMessage,
Waku,
WakuLight,
WakuPrivacy,
} from "@waku/interfaces";
import type { Waku, WakuLight, WakuPrivacy } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import {
createDecoder,
@ -180,7 +179,7 @@ describe("Decryption Keys", () => {
timestamp: messageTimestamp,
};
const receivedMsgPromise: Promise<IDecodedMessage> = new Promise(
const receivedMsgPromise: Promise<DecodedMessage> = new Promise(
(resolve) => {
waku2.relay.addObserver(decoder, resolve);
}