Skip to content

Commit

Permalink
tests: abstract away node creation and teardown utils
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Jul 26, 2024
1 parent c7fd88e commit f761d7f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
6 changes: 4 additions & 2 deletions packages/tests/src/utils/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export async function runMultipleNodes(
shardInfo?: ShardingParams,
customArgs?: Args,
strictChecking: boolean = false,
numServiceNodes = 3
numServiceNodes = 3,
withoutFilter = false
): Promise<[ServiceNodesFleet, LightNode]> {
const pubsubTopics = shardInfo
? shardInfoToPubsubTopics(shardInfo)
Expand All @@ -35,7 +36,8 @@ export async function runMultipleNodes(
numServiceNodes,
strictChecking,
shardInfo,
customArgs
customArgs,
withoutFilter
);

const wakuOptions: ProtocolCreateOptions = {
Expand Down
10 changes: 5 additions & 5 deletions packages/tests/tests/filter/peer_management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ import {
beforeEachCustom,
DefaultTestPubsubTopic,
DefaultTestShardInfo,
ServiceNode,
ServiceNodesFleet
} from "../../src/index.js";
import {
runMultipleNodes,
ServiceNode,
ServiceNodesFleet,
teardownNodesWithRedundancy
} from "../filter/utils.js";
} from "../../src/index.js";

describe("Waku Filter: Peer Management: E2E", function () {
this.timeout(15000);
Expand All @@ -46,6 +44,7 @@ describe("Waku Filter: Peer Management: E2E", function () {
this.ctx,
DefaultTestShardInfo,
undefined,
undefined,
5
);
const { error, subscription: sub } = await waku.filter.createSubscription(
Expand Down Expand Up @@ -186,6 +185,7 @@ describe("Waku Filter: Peer Management: E2E", function () {
this.ctx,
DefaultTestShardInfo,
undefined,
undefined,
2
);
const serviceNodesPeerIdStr = await Promise.all(
Expand Down
6 changes: 3 additions & 3 deletions packages/tests/tests/filter/ping.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { expect } from "chai";
import {
afterEachCustom,
beforeEachCustom,
ServiceNodesFleet
runMultipleNodes,
ServiceNodesFleet,
teardownNodesWithRedundancy
} from "../../src/index.js";

import {
runMultipleNodes,
teardownNodesWithRedundancy,
TestContentTopic,
TestDecoder,
TestEncoder,
Expand Down
4 changes: 2 additions & 2 deletions packages/tests/tests/filter/push.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {
afterEachCustom,
beforeEachCustom,
delay,
runMultipleNodes,
ServiceNodesFleet,
teardownNodesWithRedundancy,
TEST_STRING,
TEST_TIMESTAMPS
} from "../../src/index.js";

import {
messageText,
runMultipleNodes,
teardownNodesWithRedundancy,
TestContentTopic,
TestDecoder,
TestEncoder,
Expand Down
5 changes: 3 additions & 2 deletions packages/tests/tests/filter/subscribe.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import {
beforeEachCustom,
delay,
generateTestData,
runMultipleNodes,
ServiceNodesFleet,
teardownNodesWithRedundancy,
TEST_STRING
} from "../../src/index.js";

import {
messagePayload,
messageText,
runMultipleNodes,
teardownNodesWithRedundancy,
TestContentTopic,
TestDecoder,
TestEncoder,
Expand All @@ -42,6 +42,7 @@ const runTests = (strictCheckNodes: boolean): void => {
[serviceNodes, waku] = await runMultipleNodes(
this.ctx,
TestShardInfo,
undefined,
strictCheckNodes
);
const { error, subscription: _subscription } =
Expand Down
6 changes: 3 additions & 3 deletions packages/tests/tests/filter/unsubscribe.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {
afterEachCustom,
beforeEachCustom,
generateTestData,
ServiceNodesFleet
runMultipleNodes,
ServiceNodesFleet,
teardownNodesWithRedundancy
} from "../../src/index.js";

import {
ClusterId,
messagePayload,
messageText,
runMultipleNodes,
teardownNodesWithRedundancy,
TestContentTopic,
TestDecoder,
TestEncoder,
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/tests/filter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
NOISE_KEY_1,
ServiceNodesFleet,
waitForConnections
} from "../../src/index.js";
} from "../../src";

// Constants for test configuration.
export const log = new Logger("test:filter");
Expand Down
7 changes: 3 additions & 4 deletions packages/tests/tests/light-push/index.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
afterEachCustom,
beforeEachCustom,
generateRandomUint8Array,
runMultipleNodes,
ServiceNodesFleet,
teardownNodesWithRedundancy,
TEST_STRING
} from "../../src";
import {
runMultipleNodes,
teardownNodesWithRedundancy
} from "../filter/utils.js";

import {
messagePayload,
Expand All @@ -36,6 +34,7 @@ const runTests = (strictNodeCheck: boolean): void => {
[serviceNodes, waku] = await runMultipleNodes(
this.ctx,
TestShardInfo,
undefined,
strictNodeCheck,
numServiceNodes,
true
Expand Down
11 changes: 5 additions & 6 deletions packages/tests/tests/light-push/peer_management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import {
beforeEachCustom,
DefaultTestShardInfo,
DefaultTestSingleShardInfo,
ServiceNodesFleet
} from "../../src/index.js";
import {
runMultipleNodes,
teardownNodesWithRedundancy,
TestContentTopic
} from "../filter/utils.js";
ServiceNodesFleet,
teardownNodesWithRedundancy
} from "../../src/index.js";
import { TestContentTopic } from "../filter/utils.js";

describe("Waku Light Push: Peer Management: E2E", function () {
this.timeout(15000);
Expand All @@ -26,6 +24,7 @@ describe("Waku Light Push: Peer Management: E2E", function () {
this.ctx,
DefaultTestShardInfo,
undefined,
undefined,
5
);
});
Expand Down

0 comments on commit f761d7f

Please sign in to comment.