@onekeyfe/hd-core 1.2.0-alpha.40 → 1.2.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -78
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +12 -132
- package/__tests__/homescreen.test.ts +1 -41
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/open-wallet-session.test.ts +18 -259
- package/__tests__/protocol-v2-unlock-policy.test.ts +35 -86
- package/__tests__/protocol-v2.test.ts +632 -333
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +11 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +22 -5
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +8 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +30 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -2
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/core/deviceEventRegistration.d.ts +0 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +4 -22
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/events/device.d.ts +0 -4
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -27
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +181 -88
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3162 -1614
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +3 -3
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -4
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +69 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -3
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -3
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/settings.d.ts +13 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +0 -4
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +0 -10
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +10 -8
- package/src/api/CheckAllFirmwareRelease.ts +51 -6
- package/src/api/FirmwareUpdateV2.ts +298 -120
- package/src/api/FirmwareUpdateV3.ts +263 -57
- package/src/api/FirmwareUpdateV4.ts +748 -281
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -54
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -32
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/device/DeviceUpdateBootloader.ts +122 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +57 -0
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +745 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +392 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- package/src/api/helpers/protocolV2FileWrite.ts +4 -11
- package/src/api/index.ts +0 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- package/src/core/deviceEventRegistration.ts +0 -4
- package/src/core/index.ts +75 -118
- package/src/data/messages/messages-protocol-v2.json +0 -10
- package/src/data-manager/DataManager.ts +33 -33
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +21 -193
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-request.ts +2 -32
- package/src/index.ts +5 -0
- package/src/inject.ts +22 -3
- package/src/lowLevelInject.ts +5 -1
- package/src/protocols/protocol-v2/features.ts +2 -9
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +5 -31
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +18 -93
- package/src/topLevelInject.ts +5 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -0
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -0
- package/src/types/api/firmwareUpdate.ts +76 -0
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -2
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/settings.ts +13 -0
- package/src/utils/deviceFeaturesUtils.ts +0 -4
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/deviceUploadNft.test.ts +0 -187
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -56
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -30
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -29
- package/dist/utils/pro2Nft.d.ts.map +0 -1
- package/dist/utils/uiProgressThrottle.d.ts +0 -3
- package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -166
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -117
- package/src/utils/pro2Nft.ts +0 -91
- package/src/utils/uiProgressThrottle.ts +0 -63
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
import { DeviceType } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
4
|
import { Device } from '../src/device/Device';
|
|
@@ -43,70 +43,6 @@ const getProtocolV2LoaderInfo = (mode: 'bootloader' | 'romloader') => ({
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
describe('getDeviceState', () => {
|
|
46
|
-
test('coalesces concurrent Protocol V2 runtime-context negotiation', async () => {
|
|
47
|
-
let resolveProtocolInfo:
|
|
48
|
-
| ((value: { message: typeof protocolV2ApplicationInfo }) => void)
|
|
49
|
-
| undefined;
|
|
50
|
-
const typedCall = jest.fn(
|
|
51
|
-
() =>
|
|
52
|
-
new Promise<{ message: typeof protocolV2ApplicationInfo }>(resolve => {
|
|
53
|
-
resolveProtocolInfo = resolve;
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
const device = createV2Device(typedCall);
|
|
57
|
-
|
|
58
|
-
const first = device.ensureProtocolV2RuntimeContext();
|
|
59
|
-
const second = device.ensureProtocolV2RuntimeContext();
|
|
60
|
-
resolveProtocolInfo?.({ message: protocolV2ApplicationInfo });
|
|
61
|
-
|
|
62
|
-
await expect(Promise.all([first, second])).resolves.toEqual([
|
|
63
|
-
protocolV2ApplicationInfo,
|
|
64
|
-
protocolV2ApplicationInfo,
|
|
65
|
-
]);
|
|
66
|
-
expect(typedCall).toHaveBeenCalledTimes(1);
|
|
67
|
-
expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
68
|
-
eventless_wallet_session: true,
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('renegotiates Protocol V2 runtime context after transport disconnect', async () => {
|
|
73
|
-
const typedCall = jest.fn().mockResolvedValue({ message: protocolV2ApplicationInfo });
|
|
74
|
-
const device = createV2Device(typedCall);
|
|
75
|
-
|
|
76
|
-
await device.ensureProtocolV2RuntimeContext();
|
|
77
|
-
await device.ensureProtocolV2RuntimeContext();
|
|
78
|
-
device.markTransportDisconnected();
|
|
79
|
-
await device.ensureProtocolV2RuntimeContext();
|
|
80
|
-
|
|
81
|
-
expect(typedCall).toHaveBeenCalledTimes(2);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('rejects every waiter when runtime-context negotiation is invalidated', async () => {
|
|
85
|
-
let resolveProtocolInfo:
|
|
86
|
-
| ((value: { message: typeof protocolV2ApplicationInfo }) => void)
|
|
87
|
-
| undefined;
|
|
88
|
-
const typedCall = jest.fn(
|
|
89
|
-
() =>
|
|
90
|
-
new Promise<{ message: typeof protocolV2ApplicationInfo }>(resolve => {
|
|
91
|
-
resolveProtocolInfo = resolve;
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
const device = createV2Device(typedCall);
|
|
95
|
-
|
|
96
|
-
const first = device.ensureProtocolV2RuntimeContext();
|
|
97
|
-
const second = device.ensureProtocolV2RuntimeContext();
|
|
98
|
-
const firstExpectation = expect(first).rejects.toMatchObject({
|
|
99
|
-
errorCode: HardwareErrorCode.DeviceInitializeFailed,
|
|
100
|
-
});
|
|
101
|
-
const secondExpectation = expect(second).rejects.toMatchObject({
|
|
102
|
-
errorCode: HardwareErrorCode.DeviceInitializeFailed,
|
|
103
|
-
});
|
|
104
|
-
device.markTransportDisconnected();
|
|
105
|
-
resolveProtocolInfo?.({ message: protocolV2ApplicationInfo });
|
|
106
|
-
|
|
107
|
-
await Promise.all([firstExpectation, secondExpectation]);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
46
|
test('does not expose the internal wallet session', async () => {
|
|
111
47
|
const device = createV2Device(jest.fn());
|
|
112
48
|
device.updateState({ protocol: 'V2' }, 'initialize');
|
|
@@ -223,20 +159,15 @@ describe('getDeviceState', () => {
|
|
|
223
159
|
throw new Error(`Unexpected request: ${requestType}`);
|
|
224
160
|
});
|
|
225
161
|
const device = createV2Device(typedCall);
|
|
226
|
-
device.updateState(
|
|
227
|
-
{
|
|
228
|
-
protocol: 'V2',
|
|
229
|
-
identity: { deviceType: EDeviceType.Pro2 },
|
|
230
|
-
status: { mode },
|
|
231
|
-
raw: { protocolV2ProtocolInfo: getProtocolV2LoaderInfo(mode) },
|
|
232
|
-
},
|
|
233
|
-
'initialize'
|
|
234
|
-
);
|
|
162
|
+
device.updateState({ protocol: 'V2', status: { mode } }, 'initialize');
|
|
235
163
|
|
|
236
164
|
const state = await device.getDeviceState({ refreshSections: ['status'] });
|
|
237
165
|
|
|
238
166
|
expect(state.status.mode).toBe(mode);
|
|
239
|
-
expect(typedCall
|
|
167
|
+
expect(typedCall.mock.calls.map(call => call[0])).toEqual([
|
|
168
|
+
'DeviceInfoGet',
|
|
169
|
+
'ProtocolInfoRequest',
|
|
170
|
+
]);
|
|
240
171
|
}
|
|
241
172
|
);
|
|
242
173
|
|
|
@@ -256,14 +187,7 @@ describe('getDeviceState', () => {
|
|
|
256
187
|
return { message: { init_states: true, unlocked: true, device_id: 'device-1' } };
|
|
257
188
|
});
|
|
258
189
|
const device = createV2Device(typedCall);
|
|
259
|
-
device.updateState(
|
|
260
|
-
{
|
|
261
|
-
protocol: 'V2',
|
|
262
|
-
status: { mode: 'normal' },
|
|
263
|
-
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
264
|
-
},
|
|
265
|
-
'initialize'
|
|
266
|
-
);
|
|
190
|
+
device.updateState({ protocol: 'V2', status: { mode: 'normal' } }, 'initialize');
|
|
267
191
|
|
|
268
192
|
const state = await device.getDeviceState({ refreshSections: ['status'] });
|
|
269
193
|
|
|
@@ -281,14 +205,7 @@ describe('getDeviceState', () => {
|
|
|
281
205
|
},
|
|
282
206
|
});
|
|
283
207
|
const device = createV2Device(typedCall);
|
|
284
|
-
device.updateState(
|
|
285
|
-
{
|
|
286
|
-
protocol: 'V2',
|
|
287
|
-
status: { mode: 'normal' },
|
|
288
|
-
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
289
|
-
},
|
|
290
|
-
'initialize'
|
|
291
|
-
);
|
|
208
|
+
device.updateState({ protocol: 'V2', status: { mode: 'normal' } }, 'initialize');
|
|
292
209
|
const onState = jest.fn();
|
|
293
210
|
device.on(DEVICE.STATE, onState);
|
|
294
211
|
|
|
@@ -333,18 +250,13 @@ describe('getDeviceState', () => {
|
|
|
333
250
|
throw new Error(`Unexpected request: ${requestType}`);
|
|
334
251
|
});
|
|
335
252
|
const device = createV2Device(typedCall);
|
|
336
|
-
device.updateState(
|
|
337
|
-
{
|
|
338
|
-
protocol: 'V2',
|
|
339
|
-
status: { mode: 'normal' },
|
|
340
|
-
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
341
|
-
},
|
|
342
|
-
'initialize'
|
|
343
|
-
);
|
|
253
|
+
device.updateState({ protocol: 'V2', status: { mode: 'normal' } }, 'initialize');
|
|
344
254
|
|
|
345
255
|
const state = await device.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
346
256
|
|
|
347
257
|
expect(typedCall.mock.calls.map(call => call[0])).toEqual([
|
|
258
|
+
'DeviceInfoGet',
|
|
259
|
+
'ProtocolInfoRequest',
|
|
348
260
|
'DeviceStatusGet',
|
|
349
261
|
'DeviceSettingsGet',
|
|
350
262
|
]);
|
|
@@ -376,11 +288,7 @@ describe('getDeviceState', () => {
|
|
|
376
288
|
});
|
|
377
289
|
const device = createV2Device(typedCall);
|
|
378
290
|
device.updateState(
|
|
379
|
-
{
|
|
380
|
-
protocol: 'V2',
|
|
381
|
-
status: { mode: 'normal', unlocked: true },
|
|
382
|
-
raw: { protocolV2ProtocolInfo: protocolV2ApplicationInfo },
|
|
383
|
-
},
|
|
291
|
+
{ protocol: 'V2', status: { mode: 'normal', unlocked: true } },
|
|
384
292
|
'initialize'
|
|
385
293
|
);
|
|
386
294
|
|
|
@@ -466,34 +374,6 @@ describe('getDeviceState', () => {
|
|
|
466
374
|
});
|
|
467
375
|
});
|
|
468
376
|
|
|
469
|
-
test.each([
|
|
470
|
-
EDeviceType.Classic,
|
|
471
|
-
EDeviceType.Classic1s,
|
|
472
|
-
EDeviceType.ClassicPure,
|
|
473
|
-
EDeviceType.Mini,
|
|
474
|
-
])('keeps the GetFeatures-only firmware path for %s', async deviceType => {
|
|
475
|
-
const typedCall = jest.fn().mockResolvedValue({
|
|
476
|
-
message: {
|
|
477
|
-
onekey_device_type: deviceType.toUpperCase(),
|
|
478
|
-
initialized: true,
|
|
479
|
-
onekey_firmware_version: '3.5.0',
|
|
480
|
-
se_ver: '1.1.0.2',
|
|
481
|
-
},
|
|
482
|
-
});
|
|
483
|
-
const device = createV1Device(typedCall);
|
|
484
|
-
|
|
485
|
-
const state = await device.getDeviceState({
|
|
486
|
-
refreshSections: ['identity', 'versions', 'verification'],
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
expect(typedCall.mock.calls.map(call => call[0])).toEqual(['GetFeatures']);
|
|
490
|
-
expect(state.versions).toMatchObject({
|
|
491
|
-
firmware: '3.5.0',
|
|
492
|
-
se: '1.1.0.2',
|
|
493
|
-
se01: '1.1.0.2',
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
|
|
497
377
|
test('does not clear Protocol V1 firmware details during a later runtime refresh', async () => {
|
|
498
378
|
let getFeaturesCount = 0;
|
|
499
379
|
const typedCall = jest.fn().mockImplementation((requestType: string) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
|
-
import { getHomeScreenSize
|
|
3
|
+
import { getHomeScreenSize } from '../src/utils/homescreen';
|
|
4
4
|
|
|
5
5
|
describe('getHomeScreenSize', () => {
|
|
6
6
|
it('returns the Pro 2 wallpaper dimensions', () => {
|
|
@@ -21,44 +21,4 @@ describe('getHomeScreenSize', () => {
|
|
|
21
21
|
})
|
|
22
22
|
).toBeUndefined();
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
it('does not reuse the wallpaper homeScreenType for Pro 2 NFT dimensions', () => {
|
|
26
|
-
expect(
|
|
27
|
-
getHomeScreenSize({
|
|
28
|
-
deviceType: EDeviceType.Pro2,
|
|
29
|
-
homeScreenType: 'Nft',
|
|
30
|
-
thumbnail: false,
|
|
31
|
-
})
|
|
32
|
-
).toEqual({ width: 604, height: 1024 });
|
|
33
|
-
expect(
|
|
34
|
-
getHomeScreenSize({
|
|
35
|
-
deviceType: EDeviceType.Pro2,
|
|
36
|
-
homeScreenType: 'Nft',
|
|
37
|
-
thumbnail: true,
|
|
38
|
-
})
|
|
39
|
-
).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('getNftSize', () => {
|
|
44
|
-
it('returns the Pro 2 NFT image and thumbnail dimensions independently', () => {
|
|
45
|
-
expect(getNftSize({ deviceType: EDeviceType.Pro2 })).toEqual({ width: 540, height: 540 });
|
|
46
|
-
expect(getNftSize({ deviceType: EDeviceType.Pro2, thumbnail: true })).toEqual({
|
|
47
|
-
width: 263,
|
|
48
|
-
height: 263,
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('preserves the legacy NFT dimensions', () => {
|
|
53
|
-
expect(getNftSize({ deviceType: EDeviceType.Touch })).toEqual({ width: 480, height: 800 });
|
|
54
|
-
expect(getNftSize({ deviceType: EDeviceType.Touch, thumbnail: true })).toEqual({
|
|
55
|
-
width: 238,
|
|
56
|
-
height: 238,
|
|
57
|
-
});
|
|
58
|
-
expect(getNftSize({ deviceType: EDeviceType.Pro, thumbnail: true })).toEqual({
|
|
59
|
-
width: 226,
|
|
60
|
-
height: 226,
|
|
61
|
-
radius: 40,
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
24
|
});
|
|
@@ -104,7 +104,7 @@ describe('getLogBlockLabel', () => {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
it.each(['
|
|
107
|
+
it.each(['deviceUploadWallpaper', 'uploadPortfolio', 'fileWrite', 'fileRead'])(
|
|
108
108
|
'keeps metadata and replaces binary payloads with their size for %s',
|
|
109
109
|
method => {
|
|
110
110
|
const request = { method, path: 'resource.bin', data: new Uint8Array(1024) };
|
|
@@ -5,7 +5,6 @@ import GetPassphraseState from '../src/api/GetPassphraseState';
|
|
|
5
5
|
import OpenWalletSession from '../src/api/OpenWalletSession';
|
|
6
6
|
import { Device } from '../src/device/Device';
|
|
7
7
|
import { deviceWalletSessionStore } from '../src/device/DeviceWalletSessionStore';
|
|
8
|
-
import { ensureProtocolV2WalletSessionUnlocked } from '../src/protocols/protocol-v2/walletSession';
|
|
9
8
|
|
|
10
9
|
jest.mock('../src/data/config', () => ({
|
|
11
10
|
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
@@ -27,7 +26,6 @@ const createDevice = ({
|
|
|
27
26
|
unlocked: true,
|
|
28
27
|
passphraseProtection,
|
|
29
28
|
attachToPinEnabled: false,
|
|
30
|
-
unlockedAttachPin: false,
|
|
31
29
|
},
|
|
32
30
|
commands: {
|
|
33
31
|
typedCall: jest.fn((request: string, ...args: unknown[]) => {
|
|
@@ -45,21 +43,10 @@ const createDevice = ({
|
|
|
45
43
|
}),
|
|
46
44
|
promptPassphrase,
|
|
47
45
|
},
|
|
48
|
-
|
|
49
|
-
device
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
),
|
|
53
|
-
getDeviceState: jest.fn(() =>
|
|
54
|
-
Promise.resolve({
|
|
55
|
-
identity: { deviceId: 'device-1' },
|
|
56
|
-
status: {
|
|
57
|
-
unlocked: device.features.unlocked,
|
|
58
|
-
passphraseProtection: device.features.passphraseProtection,
|
|
59
|
-
unlockedAttachPin: device.features.unlockedAttachPin,
|
|
60
|
-
},
|
|
61
|
-
})
|
|
62
|
-
),
|
|
46
|
+
getDeviceState: jest.fn().mockResolvedValue({
|
|
47
|
+
identity: { deviceId: 'device-1' },
|
|
48
|
+
status: { passphraseProtection },
|
|
49
|
+
}),
|
|
63
50
|
getCurrentDeviceId: () => 'device-1',
|
|
64
51
|
getCurrentPassphraseProtection: () => passphraseProtection,
|
|
65
52
|
getInternalState: () =>
|
|
@@ -95,50 +82,6 @@ describe('openWalletSession', () => {
|
|
|
95
82
|
deviceWalletSessionStore.clear();
|
|
96
83
|
});
|
|
97
84
|
|
|
98
|
-
test('unlocks a locked Protocol V2 device before restoring a wallet session', async () => {
|
|
99
|
-
const device = {
|
|
100
|
-
commands: {
|
|
101
|
-
typedCall: jest.fn().mockResolvedValue({ message: { unlocked: false } }),
|
|
102
|
-
},
|
|
103
|
-
isBootloader: jest.fn().mockReturnValue(false),
|
|
104
|
-
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
105
|
-
isRomloader: jest.fn().mockReturnValue(false),
|
|
106
|
-
state: { status: { unlocked: false } },
|
|
107
|
-
unlockDevice: jest.fn().mockResolvedValue(undefined),
|
|
108
|
-
updateProtocolV2Status: jest.fn(function updateProtocolV2Status(
|
|
109
|
-
this: { state: { status: { unlocked: boolean } } },
|
|
110
|
-
status: { unlocked?: boolean }
|
|
111
|
-
) {
|
|
112
|
-
this.state.status.unlocked = status.unlocked ?? this.state.status.unlocked;
|
|
113
|
-
}),
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
await expect(ensureProtocolV2WalletSessionUnlocked(device as any)).resolves.toBe(true);
|
|
117
|
-
expect(device.commands.typedCall).toHaveBeenCalledWith('DeviceStatusGet', 'DeviceStatus', {});
|
|
118
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
|
|
119
|
-
source: 'unlock-coordinator',
|
|
120
|
-
reason: 'device-locked',
|
|
121
|
-
deviceOnly: true,
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('does not request PIN when wallet-session recovery finds the device unlocked', async () => {
|
|
126
|
-
const device = {
|
|
127
|
-
commands: {
|
|
128
|
-
typedCall: jest.fn().mockResolvedValue({ message: { unlocked: true } }),
|
|
129
|
-
},
|
|
130
|
-
isBootloader: jest.fn().mockReturnValue(false),
|
|
131
|
-
isProtocolV2: jest.fn().mockReturnValue(true),
|
|
132
|
-
isRomloader: jest.fn().mockReturnValue(false),
|
|
133
|
-
state: { status: { unlocked: true } },
|
|
134
|
-
unlockDevice: jest.fn(),
|
|
135
|
-
updateProtocolV2Status: jest.fn(),
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
await expect(ensureProtocolV2WalletSessionUnlocked(device as any)).resolves.toBe(false);
|
|
139
|
-
expect(device.unlockDevice).not.toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
85
|
test.each([{ useEmptyPassphrase: true }, { initSession: true }, {}])(
|
|
143
86
|
'requires the explicit mode in the new public API: %p',
|
|
144
87
|
legacyParams => {
|
|
@@ -330,24 +273,10 @@ describe('openWalletSession', () => {
|
|
|
330
273
|
typedCall,
|
|
331
274
|
promptPassphrase: jest.fn().mockResolvedValue({ passphraseOnDevice: true }),
|
|
332
275
|
});
|
|
333
|
-
device.getDeviceState = jest
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
status: {
|
|
338
|
-
unlocked: false,
|
|
339
|
-
passphraseProtection: null,
|
|
340
|
-
unlockedAttachPin: null,
|
|
341
|
-
},
|
|
342
|
-
})
|
|
343
|
-
.mockResolvedValue({
|
|
344
|
-
identity: { deviceId: 'device-1' },
|
|
345
|
-
status: {
|
|
346
|
-
unlocked: true,
|
|
347
|
-
passphraseProtection: true,
|
|
348
|
-
unlockedAttachPin: false,
|
|
349
|
-
},
|
|
350
|
-
});
|
|
276
|
+
device.getDeviceState = jest.fn().mockResolvedValue({
|
|
277
|
+
identity: { deviceId: 'device-1' },
|
|
278
|
+
status: { unlocked: false, passphraseProtection: true },
|
|
279
|
+
});
|
|
351
280
|
method.device = device as any;
|
|
352
281
|
|
|
353
282
|
await expect(method.run()).resolves.toMatchObject({
|
|
@@ -401,12 +330,6 @@ describe('openWalletSession', () => {
|
|
|
401
330
|
status.passphrase_enabled ?? device.features.passphraseProtection;
|
|
402
331
|
return device.features;
|
|
403
332
|
});
|
|
404
|
-
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
405
|
-
device.features.unlocked = true;
|
|
406
|
-
device.features.passphraseProtection = true;
|
|
407
|
-
device.features.unlockedAttachPin = false;
|
|
408
|
-
return Promise.resolve(device.features);
|
|
409
|
-
});
|
|
410
333
|
method.device = device as any;
|
|
411
334
|
|
|
412
335
|
await expect(method.run()).resolves.toEqual({
|
|
@@ -416,98 +339,10 @@ describe('openWalletSession', () => {
|
|
|
416
339
|
passphraseState: 'hidden-state-after-unlock',
|
|
417
340
|
resumed: false,
|
|
418
341
|
});
|
|
419
|
-
expect(device.unlockDevice).
|
|
342
|
+
expect(device.unlockDevice).not.toHaveBeenCalled();
|
|
420
343
|
expect(promptPassphrase).toHaveBeenCalledTimes(1);
|
|
421
344
|
});
|
|
422
345
|
|
|
423
|
-
test('unlocks before wallet selection when the Protocol V2 wallet status is unknown', async () => {
|
|
424
|
-
const typedCall = jest
|
|
425
|
-
.fn()
|
|
426
|
-
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
427
|
-
.mockResolvedValueOnce({ message: {} })
|
|
428
|
-
.mockResolvedValueOnce({
|
|
429
|
-
message: {
|
|
430
|
-
btc_test_address: 'hidden-state-after-unknown-status',
|
|
431
|
-
session_id: 'hidden-session-after-unknown-status',
|
|
432
|
-
},
|
|
433
|
-
});
|
|
434
|
-
const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
|
|
435
|
-
const method = new OpenWalletSession({
|
|
436
|
-
payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
|
|
437
|
-
});
|
|
438
|
-
method.init();
|
|
439
|
-
const device = createDevice({ typedCall, promptPassphrase });
|
|
440
|
-
device.getDeviceState = jest
|
|
441
|
-
.fn()
|
|
442
|
-
.mockResolvedValueOnce({
|
|
443
|
-
identity: { deviceId: 'device-1' },
|
|
444
|
-
status: {
|
|
445
|
-
unlocked: undefined,
|
|
446
|
-
passphraseProtection: null,
|
|
447
|
-
unlockedAttachPin: null,
|
|
448
|
-
},
|
|
449
|
-
})
|
|
450
|
-
.mockResolvedValue({
|
|
451
|
-
identity: { deviceId: 'device-1' },
|
|
452
|
-
status: {
|
|
453
|
-
unlocked: true,
|
|
454
|
-
passphraseProtection: true,
|
|
455
|
-
unlockedAttachPin: false,
|
|
456
|
-
},
|
|
457
|
-
});
|
|
458
|
-
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
459
|
-
device.features.unlocked = true;
|
|
460
|
-
device.features.passphraseProtection = true;
|
|
461
|
-
device.features.unlockedAttachPin = false;
|
|
462
|
-
return Promise.resolve(device.features);
|
|
463
|
-
});
|
|
464
|
-
method.device = device as any;
|
|
465
|
-
|
|
466
|
-
await expect(method.run()).resolves.toMatchObject({
|
|
467
|
-
walletType: 'hidden',
|
|
468
|
-
passphraseState: 'hidden-state-after-unknown-status',
|
|
469
|
-
});
|
|
470
|
-
expect(device.unlockDevice).toHaveBeenCalledTimes(1);
|
|
471
|
-
expect(device.unlockDevice.mock.invocationCallOrder[0]).toBeLessThan(
|
|
472
|
-
promptPassphrase.mock.invocationCallOrder[0]
|
|
473
|
-
);
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
test('rejects wallet selection when the post-unlock Protocol V2 status remains incomplete', async () => {
|
|
477
|
-
const typedCall = jest
|
|
478
|
-
.fn()
|
|
479
|
-
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
480
|
-
.mockResolvedValueOnce({ message: {} })
|
|
481
|
-
.mockResolvedValueOnce({
|
|
482
|
-
message: {
|
|
483
|
-
btc_test_address: 'hidden-state-from-incomplete-status',
|
|
484
|
-
session_id: 'hidden-session-from-incomplete-status',
|
|
485
|
-
},
|
|
486
|
-
});
|
|
487
|
-
const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
|
|
488
|
-
const method = new OpenWalletSession({
|
|
489
|
-
payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
|
|
490
|
-
});
|
|
491
|
-
method.init();
|
|
492
|
-
const device = createDevice({ typedCall, promptPassphrase });
|
|
493
|
-
device.getDeviceState = jest.fn().mockResolvedValue({
|
|
494
|
-
identity: { deviceId: 'device-1' },
|
|
495
|
-
status: {
|
|
496
|
-
unlocked: true,
|
|
497
|
-
passphraseProtection: null,
|
|
498
|
-
unlockedAttachPin: null,
|
|
499
|
-
},
|
|
500
|
-
});
|
|
501
|
-
device.unlockDevice = jest.fn().mockResolvedValue(device.features);
|
|
502
|
-
method.device = device as any;
|
|
503
|
-
|
|
504
|
-
await expect(method.run()).rejects.toMatchObject({
|
|
505
|
-
errorCode: HardwareErrorCode.DeviceInitializeFailed,
|
|
506
|
-
});
|
|
507
|
-
expect(device.unlockDevice).toHaveBeenCalledTimes(1);
|
|
508
|
-
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
509
|
-
});
|
|
510
|
-
|
|
511
346
|
test('rejects a Pro2 standard-wallet fallback after selecting a hidden wallet', async () => {
|
|
512
347
|
const typedCall = jest
|
|
513
348
|
.fn()
|
|
@@ -821,11 +656,7 @@ describe('openWalletSession', () => {
|
|
|
821
656
|
expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
822
657
|
eventless_wallet_session: true,
|
|
823
658
|
});
|
|
824
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main
|
|
825
|
-
source: 'wallet-session-coordinator',
|
|
826
|
-
reason: 'open-wallet',
|
|
827
|
-
deviceOnly: true,
|
|
828
|
-
});
|
|
659
|
+
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
|
|
829
660
|
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
|
|
830
661
|
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
831
662
|
expect(device.passphraseState).toBeUndefined();
|
|
@@ -855,11 +686,7 @@ describe('openWalletSession', () => {
|
|
|
855
686
|
})
|
|
856
687
|
.mockResolvedValueOnce({
|
|
857
688
|
identity: { deviceId: 'device-1' },
|
|
858
|
-
status: {
|
|
859
|
-
unlocked: true,
|
|
860
|
-
passphraseProtection: true,
|
|
861
|
-
unlockedAttachPin: false,
|
|
862
|
-
},
|
|
689
|
+
status: { passphraseProtection: true },
|
|
863
690
|
});
|
|
864
691
|
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
865
692
|
device.features.unlocked = true;
|
|
@@ -874,11 +701,7 @@ describe('openWalletSession', () => {
|
|
|
874
701
|
passphraseState: null,
|
|
875
702
|
resumed: false,
|
|
876
703
|
});
|
|
877
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main
|
|
878
|
-
source: 'wallet-session-coordinator',
|
|
879
|
-
reason: 'open-wallet',
|
|
880
|
-
deviceOnly: true,
|
|
881
|
-
});
|
|
704
|
+
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
|
|
882
705
|
expect(device.getDeviceState).toHaveBeenCalledTimes(2);
|
|
883
706
|
});
|
|
884
707
|
|
|
@@ -898,24 +721,6 @@ describe('openWalletSession', () => {
|
|
|
898
721
|
method.init();
|
|
899
722
|
const device = createDevice({ typedCall });
|
|
900
723
|
device.features.unlockedAttachPin = true;
|
|
901
|
-
device.getDeviceState = jest
|
|
902
|
-
.fn()
|
|
903
|
-
.mockResolvedValueOnce({
|
|
904
|
-
identity: { deviceId: 'device-1' },
|
|
905
|
-
status: {
|
|
906
|
-
unlocked: true,
|
|
907
|
-
unlockedAttachPin: true,
|
|
908
|
-
passphraseProtection: true,
|
|
909
|
-
},
|
|
910
|
-
})
|
|
911
|
-
.mockResolvedValue({
|
|
912
|
-
identity: { deviceId: 'device-1' },
|
|
913
|
-
status: {
|
|
914
|
-
unlocked: true,
|
|
915
|
-
unlockedAttachPin: false,
|
|
916
|
-
passphraseProtection: true,
|
|
917
|
-
},
|
|
918
|
-
});
|
|
919
724
|
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
920
725
|
device.features.unlockedAttachPin = false;
|
|
921
726
|
return Promise.resolve(device.features);
|
|
@@ -926,11 +731,7 @@ describe('openWalletSession', () => {
|
|
|
926
731
|
walletType: 'standard',
|
|
927
732
|
passphraseState: null,
|
|
928
733
|
});
|
|
929
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main
|
|
930
|
-
source: 'wallet-session-coordinator',
|
|
931
|
-
reason: 'open-wallet',
|
|
932
|
-
deviceOnly: true,
|
|
933
|
-
});
|
|
734
|
+
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
|
|
934
735
|
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
|
|
935
736
|
});
|
|
936
737
|
|
|
@@ -1138,9 +939,7 @@ describe('openWalletSession', () => {
|
|
|
1138
939
|
},
|
|
1139
940
|
{ cancelDeviceOnReject: false }
|
|
1140
941
|
);
|
|
1141
|
-
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.AttachToPin
|
|
1142
|
-
emitUiEvent: false,
|
|
1143
|
-
});
|
|
942
|
+
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.AttachToPin);
|
|
1144
943
|
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
|
|
1145
944
|
});
|
|
1146
945
|
|
|
@@ -1416,11 +1215,7 @@ describe('openWalletSession', () => {
|
|
|
1416
1215
|
})
|
|
1417
1216
|
.mockResolvedValueOnce({
|
|
1418
1217
|
identity: { deviceId: 'device-1' },
|
|
1419
|
-
status: {
|
|
1420
|
-
unlocked: true,
|
|
1421
|
-
passphraseProtection: true,
|
|
1422
|
-
unlockedAttachPin: false,
|
|
1423
|
-
},
|
|
1218
|
+
status: { passphraseProtection: true },
|
|
1424
1219
|
});
|
|
1425
1220
|
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
1426
1221
|
device.features.unlocked = true;
|
|
@@ -1476,11 +1271,7 @@ describe('openWalletSession', () => {
|
|
|
1476
1271
|
})
|
|
1477
1272
|
.mockResolvedValueOnce({
|
|
1478
1273
|
identity: { deviceId: 'other-device' },
|
|
1479
|
-
status: {
|
|
1480
|
-
unlocked: true,
|
|
1481
|
-
passphraseProtection: true,
|
|
1482
|
-
unlockedAttachPin: false,
|
|
1483
|
-
},
|
|
1274
|
+
status: { passphraseProtection: true },
|
|
1484
1275
|
});
|
|
1485
1276
|
device.unlockDevice = jest.fn().mockImplementation(() => {
|
|
1486
1277
|
device.features.unlocked = true;
|
|
@@ -1544,6 +1335,7 @@ describe('openWalletSession', () => {
|
|
|
1544
1335
|
const typedCall = jest
|
|
1545
1336
|
.fn()
|
|
1546
1337
|
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
1338
|
+
.mockResolvedValueOnce({ message: {} })
|
|
1547
1339
|
.mockResolvedValueOnce({
|
|
1548
1340
|
message: {
|
|
1549
1341
|
btc_test_address: 'hidden-state',
|
|
@@ -1570,40 +1362,7 @@ describe('openWalletSession', () => {
|
|
|
1570
1362
|
passphraseState: 'hidden-state',
|
|
1571
1363
|
resumed: false,
|
|
1572
1364
|
});
|
|
1573
|
-
expect(
|
|
1574
|
-
expect(promptPassphrase).not.toHaveBeenCalled();
|
|
1365
|
+
expect(promptPassphrase).toHaveBeenCalledTimes(1);
|
|
1575
1366
|
expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('new-session');
|
|
1576
1367
|
});
|
|
1577
|
-
|
|
1578
|
-
test.each([false, true])('keeps deriveCardano API compatibility: %s', async deriveCardano => {
|
|
1579
|
-
const typedCall = jest
|
|
1580
|
-
.fn()
|
|
1581
|
-
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
1582
|
-
.mockResolvedValueOnce({ message: {} })
|
|
1583
|
-
.mockResolvedValueOnce({
|
|
1584
|
-
message: {
|
|
1585
|
-
btc_test_address: 'hidden-state',
|
|
1586
|
-
session_id: 'new-session',
|
|
1587
|
-
},
|
|
1588
|
-
});
|
|
1589
|
-
const method = new OpenWalletSession({
|
|
1590
|
-
payload: {
|
|
1591
|
-
method: 'openWalletSession',
|
|
1592
|
-
connectId: 'connect-id',
|
|
1593
|
-
mode: 'select-hidden',
|
|
1594
|
-
deriveCardano,
|
|
1595
|
-
},
|
|
1596
|
-
});
|
|
1597
|
-
method.init();
|
|
1598
|
-
method.device = createDevice({
|
|
1599
|
-
typedCall,
|
|
1600
|
-
promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
|
|
1601
|
-
}) as any;
|
|
1602
|
-
|
|
1603
|
-
await expect(method.run()).resolves.toMatchObject({
|
|
1604
|
-
walletType: 'hidden',
|
|
1605
|
-
passphraseState: 'hidden-state',
|
|
1606
|
-
});
|
|
1607
|
-
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
|
|
1608
|
-
});
|
|
1609
1368
|
});
|