From e0427d98bacf3e47c7d77bd2f5ac48f94dd57590 Mon Sep 17 00:00:00 2001 From: Jonathan Ho Date: Wed, 15 Mar 2023 16:49:28 -0700 Subject: [PATCH] test(gw): fix gw integration test (#2835) * test(gw): fix gw integration test * ci: increase timeout * chore(gw): fix redundant import --- .github/workflows/integration-test.yml | 2 +- packages/gateway/src/Shard.ts | 3 +-- packages/gateway/tests/integration/connection.spec.ts | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 57f12391d..ec98667e2 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -40,7 +40,7 @@ jobs: key: ${{ runner.os }}-turbo-build-${{ github.sha }} - name: Integration Test run: yarn test:integration --cache-dir=".turbo" --filter=./packages/${{ inputs.package }} - timeout-minutes: 1 + timeout-minutes: 3 - name: Collect and upload the coverage report uses: codecov/codecov-action@v3 with: diff --git a/packages/gateway/src/Shard.ts b/packages/gateway/src/Shard.ts index 746c3a715..06a74dc34 100644 --- a/packages/gateway/src/Shard.ts +++ b/packages/gateway/src/Shard.ts @@ -9,8 +9,7 @@ import type { RequestGuildMembers, } from '@discordeno/types' import { GatewayCloseEventCodes, GatewayIntents, GatewayOpcodes } from '@discordeno/types' -import { Collection, LeakyBucket, camelize, delay, logger } from '@discordeno/utils' -import { clearInterval } from 'node:timers' +import { camelize, Collection, delay, LeakyBucket, logger } from '@discordeno/utils' import { inflateSync } from 'node:zlib' import WebSocket from 'ws' import type { RequestMemberRequest } from './manager.js' diff --git a/packages/gateway/tests/integration/connection.spec.ts b/packages/gateway/tests/integration/connection.spec.ts index 43368c325..6cb1719cf 100644 --- a/packages/gateway/tests/integration/connection.spec.ts +++ b/packages/gateway/tests/integration/connection.spec.ts @@ -51,7 +51,7 @@ const createUws = async (options: { JSON.stringify({ op: 10, d: { - heartbeat_interval: 100, + heartbeat_interval: 1017, }, }), ) @@ -128,7 +128,7 @@ const createUws = async (options: { describe('gateway', () => { it('can connect to server', async function () { - this.timeout(6000) + this.timeout(15000) let resolveConnected: () => void const connected = new Promise((resolve) => (resolveConnected = resolve)) const uwsOptions = { onOpen: resolveConnected!, closing: false } @@ -142,7 +142,7 @@ describe('gateway', () => { }) it('will heartbeat', async function () { - this.timeout(6000) + this.timeout(15000) let resolveHeartbeat: () => void let resolveConnected: () => void const connected = new Promise((resolve) => (resolveConnected = resolve)) @@ -161,7 +161,7 @@ describe('gateway', () => { await connected const timeout = setTimeout(() => { throw new Error('Not heartbeat in time') - }, 100) + }, 1017) await Heartbeated clearTimeout(timeout) uwsOptions.closing = true