Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: disables auto init event #5589

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export class Core extends ICore {
await this.relayer.init();
await this.heartbeat.init();
await this.pairing.init();
this.eventClient.init();
this.linkModeSupportedApps = (await this.storage.getItem(WALLETCONNECT_LINK_MODE_APPS)) || [];

this.initialized = true;
Expand Down
22 changes: 21 additions & 1 deletion packages/core/test/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,24 @@ describe("Events Client", () => {
expect(core.eventClient.events.size).toBe(0);
});

it("should not send automatic init event", async () => {
process.env.IS_VITEST = false as any;
const core = new Core({ ...TEST_CORE_OPTIONS, telemetryEnabled: false });
let initCalled = false;
// @ts-expect-error - accessing private properties
core.eventClient.sendEvent = async (payload: any) => {
initCalled = true;
expect(payload).toBeDefined();
expect(payload.length).to.eql(1);
expect(payload[0].props.event).to.eql("INIT");
expect(payload[0].props.properties.client_id).to.eql(await core.crypto.getClientId());
};
await core.start();
await new Promise((resolve) => setTimeout(resolve, 500));
expect(initCalled).to.eql(false);
process.env.IS_VITEST = true as any;
});

it("should send init event", async () => {
process.env.IS_VITEST = false as any;
const core = new Core({ ...TEST_CORE_OPTIONS, telemetryEnabled: false });
Expand All @@ -209,10 +227,12 @@ describe("Events Client", () => {
await core.start();
await new Promise((resolve) => setTimeout(resolve, 500));

expect(initCalled).to.eql(false);
await core.eventClient.init();
expect(initCalled).to.eql(true);
if (!initCalled) {
throw new Error("init not called");
}

process.env.IS_VITEST = true as any;
});
});
Loading