diff --git a/packages/connect/src/core/__tests__/onCallFirmwareUpdate.test.ts b/packages/connect/src/core/__tests__/onCallFirmwareUpdate.test.ts index cb1a2a81da0..46fa6fa1b13 100644 --- a/packages/connect/src/core/__tests__/onCallFirmwareUpdate.test.ts +++ b/packages/connect/src/core/__tests__/onCallFirmwareUpdate.test.ts @@ -554,4 +554,53 @@ describe('onCallFirmwareUpdate', () => { await deviceList.dispose(); }); + + it('T3W1: from binary', async () => { + const { context, deviceList, waitForDeviceList, buildFixture } = setupTest(); + const t3 = { + internal_model: 'T3W1', + }; + + await waitForDeviceList([ + // GetFeatures before reboot + buildFixture('0037', { ...t3 }), + // GetFeatures in bootloader mode + buildFixture('0037', { ...t3, bootloader_mode: true }), + // Initialize in bootloader mode + buildFixture('0000', { ...t3 }), + // GetFeatures after reboot + buildFixture('0037', { ...t3 }), + ]); + + const binary = await httpRequestMock(); + const result = await runFirmwareUpdate({ + params: { binary }, + context, + }); + + expect(result.check).toEqual('omitted'); + expect(result.versionCheck).toEqual(true); + + await deviceList.dispose(); + }); + + // NOTE: this test fails because there are no official releases for T3W1, should be removed after release + it('T3W1: failed from config', async () => { + const { context, deviceList, waitForDeviceList, buildFixture } = setupTest(); + const t3 = { internal_model: 'T3W1' }; + + await waitForDeviceList([ + // GetFeatures before reboot + buildFixture('0037', { ...t3 }), + ]); + + await expect(() => + onCallFirmwareUpdate({ + params: {}, + context, + }), + ).rejects.toThrow('firmwareRelease is not set'); + + await deviceList.dispose(); + }); }); diff --git a/packages/connect/src/core/onCallFirmwareUpdate.ts b/packages/connect/src/core/onCallFirmwareUpdate.ts index 1093c2d8020..117260ff4d6 100644 --- a/packages/connect/src/core/onCallFirmwareUpdate.ts +++ b/packages/connect/src/core/onCallFirmwareUpdate.ts @@ -185,9 +185,6 @@ const getBinaryHelper = ( postMessage: PostMessage, btcOnly: boolean, ) => { - if (!device.firmwareRelease) { - throw ERRORS.TypedError('Runtime', 'device.firmwareRelease is not set'); - } if (params.binary) { return { binary: params.binary, @@ -196,6 +193,10 @@ const getBinaryHelper = ( }; } + if (!device.firmwareRelease) { + throw ERRORS.TypedError('Runtime', 'device.firmwareRelease is not set'); + } + const { intermediaryVersion, release: { version }, @@ -318,10 +319,6 @@ export const onCallFirmwareUpdate = async ({ log.debug('onCallFirmwareUpdate with params: ', params); const device = await initDevice(params?.device?.path); - if (!device.firmwareRelease) { - throw ERRORS.TypedError('Runtime', 'device.firmwareRelease is not set'); - } - if (deviceList.getDeviceCount() > 1) { throw ERRORS.TypedError( 'Device_MultipleNotSupported', @@ -378,7 +375,7 @@ export const onCallFirmwareUpdate = async ({ const targetLanguage = params.language || device.features.language || 'en-US'; const languageBlob = - language && targetLanguage !== 'en-US' + device.firmwareRelease && language && targetLanguage !== 'en-US' ? await getLanguage({ language: targetLanguage, version: device.firmwareRelease.release.version, @@ -438,7 +435,7 @@ export const onCallFirmwareUpdate = async ({ ); } - const intermediary = !params.binary && device.firmwareRelease.intermediaryVersion; + const intermediary = !params.binary && device.firmwareRelease?.intermediaryVersion; const bootloaderVersion = reconnectedDevice.getVersion(); // note: fw major_version 1 requires calling initialize before calling FirmwareErase. Without it device would not respond