forked from input-output-hk/daedalus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect-multiple-hardware-wallets.ts
56 lines (47 loc) · 1.27 KB
/
connect-multiple-hardware-wallets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import expect from 'expect';
import {
createAndRegisterHardwareWalletChannels,
createHardwareWalletConnectionChannel,
createSequentialResult,
initLedgerChannel,
createTestInstructions,
waitForZombieMessages,
} from './utils';
export const run = () => {
expect.assertions(2);
createAndRegisterHardwareWalletChannels();
const hardwareWalletConnectionChannel = createHardwareWalletConnectionChannel();
createTestInstructions([
'Start test runner',
'Plug Ledger Nano S to your computer',
'Plug Ledger Nano S Plus to your computer',
'Plug Ledger Nano X to your computer',
]);
const getNextExpectedSequence = createSequentialResult([
{
disconnected: false,
deviceModel: 'nanoS',
},
{
disconnected: false,
deviceModel: 'nanoSP',
},
{
disconnected: false,
deviceModel: 'nanoX',
},
]);
return new Promise<void>((resolve) => {
hardwareWalletConnectionChannel.onReceive(
async (message: { path: string; deviceModel: string }) => {
const [expectedValue, isOver] = getNextExpectedSequence();
expect(message).toEqual(expectedValue);
if (isOver) {
await waitForZombieMessages();
resolve();
}
}
);
initLedgerChannel();
});
};