Skip to content

Commit

Permalink
feat: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ganchoradkov committed Oct 8, 2024
1 parent fdf558c commit ac72096
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/core/test/relayer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, describe, it, beforeEach, afterEach } from "vitest";
import { expect, describe, it, beforeEach, afterEach, vi } from "vitest";
import { getDefaultLoggerOptions, pino } from "@walletconnect/logger";
import { JsonRpcProvider } from "@walletconnect/jsonrpc-provider";

Expand Down Expand Up @@ -164,6 +164,23 @@ describe("Relayer", () => {
expect(subscriber.events.listenerCount(SUBSCRIBER_EVENTS.created)).to.eq(startNumListeners);
});

it("should throw when subscribe reaches a publish timeout", async () => {
await relayer.transportOpen();
await relayer.toEstablishConnection();
relayer.subscriber.subscribeTimeout = 5_000;
relayer.request = () => {
return new Promise<void>((_, reject) => {
setTimeout(() => {
reject(new Error("Subscription timeout"));
}, 100_000);
});
};
const topic = generateRandomBytes32();
await expect(relayer.subscribe(topic)).rejects.toThrow(
`Subscribing to ${topic} failed, please try again`,
);
});

it("should be able to resubscribe on topic that already exists", async () => {
const topic = generateRandomBytes32();
const id = await relayer.subscribe(topic);
Expand Down

0 comments on commit ac72096

Please sign in to comment.