From 052bdba7c67245789f48ac68237ffcb811fcbba9 Mon Sep 17 00:00:00 2001 From: Victor Alber Date: Thu, 25 Jul 2024 14:04:42 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=92=9Aupdate=20labels=20for=20ETH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ledger-live-desktop/tests/enum/Currency.ts | 8 ++++---- apps/ledger-live-desktop/tests/page/speculos.page.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/ledger-live-desktop/tests/enum/Currency.ts b/apps/ledger-live-desktop/tests/enum/Currency.ts index 0c5f51533ede..1c42be50a292 100644 --- a/apps/ledger-live-desktop/tests/enum/Currency.ts +++ b/apps/ledger-live-desktop/tests/enum/Currency.ts @@ -38,28 +38,28 @@ export class Currency { "Ethereum", "ETH", "Ethereum", - [DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT], + [DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT], [DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT], ); static readonly tETH = new Currency( "Ethereum Holesky", "𝚝ETH", "Ethereum Holesky", - [DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT], + [DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT], [DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT], ); static readonly sepETH = new Currency( "Ethereum Sepolia", "𝚝ETH", "Ethereum Sepolia", - [DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT], + [DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT], [DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT], ); static readonly ETC = new Currency( "Ethereum Classic", "ETC", "Ethereum Classic", - [DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT], + [DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT], [DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT], ); static readonly SOL = new Currency( diff --git a/apps/ledger-live-desktop/tests/page/speculos.page.ts b/apps/ledger-live-desktop/tests/page/speculos.page.ts index a2fa47fdd0e1..71f836c57fbb 100644 --- a/apps/ledger-live-desktop/tests/page/speculos.page.ts +++ b/apps/ledger-live-desktop/tests/page/speculos.page.ts @@ -25,9 +25,9 @@ export class SpeculosPage extends AppPage { @step("Verify transaction info on device") async expectValidTxInfo(tx: Transaction) { - const amountScreen = await pressRightUntil(DeviceLabels.AMOUT); + const amountScreen = await pressRightUntil(tx.accountToDebit.currency.sendPattern[0]); expect(verifyAmount(tx.amount, amountScreen)).toBe(true); - const addressScreen = await pressRightUntil(DeviceLabels.ADDRESS); + const addressScreen = await pressRightUntil(tx.accountToDebit.currency.sendPattern[1]); expect(assertAddressesEquality(tx.recipient, addressScreen)).toBe(true); await pressRightUntil(tx.accountToDebit.currency.sendPattern[2]); await pressBoth(); From 0809ef2bc31403e59fc0640291626c5734cc882a Mon Sep 17 00:00:00 2001 From: Victor Alber Date: Thu, 25 Jul 2024 17:18:43 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20adding=20findLatest?= =?UTF-8?q?AppCandidate=20function=20to=20have=20the=20latest=20app=20vers?= =?UTF-8?q?ion=20+=20latest=20firmware=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ledger-live-desktop/tests/utils/speculos.ts | 4 ++-- libs/ledger-live-common/src/load/speculos.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/ledger-live-desktop/tests/utils/speculos.ts b/apps/ledger-live-desktop/tests/utils/speculos.ts index d9e8ba3387b7..fe4c78979dea 100644 --- a/apps/ledger-live-desktop/tests/utils/speculos.ts +++ b/apps/ledger-live-desktop/tests/utils/speculos.ts @@ -4,7 +4,7 @@ import { listAppCandidates, createSpeculosDevice, releaseSpeculosDevice, - findAppCandidate, + findLatestAppCandidate, SpeculosTransport, } from "@ledgerhq/live-common/load/speculos"; import { SpeculosDevice } from "@ledgerhq/speculos-transport"; @@ -202,7 +202,7 @@ export async function startSpeculos( } const { appQuery, dependency, onSpeculosDeviceCreated } = spec; - const appCandidate = findAppCandidate(appCandidates, appQuery); + const appCandidate = findLatestAppCandidate(appCandidates, appQuery); if (!appCandidate) { console.warn("no app found for " + testName); console.warn(appQuery); diff --git a/libs/ledger-live-common/src/load/speculos.ts b/libs/ledger-live-common/src/load/speculos.ts index d344ca9e06d5..8ede263d7a9b 100644 --- a/libs/ledger-live-common/src/load/speculos.ts +++ b/libs/ledger-live-common/src/load/speculos.ts @@ -123,6 +123,20 @@ export function appCandidatesMatches(appCandidate: AppCandidate, search: AppSear (search.appVersion && semver.satisfies(appCandidate.appVersion, search.appVersion))) ); } + +export const findLatestAppCandidate = ( + appCandidates: AppCandidate[], + search: AppSearch, +): AppCandidate | null => { + let apps = appCandidates.filter(c => appCandidatesMatches(c, search)); + if (apps.length === 0) { + return null; + } + + apps = apps.sort((a, b) => semver.rcompare(a.appVersion, b.appVersion)); + return apps[0]; +}; + export const findAppCandidate = ( appCandidates: AppCandidate[], search: AppSearch,