chore: remove go-waku related code in tests (#2285)

* remove go-waku related code in tests

* remove not needed

* remove args level for go-waku
This commit is contained in:
Sasha 2025-02-25 17:56:55 +01:00 committed by GitHub
parent 4cd1eea05a
commit 87a918d9cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 31 additions and 124 deletions

2
package-lock.json generated
View File

@ -16,9 +16,9 @@
"packages/message-encryption",
"packages/sdk",
"packages/relay",
"packages/tests",
"packages/sds",
"packages/rln",
"packages/tests",
"packages/browser-tests",
"packages/build-utils",
"packages/react-native-polyfills"

View File

@ -79,18 +79,6 @@ export class ServiceNodesFleet {
);
}
public get type(): "go-waku" | "nwaku" {
const nodeType = new Set(
this.nodes.map((node) => {
return node.type;
})
);
if (nodeType.size > 1) {
throw new Error("Multiple node types");
}
return nodeType.values().next().value;
}
public async start(): Promise<void> {
const startPromises = this.nodes.map((node) => node.start());
await Promise.all(startPromises);

View File

@ -29,8 +29,6 @@ const NODE_READY_LOG_LINE = "Node setup complete";
export const DOCKER_IMAGE_NAME =
process.env.WAKUNODE_IMAGE || "wakuorg/nwaku:v0.31.0";
const isGoWaku = DOCKER_IMAGE_NAME.includes("go-waku");
const LOG_DIR = "./log";
const OneMillion = BigInt(1_000_000);
@ -79,14 +77,6 @@ export class ServiceNode {
this.logPath = `${LOG_DIR}/wakunode_${logName}.log`;
}
public get type(): "go-waku" | "nwaku" {
return isGoWaku ? "go-waku" : "nwaku";
}
public get nodeType(): "go-waku" | "nwaku" {
return isGoWaku ? "go-waku" : "nwaku";
}
public get containerName(): string | undefined {
return this.docker?.container?.id;
}
@ -133,17 +123,10 @@ export class ServiceNode {
});
});
if (isGoWaku && !args.logLevel) {
args.logLevel = LogLevel.Debug;
}
const { tcpPort, websocketPort, restPort, discv5UdpPort } = ports;
this.restPort = restPort;
this.websocketPort = websocketPort;
// `legacyFilter` is required to enable filter v1 with go-waku
const { legacyFilter = false, ..._args } = args;
// Object.assign overrides the properties with the source (if there are conflicts)
Object.assign(
mergedArgs,
@ -152,11 +135,10 @@ export class ServiceNode {
restPort,
tcpPort,
websocketPort,
...(args?.peerExchange && { discv5UdpPort }),
...(isGoWaku && { minRelayPeersToPublish: 0, legacyFilter })
...(args?.peerExchange && { discv5UdpPort })
},
{ restAddress: "0.0.0.0" },
_args
args
);
process.env.WAKUNODE2_STORE_MESSAGE_DB_URL = "";
@ -179,14 +161,12 @@ export class ServiceNode {
throw error;
}
try {
log.info(
`Waiting to see '${NODE_READY_LOG_LINE}' in ${this.type} logs`
);
log.info(`Waiting to see '${NODE_READY_LOG_LINE}' in logs`);
await this.waitForLog(NODE_READY_LOG_LINE, 15000);
if (process.env.CI) await delay(100);
log.info(`${this.type} node has been started`);
log.info(`Node has been started`);
} catch (error) {
log.error(`Error starting ${this.type}: ${error}`);
log.error(`Error starting: ${error}`);
if (this.docker.container) await this.docker.stop();
throw error;
}
@ -356,9 +336,9 @@ export class ServiceNode {
const multiaddrWithId = res.listenAddresses
.map((ma) => multiaddr(ma))
.find((ma) => ma.protoNames().includes("ws"));
if (!multiaddrWithId) throw `${this.type} did not return a ws multiaddr`;
if (!multiaddrWithId) throw `Did not return a ws multiaddr`;
const peerIdStr = multiaddrWithId.getPeerId();
if (!peerIdStr) throw `${this.type} multiaddr does not contain peerId`;
if (!peerIdStr) throw `Multiaddr does not contain peerId`;
this.peerId = peerIdFromString(peerIdStr);
return this.peerId;
@ -399,7 +379,7 @@ export class ServiceNode {
private checkProcess(): void {
if (!this.docker?.container) {
throw `${this.type} container hasn't started`;
throw `Container hasn't started`;
}
}
}

View File

@ -22,8 +22,6 @@ export interface Args {
websocketPort?: number;
discv5BootstrapNode?: string;
discv5UdpPort?: number;
// `legacyFilter` is required to enable filter v1 with go-waku
legacyFilter?: boolean;
clusterId?: number;
shard?: Array<number>;
rlnRelayEthClientAddress?: string;

View File

@ -6,5 +6,4 @@ export * from "./delay.js";
export * from "./base64_utf8.js";
export * from "./waitForConnections.js";
export * from "./custom_mocha_hooks.js";
export * from "./waku_versions_utils.js";
export * from "./nodes.js";

View File

@ -1,17 +0,0 @@
import { DOCKER_IMAGE_NAME } from "../lib/service_node.js";
// Utility to add test conditions based on nwaku/go-waku versions
export function isNwakuAtLeast(requiredVersion: string): boolean {
const versionRegex = /(?:v)?(\d+\.\d+(?:\.\d+)?)/;
const match = DOCKER_IMAGE_NAME.match(versionRegex);
if (match) {
const version = match[0].substring(1); // Remove the 'v' prefix
return (
version.localeCompare(requiredVersion, undefined, { numeric: true }) >= 0
);
} else {
// If there is no match we assume that it's a version close to master so we return True
return true;
}
}

View File

@ -98,7 +98,6 @@ describe("ENR Interop: ServiceNode", function () {
store: true,
filter: true,
lightpush: true,
legacyFilter: true,
pubsubTopic: [DefaultTestPubsubTopic]
});
const multiAddrWithId = await nwaku.getMultiaddrWithId();

View File

@ -182,16 +182,9 @@ const runTests = (strictCheckNodes: boolean): void => {
TestPubsubTopic
);
// For go-waku the message is received (it is possible to send a message with no payload)
if (serviceNodes.type == "go-waku") {
expect(await serviceNodes.messageCollector.waitForMessages(1)).to.eq(
true
);
} else {
expect(await serviceNodes.messageCollector.waitForMessages(1)).to.eq(
false
);
}
expect(await serviceNodes.messageCollector.waitForMessages(1)).to.eq(
false
);
});
it("Check message with non string payload is not received", async function () {

View File

@ -174,12 +174,7 @@ describe("Waku Filter V2: FilterPush", function () {
async (res) => res.status === 200
);
// For go-waku the message is received (it is possible to send a message with no payload)
if (nwaku.type == "go-waku") {
expect(await messageCollector.waitForMessages(1)).to.eq(true);
} else {
expect(await messageCollector.waitForMessages(1)).to.eq(false);
}
expect(await messageCollector.waitForMessages(1)).to.eq(false);
});
it("Check message with non string payload is not received", async function () {

View File

@ -189,29 +189,15 @@ const runTests = (strictNodeCheck: boolean): void => {
messagePayload
);
if (serviceNodes.type == "go-waku") {
expect(pushResponse.successes.length).to.eq(numServiceNodes);
expect(
await serviceNodes.messageCollector.waitForMessages(1, {
pubsubTopic: TestPubsubTopic
})
).to.eq(true);
serviceNodes.messageCollector.verifyReceivedMessage(0, {
expectedMessageText: messageText,
expectedContentTopic: TestContentTopic,
expectedPubsubTopic: TestPubsubTopic
});
} else {
expect(pushResponse.successes.length).to.eq(0);
expect(
pushResponse.failures?.map((failure) => failure.error)
).to.include(ProtocolError.REMOTE_PEER_REJECTED);
expect(
await serviceNodes.messageCollector.waitForMessages(1, {
pubsubTopic: TestPubsubTopic
})
).to.eq(false);
}
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
ProtocolError.REMOTE_PEER_REJECTED
);
expect(
await serviceNodes.messageCollector.waitForMessages(1, {
pubsubTopic: TestPubsubTopic
})
).to.eq(false);
});
it("Push message with rate limit", async function () {

View File

@ -181,29 +181,15 @@ describe("Waku Light Push: Single Node", function () {
messagePayload
);
if (nwaku.type == "go-waku") {
expect(pushResponse.successes.length).to.eq(1);
expect(
await messageCollector.waitForMessages(1, {
pubsubTopic: TestPubsubTopic
})
).to.eq(true);
messageCollector.verifyReceivedMessage(0, {
expectedMessageText: messageText,
expectedContentTopic: TestContentTopic,
expectedPubsubTopic: TestPubsubTopic
});
} else {
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
ProtocolError.REMOTE_PEER_REJECTED
);
expect(
await messageCollector.waitForMessages(1, {
pubsubTopic: TestPubsubTopic
})
).to.eq(false);
}
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
ProtocolError.REMOTE_PEER_REJECTED
);
expect(
await messageCollector.waitForMessages(1, {
pubsubTopic: TestPubsubTopic
})
).to.eq(false);
});
it("Push message with rate limit", async function () {