Skip to content

Commit

Permalink
chore: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ganchoradkov committed Jan 8, 2025
1 parent 1479ba2 commit 051e587
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/core/test/pairing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { expect, describe, it, beforeEach, afterEach } from "vitest";
import { ICore } from "@walletconnect/types";
import { Core, CORE_PROTOCOL, CORE_VERSION, PAIRING_EVENTS, SUBSCRIBER_EVENTS } from "../src";
import { TEST_CORE_OPTIONS, disconnectSocket, waitForEvent } from "./shared";
import { generateRandomBytes32, parseUri, toBase64 } from "@walletconnect/utils";
import { calcExpiry, generateRandomBytes32, parseUri, toBase64 } from "@walletconnect/utils";
import { FIVE_MINUTES, ONE_MINUTE } from "@walletconnect/time";

const createCoreClients: () => Promise<{ coreA: ICore; coreB: ICore }> = async () => {
const coreA = new Core(TEST_CORE_OPTIONS);
Expand Down Expand Up @@ -121,8 +122,13 @@ describe("Pairing", () => {
const inactivePairing = coreA.pairing.pairings.get(topic);
expect(inactivePairing.active).toBe(false);
await coreA.pairing.activate({ topic });
expect(coreA.pairing.pairings.get(topic).active).toBe(true);
expect(coreA.pairing.pairings.get(topic).expiry > inactivePairing.expiry).toBe(true);
const activePairing = coreA.pairing.pairings.get(topic);
expect(activePairing.active).toBe(true);
expect(activePairing.expiry > inactivePairing.expiry).toBe(false);
// inactive pairing should have an expiry of 5 minutes
expect(inactivePairing.expiry).to.be.approximately(calcExpiry(FIVE_MINUTES), 5);
// active pairing should have an expiry of 1 minute
expect(activePairing.expiry).to.be.approximately(calcExpiry(ONE_MINUTE), 5);
});
});

Expand Down

0 comments on commit 051e587

Please sign in to comment.