From 02d15d62dba180aa75bbb8dd4ed7b3179c334bee Mon Sep 17 00:00:00 2001 From: Marek Polak Date: Thu, 2 Jan 2025 15:21:48 +0100 Subject: [PATCH 1/5] test(connect): disable autoconfirm in override test --- packages/connect/e2e/common.setup.ts | 12 ++++++++---- packages/connect/e2e/tests/device/override.test.ts | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/connect/e2e/common.setup.ts b/packages/connect/e2e/common.setup.ts index 674bae1d0f9..0358f282bdf 100644 --- a/packages/connect/e2e/common.setup.ts +++ b/packages/connect/e2e/common.setup.ts @@ -127,10 +127,12 @@ export const setup = async ( ); }; +type InitParams = Partial[0]> & { autoConfirm?: boolean }; + export const initTrezorConnect = async ( // eslint-disable-next-line @typescript-eslint/no-shadow TrezorUserEnvLink: TrezorUserEnvLinkClass, - options?: Partial[0]>, + { autoConfirm = true, ...options }: InitParams = {}, ) => { TrezorConnect.removeAllListeners(); @@ -162,9 +164,11 @@ export const initTrezorConnect = async ( }); }); - TrezorConnect.on(UI.REQUEST_BUTTON, () => { - setTimeout(() => TrezorUserEnvLink.send({ type: 'emulator-press-yes' }), 1); - }); + if (autoConfirm) { + TrezorConnect.on(UI.REQUEST_BUTTON, () => { + setTimeout(() => TrezorUserEnvLink.send({ type: 'emulator-press-yes' }), 1); + }); + } await TrezorConnect.init({ manifest: { diff --git a/packages/connect/e2e/tests/device/override.test.ts b/packages/connect/e2e/tests/device/override.test.ts index b682d63f821..257fa7478b1 100644 --- a/packages/connect/e2e/tests/device/override.test.ts +++ b/packages/connect/e2e/tests/device/override.test.ts @@ -8,7 +8,7 @@ describe('TrezorConnect override param', () => { await setup(controller, { mnemonic: 'mnemonic_all', }); - await initTrezorConnect(controller); + await initTrezorConnect(controller, { autoConfirm: false }); }); afterAll(() => { From 5a68f5c661bd880f75f5ea303f521c358ae0a21e Mon Sep 17 00:00:00 2001 From: Marek Polak Date: Fri, 3 Jan 2025 13:46:16 +0100 Subject: [PATCH 2/5] test(connect): disable autoconfirm for EntryPin --- packages/connect/e2e/common.setup.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/connect/e2e/common.setup.ts b/packages/connect/e2e/common.setup.ts index 0358f282bdf..2cf1ba09a39 100644 --- a/packages/connect/e2e/common.setup.ts +++ b/packages/connect/e2e/common.setup.ts @@ -165,7 +165,8 @@ export const initTrezorConnect = async ( }); if (autoConfirm) { - TrezorConnect.on(UI.REQUEST_BUTTON, () => { + TrezorConnect.on(UI.REQUEST_BUTTON, e => { + if (e.code === 'ButtonRequest_PinEntry') return; setTimeout(() => TrezorUserEnvLink.send({ type: 'emulator-press-yes' }), 1); }); } From 95cd713ee2fd16c3f246417bf1a07929576fa9be Mon Sep 17 00:00:00 2001 From: Marek Polak Date: Mon, 6 Jan 2025 14:15:15 +0100 Subject: [PATCH 3/5] fix(blockchain-link): blockfrost getAccountInfo details fallback --- packages/blockchain-link/src/workers/blockfrost/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/blockchain-link/src/workers/blockfrost/index.ts b/packages/blockchain-link/src/workers/blockfrost/index.ts index b240f472249..b6ca8ce2b58 100644 --- a/packages/blockchain-link/src/workers/blockfrost/index.ts +++ b/packages/blockchain-link/src/workers/blockfrost/index.ts @@ -91,7 +91,8 @@ const pushTransaction = async (request: Request) = const getAccountInfo = async (request: Request) => { const api = await request.connect(); - const info = await api.getAccountInfo(request.payload); + const { details = 'basic', ...rest } = request.payload; + const info = await api.getAccountInfo({ details, ...rest }); return { type: RESPONSES.GET_ACCOUNT_INFO, From 6cde9ec5cf368b9131cf633d4572dadebbb4779c Mon Sep 17 00:00:00 2001 From: Marek Polak Date: Mon, 6 Jan 2025 15:53:36 +0100 Subject: [PATCH 4/5] test(connect): skip 2 in cancel test --- packages/connect/e2e/tests/device/cancel.test.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/connect/e2e/tests/device/cancel.test.ts b/packages/connect/e2e/tests/device/cancel.test.ts index 869404c5138..e411bc91bef 100644 --- a/packages/connect/e2e/tests/device/cancel.test.ts +++ b/packages/connect/e2e/tests/device/cancel.test.ts @@ -1,6 +1,6 @@ import { StartEmu, SetupEmu } from '@trezor/trezor-user-env-link'; -import { getController, initTrezorConnect } from '../../common.setup'; +import { conditionalTest, getController, initTrezorConnect } from '../../common.setup'; import TrezorConnect from '../../../src'; const getAddress = (showOnTrezor: boolean, coin: string = 'regtest') => { @@ -159,8 +159,7 @@ describe('TrezorConnect.cancel', () => { await assertGetAddressWorks(); }); - // todo: this should be conditionalTest(['2']) - it('Pin request - Cancel', async () => { + conditionalTest(['2'], 'Pin request - Cancel', async () => { await setupTest({ setupParams: { version: '1-latest', @@ -190,8 +189,7 @@ describe('TrezorConnect.cancel', () => { expect(feat.payload).toMatchObject({ initialized: true }); }); - // todo: this should be conditionalTest(['2']) - it('Word request - Cancel', async () => { + conditionalTest(['2'], 'Word request - Cancel', async () => { await controller.startEmu({ version: '1-latest', model: 'T1B1', wipe: true }); await controller.startBridge( // @ts-expect-error From d4df770257d77d43d6576720a193a7ce327c4e12 Mon Sep 17 00:00:00 2001 From: Marek Polak Date: Tue, 7 Jan 2025 15:04:31 +0100 Subject: [PATCH 5/5] test(connect): fix T3T1 auto lock test --- packages/connect/e2e/common.setup.ts | 8 ++++++++ .../e2e/tests/device/authorizeCoinjoin.test.ts | 12 ++++++++++-- packages/connect/e2e/tests/device/setBusy.test.ts | 12 ++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/connect/e2e/common.setup.ts b/packages/connect/e2e/common.setup.ts index 2cf1ba09a39..3355a767724 100644 --- a/packages/connect/e2e/common.setup.ts +++ b/packages/connect/e2e/common.setup.ts @@ -246,3 +246,11 @@ export const conditionalTest = (rules: string[], ...args: any) => { // @ts-expect-error return testMethod(...args); }; + +export const conditionalDescribe = (rules: string[], ...args: any) => { + const skipMethod = typeof jest !== 'undefined' ? describe.skip : xdescribe; + const testMethod = skipTest(rules) ? skipMethod : describe; + + // @ts-expect-error + return testMethod(...args); +}; diff --git a/packages/connect/e2e/tests/device/authorizeCoinjoin.test.ts b/packages/connect/e2e/tests/device/authorizeCoinjoin.test.ts index 28ce206111e..af5a7fb2653 100644 --- a/packages/connect/e2e/tests/device/authorizeCoinjoin.test.ts +++ b/packages/connect/e2e/tests/device/authorizeCoinjoin.test.ts @@ -1,9 +1,17 @@ import TrezorConnect from '../../../src'; -import { getController, setup, conditionalTest, initTrezorConnect } from '../../common.setup'; +import { + getController, + setup, + conditionalTest, + conditionalDescribe, + initTrezorConnect, +} from '../../common.setup'; const controller = getController(); -describe('TrezorConnect.authorizeCoinjoin', () => { +// skip T3T1 until `emulator-apply-settings` with `auto_lock_delay_ms` is fixed on emu +// https://github.com/trezor/trezor-user-env/issues/280 +conditionalDescribe(['!T3T1'], 'TrezorConnect.authorizeCoinjoin', () => { beforeAll(async () => { await setup(controller, { mnemonic: 'mnemonic_all', diff --git a/packages/connect/e2e/tests/device/setBusy.test.ts b/packages/connect/e2e/tests/device/setBusy.test.ts index 127823d0841..51379e274ba 100644 --- a/packages/connect/e2e/tests/device/setBusy.test.ts +++ b/packages/connect/e2e/tests/device/setBusy.test.ts @@ -1,9 +1,17 @@ import TrezorConnect from '../../../src'; -import { getController, setup, conditionalTest, initTrezorConnect } from '../../common.setup'; +import { + getController, + setup, + conditionalTest, + initTrezorConnect, + conditionalDescribe, +} from '../../common.setup'; const controller = getController(); -describe('TrezorConnect.setBusy', () => { +// skip T3T1 until `emulator-apply-settings` with `auto_lock_delay_ms` is fixed on emu +// https://github.com/trezor/trezor-user-env/issues/280 +conditionalDescribe(['!T3T1'], 'TrezorConnect.setBusy', () => { beforeAll(async () => { await setup(controller, { mnemonic: 'mnemonic_all',