Skip to content

Commit

Permalink
Showing 6 changed files with 8 additions and 32 deletions.
13 changes: 1 addition & 12 deletions packages/core/test/shared/ws.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import { IJsonRpcConnection } from "@walletconnect/jsonrpc-utils";
import { IRelayer } from "@walletconnect/types";
import EventEmitter from "events";

export async function disconnectSocket(relayer: IRelayer) {
if (relayer.connected) {
relayer.provider.events = new EventEmitter();
relayer.core.heartbeat.events = new EventEmitter();
relayer.provider.connection.on("open", async () => {
await disconnect(relayer.provider.connection);
});
await disconnect(relayer.provider.connection);
await relayer.transportClose();
}
}

function disconnect(socket: IJsonRpcConnection) {
return socket.close();
}
2 changes: 1 addition & 1 deletion packages/sign-client/package.json
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
"test:concurrency": "vitest run --dir test/concurrency",
"test:xregion": "vitest run --dir test/xregion",
"test": "npm run test:pre; npm run test:run",
"test:ignoreUnhandled": "npm run test:pre; npm run test:run -- --dangerouslyIgnoreUnhandledErrors",
"test:ignoreUnhandled": "npm run test:pre; npm run test:run -- --dangerouslyIgnoreUnhandledErrors --no-threads",
"test:canary": "vitest run --dir test/canary",
"test:lifecycle": "vitest run --dir test/lifecycle",
"canary": "npm run test:pre; npm run test:canary",
2 changes: 2 additions & 0 deletions packages/sign-client/src/controllers/engine.ts
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ export class Engine extends IEngine {
}

const publicKey = await this.client.core.crypto.generateKeyPair();

const proposal = {
requiredNamespaces,
relays: relays ?? [{ protocol: RELAYER_DEFAULT_PROTOCOL }],
@@ -131,6 +132,7 @@ export class Engine extends IEngine {
}

const id = await this.sendRequest(topic, "wc_sessionPropose", proposal);

const expiry = calcExpiry(FIVE_MINUTES);
await this.setProposal(id, { id, expiry, ...proposal });

4 changes: 0 additions & 4 deletions packages/sign-client/test/sdk/validation.spec.ts
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ describe("Sign Client Validation", () => {
let clients: Clients;
beforeAll(async () => {
clients = await initTwoClients();
await testConnectMethod(clients);
client = clients.A;
pairingTopic = client.pairing.keys[0];
proposalId = client.proposal.keys[0];
@@ -459,7 +458,6 @@ describe("Sign Client Validation", () => {
let clients: Clients;
beforeAll(async () => {
clients = await initTwoClients();
await testConnectMethod(clients);
client = clients.A;
pairingTopic = client.pairing.keys[0];
proposalId = client.proposal.keys[0];
@@ -715,7 +713,6 @@ describe("Sign Client Validation", () => {
let clients: Clients;
beforeAll(async () => {
clients = await initTwoClients();
await testConnectMethod(clients);
client = clients.A;
pairingTopic = client.pairing.keys[0];
proposalId = client.proposal.keys[0];
@@ -860,7 +857,6 @@ describe("Sign Client Validation", () => {
let clients: Clients;
beforeAll(async () => {
clients = await initTwoClients();
await testConnectMethod(clients);
client = clients.A;
pairingTopic = client.pairing.keys[0];
proposalId = client.proposal.keys[0];
6 changes: 3 additions & 3 deletions packages/sign-client/test/shared/values.ts
Original file line number Diff line number Diff line change
@@ -6,9 +6,9 @@ export const TEST_RELAY_URL = process.env.TEST_RELAY_URL
? process.env.TEST_RELAY_URL
: "ws://0.0.0.0:5555";

export const TEST_RELAY_URL_US = "wss://us-east-1.relay.walletconnect.com/";
export const TEST_RELAY_URL_EU = "wss://eu-central-1.relay.walletconnect.com/";
export const TEST_RELAY_URL_AP = "wss://ap-southeast-1.relay.walletconnect.com/";
export const TEST_RELAY_URL_US = "wss://us-east-1.relay.walletconnect.com";
export const TEST_RELAY_URL_EU = "wss://eu-central-1.relay.walletconnect.com";
export const TEST_RELAY_URL_AP = "wss://ap-southeast-1.relay.walletconnect.com";

// See https://github.com/WalletConnect/push-webhook-test-server
export const TEST_WEBHOOK_ENDPOINT = "https://webhook-push-test.walletconnect.com/";
13 changes: 1 addition & 12 deletions packages/sign-client/test/shared/ws.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import { IJsonRpcConnection } from "@walletconnect/jsonrpc-utils";
import { ICore } from "@walletconnect/types";
import EventEmitter from "events";

export async function disconnectSocket(core: ICore) {
if (core.relayer.connected) {
core.relayer.provider.events = new EventEmitter();
core.relayer.core.heartbeat.events = new EventEmitter();
core.relayer.provider.connection.on("open", async () => {
await disconnect(core.relayer.provider.connection);
});
await disconnect(core.relayer.provider.connection);
await core.relayer.transportClose();
}
}

function disconnect(socket: IJsonRpcConnection) {
return socket.close();
}

0 comments on commit 913958a

Please sign in to comment.