mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-09 09:13:10 +00:00
fix: remove unnecessary comments from store validation
- Remove inline comments that explain obvious code behavior - Keep only the reference URL comment which provides useful context - Address review feedback about excessive commenting
This commit is contained in:
parent
2d92191029
commit
5f63cb5bfb
@ -17,7 +17,7 @@ describe("StoreQueryRequest validation", () => {
|
||||
expect(() =>
|
||||
StoreQueryRequest.create({
|
||||
pubsubTopic: "/waku/2/default-waku/proto",
|
||||
contentTopics: [], // Empty array
|
||||
contentTopics: [],
|
||||
includeData: true,
|
||||
paginationForward: true
|
||||
})
|
||||
@ -29,7 +29,7 @@ describe("StoreQueryRequest validation", () => {
|
||||
it("rejects content-filtered query with only contentTopics", () => {
|
||||
expect(() =>
|
||||
StoreQueryRequest.create({
|
||||
pubsubTopic: "", // Empty string
|
||||
pubsubTopic: "",
|
||||
contentTopics: ["/test/1/content/proto"],
|
||||
includeData: true,
|
||||
paginationForward: true
|
||||
@ -41,8 +41,8 @@ describe("StoreQueryRequest validation", () => {
|
||||
|
||||
it("accepts valid message hash query", () => {
|
||||
const request = StoreQueryRequest.create({
|
||||
pubsubTopic: "", // Required but ignored for hash queries
|
||||
contentTopics: [], // Required but ignored for hash queries
|
||||
pubsubTopic: "",
|
||||
contentTopics: [],
|
||||
messageHashes: [new Uint8Array([1, 2, 3, 4])],
|
||||
includeData: true,
|
||||
paginationForward: true
|
||||
|
||||
@ -28,22 +28,18 @@ export class StoreQueryRequest {
|
||||
: undefined
|
||||
});
|
||||
|
||||
// Validate request parameters based on RFC
|
||||
const isHashQuery = params.messageHashes && params.messageHashes.length > 0;
|
||||
const hasContentTopics =
|
||||
params.contentTopics && params.contentTopics.length > 0;
|
||||
const hasTimeFilter = params.timeStart || params.timeEnd;
|
||||
|
||||
if (isHashQuery) {
|
||||
// Message hash lookup queries cannot include content topics or time filters
|
||||
// but pubsubTopic is allowed/required
|
||||
if (hasContentTopics || hasTimeFilter) {
|
||||
throw new Error(
|
||||
"Message hash lookup queries cannot include content filter criteria (contentTopics, timeStart, or timeEnd)"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Content-filtered queries require both pubsubTopic and contentTopics to be set together
|
||||
if (
|
||||
(params.pubsubTopic &&
|
||||
(!params.contentTopics || params.contentTopics.length === 0)) ||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { DecodedMessage } from "@waku/core";
|
||||
import type { IDecodedMessage, LightNode } from "@waku/interfaces";
|
||||
import { messageHash } from "@waku/message-hash";
|
||||
import { assert, expect } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import {
|
||||
afterEachCustom,
|
||||
@ -73,19 +72,13 @@ describe("Waku Store, message hash query", function () {
|
||||
);
|
||||
|
||||
const messages: IDecodedMessage[] = [];
|
||||
let pageCount = 0;
|
||||
try {
|
||||
for await (const page of waku.store.queryGenerator([TestDecoder], {
|
||||
messageHashes,
|
||||
pubsubTopic: TestDecoder.pubsubTopic
|
||||
})) {
|
||||
pageCount++;
|
||||
for await (const msg of page) {
|
||||
messages.push(msg as IDecodedMessage);
|
||||
}
|
||||
for await (const page of waku.store.queryGenerator([TestDecoder], {
|
||||
messageHashes,
|
||||
pubsubTopic: TestDecoder.pubsubTopic
|
||||
})) {
|
||||
for await (const msg of page) {
|
||||
messages.push(msg as IDecodedMessage);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
expect(messages.length).to.equal(messageHashes.length);
|
||||
for (const msg of messages) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user