Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update trezor-user-env #13865

Merged
merged 3 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/template-connect-test-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
required: false
default: "2-latest"
testFirmwareModel:
description: "Firmware model for the tests (example: R)"
description: "Firmware model for the tests (example: T3T1)"
type: "string"
required: false
nodeEnvironment:
Expand All @@ -30,7 +30,7 @@ on:
required: false
default: true
testDescription:
description: "A description to make test title more descriptive (example: 2-latest-R)"
description: "A description to make test title more descriptive (example: T3T1-latest)"
type: "string"
required: false
default: ""
Expand Down
18 changes: 8 additions & 10 deletions docker/docker-connect-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ set -euo pipefail

ENVIRONMENT=$1

if [[ "$ENVIRONMENT" != "web" && "$ENVIRONMENT" != "node" ]];
then
echo "either 'web' or 'node' must be specified as the first argument"
exit 1
if [[ "$ENVIRONMENT" != "web" && "$ENVIRONMENT" != "node" ]]; then
echo "either 'web' or 'node' must be specified as the first argument"
exit 1
fi

show_usage() {
Expand All @@ -35,7 +34,7 @@ show_usage() {
echo " -D PATH Set path to docker executable. Can be replaced with \`podman\`. default: docker"
echo " -e All methods except excluded, example: applySettings,signTransaction"
echo " -p Test pattern"
echo " -f Use specific firmware version, example: 2.1.4, 1.8.0 default: 2-main"
echo " -f Use specific firmware version, example: 2.1.4, 1.8.0 default: -main"
echo " -i Included methods only, example: applySettings,signTransaction"
echo " -s actual test script. default: 'yarn test:integration'"
echo " -u Firmware url"
Expand Down Expand Up @@ -106,11 +105,10 @@ shift $((OPTIND - 1))

export DOCKER_PATH

if [[ $ENVIRONMENT == "node" ]];
then
SCRIPT="yarn workspace @trezor/connect test:e2e:node"
else
SCRIPT="yarn workspace @trezor/connect test:e2e:web"
if [[ $ENVIRONMENT == "node" ]]; then
SCRIPT="yarn workspace @trezor/connect test:e2e:node"
else
SCRIPT="yarn workspace @trezor/connect test:e2e:web"
fi

# export essential process.env variables
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/passphrase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../support/helpers';

const url = process.env.URL || 'http://localhost:8088/';
const bridgeVersion = '2.0.31';
const bridgeVersion = '2.0.33';

const isWebExtension = process.env.IS_WEBEXTENSION === 'true';
const isCoreInPopup = process.env.CORE_IN_POPUP === 'true';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link';
import { createDeferred, Deferred } from '@trezor/utils';
import { log } from '../support/helpers';

const BRIDGE_VERSION = '2.0.31';
const BRIDGE_VERSION = '2.0.33';
const WAIT_AFTER_TEST = 3000; // how long test should wait for more potential trezord requests
const CONNECT_LEGACY_VERSION = '9.0.10';

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-popup/e2e/tests/popup-pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import fs from 'fs';

const url = process.env.URL || 'http://localhost:8088/';

const bridgeVersion = '2.0.31';
const bridgeVersion = '2.0.33';
// popup window reference
let popup: Page;
let persistentContext: BrowserContext | undefined;
Expand Down
28 changes: 7 additions & 21 deletions packages/connect-popup/e2e/tests/webextension-example.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,19 @@ test.beforeAll(async () => {

test.beforeEach(async () => {
await TrezorUserEnvLink.connect();
await TrezorUserEnvLink.send({
type: 'bridge-stop',
});
await TrezorUserEnvLink.send({
type: 'emulator-stop',
});
await TrezorUserEnvLink.send({
type: 'emulator-start',
await TrezorUserEnvLink.stopBridge();
await TrezorUserEnvLink.stopEmu();
await TrezorUserEnvLink.startEmu({
wipe: true,
});
await TrezorUserEnvLink.send({
type: 'emulator-setup',
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: false,
label: 'My Trevor',
needs_backup: false,
});
await TrezorUserEnvLink.send({
type: 'bridge-start',
});
await TrezorUserEnvLink.startBridge();
});

const getBrowserContext = async (pathToExtension: string) => {
Expand Down Expand Up @@ -103,10 +95,7 @@ test('Basic web extension MV2', async () => {

await popup.waitForSelector('text=3AnYTd2FGxJLNKL1AzxfW3FJMntp9D2KKX');

await Promise.all([
popup.waitForEvent('close'),
TrezorUserEnvLink.send({ type: 'emulator-press-yes' }),
]);
await Promise.all([popup.waitForEvent('close'), TrezorUserEnvLink.pressYes()]);

await page.waitForSelector('text=3AnYTd2FGxJLNKL1AzxfW3FJMntp9D2KKX');

Expand Down Expand Up @@ -156,10 +145,7 @@ test('Basic web extension MV3', async () => {

await popup.waitForSelector('text=3AnYTd2FGxJLNKL1AzxfW3FJMntp9D2KKX');

await Promise.all([
popup.waitForEvent('close'),
TrezorUserEnvLink.send({ type: 'emulator-press-yes' }),
]);
await Promise.all([popup.waitForEvent('close'), TrezorUserEnvLink.pressYes()]);

await browserContext.close();
});
33 changes: 11 additions & 22 deletions packages/connect/e2e/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { runCLI, getVersion as getJestVersion } from 'jest';
import webpack from 'webpack';
import karma from 'karma';

import { TrezorUserEnvLink, Firmwares } from '@trezor/trezor-user-env-link';
import { TrezorUserEnvLink, Firmwares, Model } from '@trezor/trezor-user-env-link';

import argv from './jest.config';

Expand All @@ -19,10 +19,13 @@ const getEmulatorOptions = (availableFirmwares: Firmwares) => {
const getLatestFirmware = (model: keyof Firmwares) =>
availableFirmwares[model].find(fw => !fw.replace('-arm', '').includes('-'));

const latest2 = getLatestFirmware('2');
const latest1 = getLatestFirmware('1');
const model =
firmwareModel && Object.keys(availableFirmwares).includes(firmwareModel)
? (firmwareModel as Model)
: 'T2T1';
const latest = getLatestFirmware(model);

if (!latest2 || !latest1) {
if (!latest) {
// should never happen
throw new Error('could not translate n-latest into specific firmware version');
}
Expand All @@ -31,17 +34,15 @@ const getEmulatorOptions = (availableFirmwares: Firmwares) => {
type: 'emulator-start',
wipe: true,
version: firmwareArg,
model,
};

if (firmwareArg === '2-latest') {
Object.assign(emulatorStartOpts, { version: latest2 });
}
if (firmwareArg === '1-latest') {
Object.assign(emulatorStartOpts, { version: latest1 });
if (firmwareArg?.endsWith('-latest')) {
Object.assign(emulatorStartOpts, { version: latest });
}
// no firmwareArg and not loading from url at the same time - provide fallback
if (!firmwareArg && !firmwareUrl) {
Object.assign(emulatorStartOpts, { version: latest2 });
Object.assign(emulatorStartOpts, { version: latest });
}
if (firmwareUrl) {
Object.assign(emulatorStartOpts, {
Expand All @@ -50,18 +51,6 @@ const getEmulatorOptions = (availableFirmwares: Firmwares) => {
});
}

if (firmwareModel) {
Object.assign(emulatorStartOpts, { model: firmwareModel });

// temporary, it seems that model "R" does not have any built versions
// and only master build is available
if (firmwareModel === 'R') {
[emulatorStartOpts.version] = availableFirmwares.R;
} else if (firmwareModel === 'T3T1') {
[emulatorStartOpts.version] = availableFirmwares.T3T1;
}
}

return emulatorStartOpts;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/analytics/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Analytics Events', () => {
cy.getTestElement('@analytics/toggle-switch').click({ force: true });
cy.getTestElement('@settings/menu/close').click();

cy.task('startEmu', { wipe: true, version: '2.6.0' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.6.0' });
cy.task('setupEmu', {
needs_backup: false,
mnemonic: 'all all all all all all all all all all all all',
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/backup/t2t1-fail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let requests: Requests;

describe('Backup fail', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('startEmu', { wipe: true, model: 'T2T1' });
cy.task('setupEmu', { needs_backup: true });
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/backup/t2t1-misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe('Backup misc', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('startEmu', { wipe: true, model: 'T2T1' });
cy.task('setupEmu', { needs_backup: true });
cy.task('startBridge');

Expand Down
3 changes: 2 additions & 1 deletion packages/suite-web/e2e/tests/backup/t2t1-success.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let requests: Requests;

describe('Backup success', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.8.1' });
cy.task('setupEmu', {
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
Expand Down Expand Up @@ -37,6 +37,7 @@ describe('Backup success', () => {
cy.getTestElement('@backup/start-button').click();
cy.getConfirmActionOnDeviceModal();

cy.task('pressYes');
cy.task('pressYes');
cy.task('swipeEmu', 'up');
cy.task('swipeEmu', 'up');
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/firmware/firmware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Firmware', () => {
});

it(`Firmware 2.5.2 outdated notification banner should open firmware update modal`, () => {
cy.task('startEmu', { wipe: true, version: '2.5.2' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.5.2' });
cy.task('setupEmu');
cy.task('startBridge');
cy.prefixedVisit('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Metadata - cancel metadata on device', () => {

it('user cancels metadata on device, choice is respected on subsequent runs but only for the cancelled wallet', () => {
// prepare test
cy.task('startEmu', { wipe: true, version: '2.7.0' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.7.0' });
cy.task('setupEmu', {
mnemonic,
passphrase_protection: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Onboarding - create wallet', () => {
// todo: skipping for it is too flaky..
// after calling "resetDevice" we almost always receive "device disconnected during action" which is error sent by bridge.
it.skip('Success (basic)', () => {
cy.task('startEmu', { version: '1-latest', wipe: true });
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@firmware/continue-button').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe('Onboarding - recover wallet T1B1', () => {
beforeEach(() => {
cy.task('startEmu', { version: '1-latest', wipe: true });
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
Expand Down Expand Up @@ -33,7 +33,7 @@ describe('Onboarding - recover wallet T1B1', () => {
cy.wait(501);
cy.task('stopEmu');
cy.getTestElement('@connect-device-prompt', { timeout: 20000 });
cy.task('startEmu', { version: '1-latest' });
cy.task('startEmu', { model: 'T1B1', version: '1-latest' });

cy.getTestElement('@onboarding/recovery/retry-button').click();
cy.getTestElement('@recover/select-count/12').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// todo: this started to fail mysteriously after merging new base image. Skipping it for now and will investigate.
describe.skip('Onboarding - recover wallet T1B1', () => {
before(() => {
cy.task('startEmu', { version: '1-latest', wipe: true });
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Onboarding - create wallet', () => {
// note: this is an example of test that can not be parametrized to be both integration (isolated) test and e2e test.
// the problem is that it always needs to run the newest possible emulator. If this was pinned to use emulator which is currently
// in production, and we locally bumped emulator version, we would get into a screen saying "update your firmware" and the test would fail.
cy.task('startEmu', { wipe: true, version: '2-master' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2-main' });
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@firmware/continue-button').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ describe('Onboarding - recover wallet T2T1', () => {
// note: this is an example of test that can not be parametrized to be both integration (isolated) test and e2e test.
// the problem is that it always needs to run the newest possible emulator. If this was pinned to use emulator which is currently
// in production, and we locally bumped emulator version, we would get into a screen saying "update your firmware" and the test would fail.
cy.task('startEmu', { wipe: true, version: '2-master' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2-main' });

// Disable revision check. On emulator '2-master' it wont pass as it is unreleased version
// Disable revision check. On emulator '2-main' it wont pass as it is unreleased version
cy.getTestElement('@device-compromised').should('be.visible');
cy.getTestElement('@suite/menu/settings').click();
cy.getTestElement('@settings/menu/device').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const shareTwoOfThree = [
describe('Onboarding - T2T1 in recovery mode', () => {
beforeEach(() => {
cy.task('startBridge');
cy.task('startEmu', { wipe: true, version: '2.4.3' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.5.3' });
cy.resetDb();
cy.viewport(1440, 2560);
cy.prefixedVisit('/');
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('Onboarding - T2T1 in recovery mode', () => {
cy.safeReload();

// now suite has reloaded. database is wiped.
cy.task('startEmu', { wipe: false, version: '2.4.3' });
cy.task('startEmu', { wipe: false, model: 'T2T1', version: '2.5.3' });
// analytics opt-out again
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@analytics/continue-button').click();
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Onboarding - T2T1 in recovery mode', () => {
cy.task('stopEmu');
cy.wait(501);
cy.getTestElement('@connect-device-prompt', { timeout: 30000 });
cy.task('startEmu', { wipe: false, version: '2.4.3' });
cy.task('startEmu', { wipe: false, model: 'T2T1', version: '2.5.3' });
cy.getTestElement('@onboarding/confirm-on-device');
cy.wait(501);
cy.task('pressYes');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Onboarding - recover wallet T2T1', () => {
cy.viewport(1440, 2560).resetDb();
cy.prefixedVisit('/');

cy.task('startEmu', { wipe: true, version: '2.5.3' });
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.5.3' });
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@analytics/continue-button').click();

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/recovery/t1b1-dry-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe.skip('Recovery - dry run', () => {
beforeEach(() => {
cy.task('startEmu', { version: '1-latest', wipe: true });
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.wait(2000);
cy.task('setupEmu', { needs_backup: false });
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// udp transport in suite and trying to enable this test again.
describe.skip('T1B1 - Device settings', () => {
beforeEach(() => {
cy.task('startEmu', { version: '1-latest', wipe: true });
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.task('setupEmu', { needs_backup: false });
cy.task('startBridge');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
describe('T2B1 - Device settings', () => {
const startEmuOpts = {
version: '2-main',
model: 'R', // TODO: T2B1 DeviceModelInternal
model: 'T2B1',
wipe: true,
};

Expand Down
Loading
Loading