Add Wss test

This commit is contained in:
Franck Royer 2022-04-20 13:47:28 +10:00
parent 0e227d0cb0
commit 06e6ee7f43
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
5 changed files with 28 additions and 15 deletions

View File

@ -66,7 +66,7 @@ export default function runAll(nodes) {
await Promise.all(promises); await Promise.all(promises);
// All connected and relay ready // All connected and relay ready
const contentTopic = "/js-waku-testing/1/relay-test/utf8"; const contentTopic = `/waku-tests/1/relay-test-${id}/utf8`;
const messages = []; const messages = [];
@ -85,7 +85,7 @@ export default function runAll(nodes) {
const relayPromises = wakus.map(async (waku, i) => { const relayPromises = wakus.map(async (waku, i) => {
const msg = await WakuMessage.fromUtf8String( const msg = await WakuMessage.fromUtf8String(
`sent from ${i} - ${id}`, `sent via ${nodes[i]} - ${id}`,
contentTopic contentTopic
); );
return waku.relay.send(msg); return waku.relay.send(msg);
@ -104,7 +104,7 @@ export default function runAll(nodes) {
expect(messages.length).to.gte(nodes.length); expect(messages.length).to.gte(nodes.length);
for (let i = 0; i < wakus.length; i++) { for (let i = 0; i < wakus.length; i++) {
expect(messages.map((m) => m.msg)).to.contain(`sent from ${i} - ${id}`); expect(messages.map((m) => m.msg)).to.contain(`sent via ${nodes[i]} - ${id}`);
} }
}); });
@ -129,7 +129,7 @@ export default function runAll(nodes) {
await Promise.all(promises); await Promise.all(promises);
// All connected and relay ready // All connected and relay ready
const contentTopic = "/js-waku-testing/1/relay-test/utf8"; const contentTopic = `/waku-tests/1/light-push-${id}/utf8`;
const messages = []; const messages = [];
@ -148,7 +148,7 @@ export default function runAll(nodes) {
const relayPromises = wakus.map(async (waku, i) => { const relayPromises = wakus.map(async (waku, i) => {
const msg = await WakuMessage.fromUtf8String( const msg = await WakuMessage.fromUtf8String(
`sent from ${i} - ${id}`, `sent via ${nodes[i]} - ${id}`,
contentTopic contentTopic
); );
return waku.lightPush.push(msg); return waku.lightPush.push(msg);
@ -166,7 +166,7 @@ export default function runAll(nodes) {
expect(messages.length).to.gte(nodes.length); expect(messages.length).to.gte(nodes.length);
for (let i = 0; i < wakus.length; i++) { for (let i = 0; i < wakus.length; i++) {
expect(messages.map((m) => m.msg)).to.contain(`sent from ${i} - ${id}`); expect(messages.map((m) => m.msg)).to.contain(`sent via ${nodes[i]} - ${id}`);
} }
}); });
@ -191,11 +191,11 @@ export default function runAll(nodes) {
await Promise.all(promises); await Promise.all(promises);
// All connected and relay ready // All connected and relay ready
const contentTopic = "/js-waku-testing/1/store-test/utf8"; const contentTopic = `/waku-tests/1/store-test-${id}/utf8`;
const relayPromises = wakus.map(async (waku, i) => { const relayPromises = wakus.map(async (waku, i) => {
const msg = await WakuMessage.fromUtf8String( const msg = await WakuMessage.fromUtf8String(
`sent from ${i} - ${id}`, `sent via ${nodes[i]} - ${id}`,
contentTopic contentTopic
); );
return waku.relay.send(msg); return waku.relay.send(msg);
@ -210,7 +210,7 @@ export default function runAll(nodes) {
console.log(index, payloads); console.log(index, payloads);
for (let i = 0; i < wakus.length; i++) { for (let i = 0; i < wakus.length; i++) {
expect(payloads).to.contain(`sent from ${i} - ${id}`); expect(payloads).to.contain(`sent via ${nodes[i]} - ${id}`);
} }
}); });

12
nativeWssProdFleet.js Normal file
View File

@ -0,0 +1,12 @@
import { describe } from "mocha";
import runAll from "./index.js";
const nodes = [
"/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/8000/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD",
"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e",
"/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA",
];
describe("Prod Fleet Native WSS", () => {
runAll(nodes);
});

View File

@ -6,8 +6,9 @@
"lint": "eslint . --ext .js", "lint": "eslint . --ext .js",
"format": "prettier --write .", "format": "prettier --write .",
"fix": "run-s lint format", "fix": "run-s lint format",
"prod": "mocha prodFleet.js", "predefined-prod": "mocha predefinedProdFleet.js --exit",
"test": "mocha testFleet.js" "predefined-test": "mocha predefinedTestFleet.js --exit ",
"native-wss": "mocha nativeWssProdFleet.js --exit"
}, },
"eslintConfig": { "eslintConfig": {
"env": { "env": {

View File

@ -6,6 +6,6 @@ const prodFleet =
discovery.predefined.fleets.fleets["wakuv2.prod"]["waku-websocket"]; discovery.predefined.fleets.fleets["wakuv2.prod"]["waku-websocket"];
const nodes = Object.values(prodFleet); const nodes = Object.values(prodFleet);
describe("Prod Fleet", async () => { describe("Predefined Prod Fleet", () => {
await runAll(nodes); runAll(nodes);
}); });

View File

@ -6,6 +6,6 @@ const testFleet =
discovery.predefined.fleets.fleets["wakuv2.test"]["waku-websocket"]; discovery.predefined.fleets.fleets["wakuv2.test"]["waku-websocket"];
const nodes = Object.values(testFleet); const nodes = Object.values(testFleet);
describe("Prod Fleet", async () => { describe("Predefined Test Fleet", () => {
await runAll(nodes); runAll(nodes);
}); });