-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainnet.ts
More file actions
54 lines (46 loc) · 1.63 KB
/
Copy pathmainnet.ts
File metadata and controls
54 lines (46 loc) · 1.63 KB
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
import {
doNavigationClose,
elementById,
expectTextWithin,
sleep,
tap,
} from './actions';
const WALLET_SYNC_TIMEOUT_MS = 90_000;
const APP_STATUS_ROW_TIMEOUT_MS = 90_000;
type WaitForMainnetWalletReadyOptions = {
logPrefix: string;
};
export async function waitForMainnetWalletReady({
logPrefix,
}: WaitForMainnetWalletReadyOptions): Promise<void> {
console.info(`→ [${logPrefix}] Waiting for wallet home screen...`);
await elementById('TotalBalance-primary').waitForDisplayed({ timeout: WALLET_SYNC_TIMEOUT_MS });
const stabilizeMs = resolveLnStabilizeDelayMs();
console.info(
`→ [${logPrefix}] Home screen ready, letting LN node stabilize (${stabilizeMs / 1000}s)...`
);
await sleep(stabilizeMs);
console.info(`→ [${logPrefix}] Verify app status is ready`);
await tap('HeaderMenu');
await tap('DrawerAppStatus');
await expectTextWithin('Status-internet', 'Connected', { timeout: APP_STATUS_ROW_TIMEOUT_MS });
await expectTextWithin('Status-electrum', 'Connected', { timeout: APP_STATUS_ROW_TIMEOUT_MS });
await expectTextWithin('Status-lightning_node', 'Running', {
timeout: APP_STATUS_ROW_TIMEOUT_MS,
});
await expectTextWithin('Status-lightning_connection', 'Open', {
timeout: APP_STATUS_ROW_TIMEOUT_MS,
});
await doNavigationClose();
console.info(`→ [${logPrefix}] App status verified`);
}
function resolveLnStabilizeDelayMs(): number {
const fromEnv = process.env.LN_STABILIZE_DELAY_MS;
if (fromEnv) {
const parsed = Number.parseInt(fromEnv, 10);
if (Number.isFinite(parsed) && parsed >= 0) {
return parsed;
}
}
return process.env.CI ? 45_000 : 10_000;
}