Merge pull request #1182 from waku-org/chore/nwaku-0.15.0

This commit is contained in:
fryorcraken.eth 2023-02-16 18:47:09 +11:00 committed by GitHub
commit d8d7b8389b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 20 deletions

View File

@ -9,7 +9,7 @@ on:
pull_request: pull_request:
env: env:
NWAKU_VERSION: "v0.13.0" NWAKU_VERSION: "v0.15.0"
NODE_JS: "18" NODE_JS: "18"
jobs: jobs:

2
nwaku

@ -1 +1 @@
Subproject commit 9debd44e2aebf07eaf96b4525a4497c69aaf4445 Subproject commit e12b7cb4a8d7084f8174b378d38fa261428e406d

View File

@ -81,13 +81,6 @@ export interface MessageRpcQuery {
} }
export interface MessageRpcResponse { export interface MessageRpcResponse {
payload: number[];
contentTopic?: string;
version?: number;
timestamp?: bigint; // Unix epoch time in nanoseconds as a 64-bits integer value.
}
export interface MessageRpcResponseHex {
payload: string; payload: string;
contentTopic?: string; contentTopic?: string;
version?: number; version?: number;
@ -122,7 +115,7 @@ export class Nwaku {
} }
return { return {
payload: bytesToHex(message.payload), payload: Buffer.from(message.payload).toString("base64url"),
contentTopic: message.contentTopic, contentTopic: message.contentTopic,
timestamp, timestamp,
}; };
@ -321,10 +314,10 @@ export class Nwaku {
async getAsymmetricMessages( async getAsymmetricMessages(
privateKey: Uint8Array, privateKey: Uint8Array,
pubSubTopic?: string pubSubTopic?: string
): Promise<MessageRpcResponseHex[]> { ): Promise<MessageRpcResponse[]> {
this.checkProcess(); this.checkProcess();
return await this.rpcCall<MessageRpcResponseHex[]>( return await this.rpcCall<MessageRpcResponse[]>(
"get_waku_v2_private_v1_asymmetric_messages", "get_waku_v2_private_v1_asymmetric_messages",
[ [
pubSubTopic ? pubSubTopic : DefaultPubSubTopic, pubSubTopic ? pubSubTopic : DefaultPubSubTopic,
@ -363,10 +356,10 @@ export class Nwaku {
async getSymmetricMessages( async getSymmetricMessages(
symKey: Uint8Array, symKey: Uint8Array,
pubSubTopic?: string pubSubTopic?: string
): Promise<MessageRpcResponseHex[]> { ): Promise<MessageRpcResponse[]> {
this.checkProcess(); this.checkProcess();
return await this.rpcCall<MessageRpcResponseHex[]>( return await this.rpcCall<MessageRpcResponse[]>(
"get_waku_v2_private_v1_symmetric_messages", "get_waku_v2_private_v1_symmetric_messages",
[ [
pubSubTopic ? pubSubTopic : DefaultPubSubTopic, pubSubTopic ? pubSubTopic : DefaultPubSubTopic,
@ -475,3 +468,7 @@ interface RpcInfoResponse {
listenAddresses: string[]; listenAddresses: string[];
enrUri?: string; enrUri?: string;
} }
export function base64ToUtf8(b64: string): string {
return Buffer.from(b64, "base64").toString("utf-8");
}

View File

@ -2,11 +2,12 @@ import { createEncoder, waitForRemotePeer } from "@waku/core";
import { createLightNode } from "@waku/create"; import { createLightNode } from "@waku/create";
import type { LightNode } from "@waku/interfaces"; import type { LightNode } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces";
import { bytesToUtf8, utf8ToBytes } from "@waku/utils"; import { utf8ToBytes } from "@waku/utils";
import { expect } from "chai"; import { expect } from "chai";
import debug from "debug"; import debug from "debug";
import { import {
base64ToUtf8,
delay, delay,
makeLogFileName, makeLogFileName,
MessageRpcResponse, MessageRpcResponse,
@ -58,7 +59,7 @@ describe("Waku Light Push [node only]", () => {
} }
expect(msgs[0].contentTopic).to.equal(TestContentTopic); expect(msgs[0].contentTopic).to.equal(TestContentTopic);
expect(bytesToUtf8(new Uint8Array(msgs[0].payload))).to.equal(messageText); expect(base64ToUtf8(msgs[0].payload)).to.equal(messageText);
}); });
it("Push on custom pubsub topic", async function () { it("Push on custom pubsub topic", async function () {
@ -105,6 +106,6 @@ describe("Waku Light Push [node only]", () => {
} }
expect(msgs[0].contentTopic).to.equal(TestContentTopic); expect(msgs[0].contentTopic).to.equal(TestContentTopic);
expect(bytesToUtf8(new Uint8Array(msgs[0].payload))!).to.equal(messageText); expect(base64ToUtf8(msgs[0].payload!)).to.equal(messageText);
}); });
}); });

View File

@ -25,6 +25,7 @@ import { expect } from "chai";
import debug from "debug"; import debug from "debug";
import { import {
base64ToUtf8,
delay, delay,
makeLogFileName, makeLogFileName,
MessageRpcResponse, MessageRpcResponse,
@ -389,9 +390,7 @@ describe("Waku Relay [node only]", () => {
expect(msgs[0].contentTopic).to.equal(TestContentTopic); expect(msgs[0].contentTopic).to.equal(TestContentTopic);
expect(msgs[0].version).to.equal(0); expect(msgs[0].version).to.equal(0);
expect(bytesToUtf8(new Uint8Array(msgs[0].payload))).to.equal( expect(base64ToUtf8(msgs[0].payload)).to.equal(messageText);
messageText
);
}); });
it("Nwaku publishes", async function () { it("Nwaku publishes", async function () {