test: do not run two set of nodes

`runNodes` was called twice for custom pubsub test.
This commit is contained in:
fryorcraken.eth 2023-06-28 11:32:56 +10:00
parent 3b1f0adb43
commit fff5d66d2f
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 44 additions and 25 deletions

View File

@ -23,34 +23,36 @@ const TestEncoder = createEncoder({
contentTopic: TestContentTopic,
});
describe("Waku Light Push [node only]", () => {
let waku: LightNode;
let nwaku: NimGoNode;
const runNodes = async (
async function runNodes(
context: Mocha.Context,
pubSubTopic?: string
): Promise<void> => {
): Promise<[NimGoNode, LightNode]> {
const nwakuOptional = pubSubTopic ? { topics: pubSubTopic } : {};
nwaku = new NimGoNode(makeLogFileName(context));
const nwaku = new NimGoNode(makeLogFileName(context));
await nwaku.start({
lightpush: true,
relay: true,
...nwakuOptional,
});
waku = await createLightNode({
const waku = await createLightNode({
pubSubTopic,
staticNoiseKey: NOISE_KEY_1,
});
await waku.start();
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.LightPush]);
};
return [nwaku, waku];
}
describe("Waku Light Push [node only]", () => {
let waku: LightNode;
let nwaku: NimGoNode;
beforeEach(async function () {
this.timeout(15_000);
await runNodes(this);
[nwaku, waku] = await runNodes(this);
});
afterEach(async function () {
@ -108,12 +110,29 @@ describe("Waku Light Push [node only]", () => {
expect(pushResponse.recipients.length).to.eq(0);
expect(pushResponse.error).to.eq(SendError.SIZE_TOO_BIG);
});
});
it("Push on custom pubsub topic", async function () {
this.timeout(15_000);
describe("Waku Light Push [node only] - custom pubsub topic", () => {
let waku: LightNode;
let nwaku: NimGoNode;
const customPubSubTopic = "/waku/2/custom-dapp/proto";
await runNodes(this, customPubSubTopic);
beforeEach(async function () {
this.timeout(15_000);
[nwaku, waku] = await runNodes(this, customPubSubTopic);
});
afterEach(async function () {
try {
nwaku?.stop();
waku?.stop();
} catch (e) {
console.error("Failed to stop nodes: ", e);
}
});
it("Push message", async function () {
this.timeout(15_000);
const nimPeerId = await nwaku.getPeerId();
const messageText = "Light Push works!";