Skip to content

Commit

Permalink
Merge branch 'v2.0' into chore/pairing-methods-deprecation-notice
Browse files Browse the repository at this point in the history
  • Loading branch information
ganchoradkov authored Jan 15, 2025
2 parents b478e37 + 292b28d commit 4850a49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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;
});
});

0 comments on commit 4850a49

Please sign in to comment.