Skip to content

Commit

Permalink
Merge pull request #8758 from LedgerHQ/support/fix-speculos-issue
Browse files Browse the repository at this point in the history
[QAA][Playwright][Speculos] Fix timeout issues
  • Loading branch information
ypolishchuk-ledger authored Dec 24, 2024
2 parents 63df274 + d575674 commit 3f98074
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion apps/ledger-live-desktop/tests/fixtures/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as path from "path";
import { OptionalFeatureMap } from "@ledgerhq/types-live";
import { getEnv, setEnv } from "@ledgerhq/live-env";
import { startSpeculos, stopSpeculos, specs } from "@ledgerhq/live-common/e2e/speculos";
import invariant from "invariant";

import { Application } from "tests/page";
import { safeAppendFile } from "tests/utils/fileUtils";
Expand Down Expand Up @@ -110,7 +111,11 @@ export const test = base.extend<TestFixtures>({
testInfo.title.replace(/ /g, "_"),
specs[speculosApp.name.replace(/ /g, "_")],
);
setEnv("SPECULOS_API_PORT", device?.ports.apiPort?.toString());
invariant(device, "[E2E Setup] Speculos not started");
const speculosApiPort = device.ports.apiPort;
invariant(speculosApiPort, "[E2E Setup] speculosApiPort not defined");

setEnv("SPECULOS_API_PORT", speculosApiPort.toString());
setEnv("MOCK", "");

if (cliCommands?.length) {
Expand Down
1 change: 0 additions & 1 deletion libs/ledger-live-common/src/e2e/speculos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ export async function startSpeculos(
try {
return await createSpeculosDevice(deviceParams);
} catch (e: unknown) {
if (process.env.CI) console.error(e);
console.error(e);
log("engine", `test ${testName} failed with ${String(e)}`);
}
Expand Down
4 changes: 2 additions & 2 deletions libs/speculos-transport/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ export async function createSpeculosDevice(
let destroyed = false;

const destroy = async () => {
if (destroyed) return;
if (destroyed) return Promise.resolve();
destroyed = true;
return new Promise((resolve, reject) => {
if (!data[speculosID]) return;
if (!data[speculosID]) return resolve(undefined);
delete data[speculosID];
exec(`docker rm -f ${speculosID}`, (error, stdout, stderr) => {
if (error) {
Expand Down

0 comments on commit 3f98074

Please sign in to comment.