Skip to content

Commit a32374c

Browse files
committed
test(backup): add e2e tests
1 parent 0f96482 commit a32374c

File tree

8 files changed

+121
-184
lines changed

8 files changed

+121
-184
lines changed

e2e/backup.e2e.js

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
bitcoinURL,
1010
electrumHost,
1111
electrumPort,
12+
getSeed,
13+
restoreWallet,
1214
} from './helpers';
1315
import initWaitForElectrumToSync from '../__tests__/utils/wait-for-electrum';
1416

@@ -103,54 +105,9 @@ d('Backup', () => {
103105
await element(by.id('WidgetsEdit')).tap();
104106
await expect(element(by.id('PriceWidget'))).toBeVisible();
105107

106-
// get seed
107-
await element(by.id('Settings')).tap();
108-
await element(by.id('BackupSettings')).tap();
109-
await element(by.id('BackupWallet')).tap();
110-
await sleep(200); // animation
111-
await element(by.id('TapToReveal')).tap();
112-
113-
// get the seed from SeedContaider
114-
const { label: seed } = await element(
115-
by.id('SeedContaider'),
116-
).getAttributes();
117-
118-
await element(by.id('SeedContaider')).swipe('down');
119-
await sleep(200); // animation
120-
await element(by.id('NavigationClose')).atIndex(0).tap();
121-
122-
await sleep(5000); // make sure everything is saved to cloud storage TODO: improve this
123-
124-
console.info('seed: ', seed);
125-
126108
// restore wallet
127-
await device.launchApp({ delete: true });
128-
129-
await waitFor(element(by.id('Check1'))).toBeVisible();
130-
await element(by.id('Check1')).tap();
131-
await element(by.id('Check2')).tap();
132-
await element(by.id('Continue')).tap();
133-
await waitFor(element(by.id('SkipIntro'))).toBeVisible();
134-
await element(by.id('SkipIntro')).tap();
135-
await element(by.id('RestoreWallet')).tap();
136-
await element(by.id('MultipleDevices-button')).tap();
137-
await element(by.id('Word-0')).replaceText(seed);
138-
await element(by.id('WordIndex-4')).swipe('up');
139-
await element(by.id('RestoreButton')).tap();
140-
141-
await waitFor(element(by.id('GetStartedButton')))
142-
.toBeVisible()
143-
.withTimeout(300000); // 5 min
144-
await element(by.id('GetStartedButton')).tap();
145-
146-
// wait for SuggestionsLabel to appear and be accessible
147-
for (let i = 0; i < 60; i++) {
148-
await sleep(200);
149-
try {
150-
await element(by.id('SuggestionsLabel')).tap();
151-
break;
152-
} catch (e) {}
153-
}
109+
const seed = await getSeed();
110+
await restoreWallet(seed);
154111

155112
// check settings
156113
await expect(

e2e/boost.e2e.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
bitcoinURL,
1212
electrumHost,
1313
electrumPort,
14+
getSeed,
15+
restoreWallet,
1416
} from './helpers';
1517
import initWaitForElectrumToSync from '../__tests__/utils/wait-for-electrum';
1618

@@ -267,10 +269,23 @@ d('Boost', () => {
267269
assert(Number(oldFee.replace(' ', '')) < Number(newFee.replace(' ', '')));
268270
assert(oldTxid !== newTxid);
269271
await expect(element(by.id('RBFBoosted'))).toBeVisible();
272+
await element(by.id('NavigationClose')).atIndex(0).tap();
273+
274+
// wipe & restore
275+
const seed = await getSeed();
276+
await restoreWallet(seed);
277+
278+
// check activity after restore
279+
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
280+
await expect(element(by.id('BoostingIcon'))).toBeVisible();
281+
await element(by.id('ActivityShort-1')).tap();
282+
await expect(element(by.id('BoostedButton'))).toBeVisible();
283+
await expect(element(by.id('StatusBoosting'))).toBeVisible();
270284

271285
// mine new block
272-
await element(by.id('NavigationBack')).atIndex(0).tap();
273286
await rpc.generateToAddress(1, await rpc.getNewAddress());
287+
288+
// check activity item after mine
274289
await waitFor(element(by.id('StatusConfirmed')))
275290
.toBeVisible()
276291
.withTimeout(30000);

e2e/channels.e2e.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
sleep,
1717
waitForActiveChannel,
1818
waitForPeerConnection,
19+
getSeed,
20+
restoreWallet,
1921
} from './helpers';
2022

2123
d = checkComplete(['transfer-1', 'transfer-2']) ? describe.skip : describe;
@@ -186,6 +188,18 @@ d('Transfer', () => {
186188
await expect(
187189
element(by.id('MoneyText').withAncestor(by.id('TotalSize'))),
188190
).toHaveText('250 000');
191+
await element(by.id('NavigationClose')).tap();
192+
193+
const seed = await getSeed();
194+
await restoreWallet(seed);
195+
196+
// check transfer card
197+
await expect(element(by.id('Suggestion-lightningSettingUp'))).toBeVisible();
198+
199+
// check activity after restore
200+
await element(by.id('WalletsScrollView')).scrollTo('bottom', NaN, 0.85);
201+
await element(by.id('ActivityShort-1')).tap();
202+
await expect(element(by.id('StatusTransfer'))).toBeVisible();
189203

190204
markComplete('transfer-1');
191205
});

e2e/helpers.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,65 @@ export const waitForActiveChannel = async (lnd, nodeId, maxRetries = 20) => {
187187
throw new Error('Channel not active');
188188
}
189189
};
190+
191+
export const getSeed = async () => {
192+
await element(by.id('Settings')).tap();
193+
await element(by.id('BackupSettings')).tap();
194+
await element(by.id('BackupWallet')).tap();
195+
// animation
196+
await sleep(200);
197+
await element(by.id('TapToReveal')).tap();
198+
199+
// get the seed from SeedContaider
200+
const { label: seed } = await element(by.id('SeedContaider')).getAttributes();
201+
202+
await element(by.id('SeedContaider')).swipe('down');
203+
// animation
204+
await sleep(200);
205+
await element(by.id('NavigationClose')).atIndex(0).tap();
206+
207+
console.info({ seed });
208+
209+
return seed;
210+
};
211+
212+
export const restoreWallet = async (seed, passphrase) => {
213+
// make sure everything is saved to cloud storage
214+
// TODO: improve this
215+
await sleep(5000);
216+
217+
await device.launchApp({ delete: true });
218+
219+
await waitFor(element(by.id('Check1'))).toBeVisible();
220+
await element(by.id('Check1')).tap();
221+
await element(by.id('Check2')).tap();
222+
await element(by.id('Continue')).tap();
223+
await waitFor(element(by.id('SkipIntro'))).toBeVisible();
224+
await element(by.id('SkipIntro')).tap();
225+
await element(by.id('RestoreWallet')).tap();
226+
await element(by.id('MultipleDevices-button')).tap();
227+
await element(by.id('Word-0')).replaceText(seed);
228+
await element(by.id('WordIndex-4')).swipe('up');
229+
230+
if (passphrase) {
231+
await element(by.id('AdvancedButton')).tap();
232+
await element(by.id('PassphraseInput')).typeText(passphrase);
233+
await element(by.id('PassphraseInput')).tapReturnKey();
234+
}
235+
236+
await element(by.id('RestoreButton')).tap();
237+
238+
await waitFor(element(by.id('GetStartedButton')))
239+
.toBeVisible()
240+
.withTimeout(300000); // 5 min
241+
await element(by.id('GetStartedButton')).tap();
242+
243+
// wait for SuggestionsLabel to appear and be accessible
244+
for (let i = 0; i < 60; i++) {
245+
await sleep(200);
246+
try {
247+
await element(by.id('SuggestionsLabel')).tap();
248+
break;
249+
} catch (e) {}
250+
}
251+
};

e2e/lightning.e2e.js

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
sleep,
1616
waitForActiveChannel,
1717
waitForPeerConnection,
18+
restoreWallet,
19+
getSeed,
1820
} from './helpers';
1921

2022
d = checkComplete('lighting-1') ? describe.skip : describe;
@@ -311,52 +313,9 @@ d('Lightning', () => {
311313
await element(by.id('Tag-stag-delete')).tap();
312314
await element(by.id('NavigationClose')).tap();
313315

314-
// get seed
315-
await element(by.id('Settings')).tap();
316-
await element(by.id('BackupSettings')).tap();
317-
await element(by.id('BackupWallet')).tap();
318-
await sleep(1000); // animation
319-
await element(by.id('TapToReveal')).tap();
320-
321-
// get the seed from SeedContaider
322-
const { label: seed } = await element(
323-
by.id('SeedContaider'),
324-
).getAttributes();
325-
await element(by.id('SeedContaider')).swipe('down');
326-
await sleep(1000); // animation
327-
await element(by.id('NavigationClose')).atIndex(0).tap();
328-
329-
await sleep(5000); // make sure everything is saved to cloud storage TODO: improve this
330-
console.info('seed: ', seed);
331-
332-
// restore wallet
333-
await device.launchApp({ delete: true });
334-
335-
await waitFor(element(by.id('Check1'))).toBeVisible();
336-
await element(by.id('Check1')).tap();
337-
await element(by.id('Check2')).tap();
338-
await element(by.id('Continue')).tap();
339-
await waitFor(element(by.id('SkipIntro'))).toBeVisible();
340-
await element(by.id('SkipIntro')).tap();
341-
await element(by.id('RestoreWallet')).tap();
342-
await element(by.id('MultipleDevices-button')).tap();
343-
await element(by.id('Word-0')).replaceText(seed);
344-
await element(by.id('WordIndex-4')).swipe('up');
345-
await element(by.id('RestoreButton')).tap();
346-
347-
await waitFor(element(by.id('GetStartedButton')))
348-
.toBeVisible()
349-
.withTimeout(300000); // 5 min
350-
await element(by.id('GetStartedButton')).tap();
351-
352-
// wait for SuggestionsLabel to appear and be accessible
353-
for (let i = 0; i < 60; i++) {
354-
await sleep(1000);
355-
try {
356-
await element(by.id('SuggestionsLabel')).tap();
357-
break;
358-
} catch (e) {}
359-
}
316+
// wipe and restore wallet
317+
const seed = await getSeed();
318+
await restoreWallet(seed);
360319

361320
// check balance
362321
await waitFor(

e2e/onboarding.e2e.js

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import jestExpect from 'expect';
22

3-
import { sleep, checkComplete, markComplete } from './helpers';
3+
import {
4+
sleep,
5+
checkComplete,
6+
markComplete,
7+
getSeed,
8+
restoreWallet,
9+
} from './helpers';
410

511
d = checkComplete('onboarding-1') ? describe.skip : describe;
612

@@ -31,8 +37,9 @@ d('Onboarding', () => {
3137
await element(by.id('SkipButton')).tap();
3238

3339
// create new wallet with passphrase
40+
const passphrase = 'supersecret';
3441
await element(by.id('Passphrase')).tap();
35-
await element(by.id('PassphraseInput')).typeText('supersecret');
42+
await element(by.id('PassphraseInput')).typeText(passphrase);
3643
await element(by.id('PassphraseInput')).tapReturnKey();
3744
await element(by.id('CreateNewWallet')).tap();
3845

@@ -54,20 +61,9 @@ d('Onboarding', () => {
5461
}
5562
}
5663

57-
// get seed
58-
await element(by.id('Settings')).tap();
59-
await element(by.id('BackupSettings')).tap();
60-
await element(by.id('BackupWallet')).tap();
61-
await element(by.id('TapToReveal')).tap();
62-
// get the seed from SeedContaider
63-
const { label: seed } = await element(
64-
by.id('SeedContaider'),
65-
).getAttributes();
66-
await element(by.id('SeedContaider')).swipe('down');
67-
await element(by.id('NavigationClose')).atIndex(0).tap();
68-
console.info('seed: ', seed);
69-
70-
// get receing address
64+
const seed = await getSeed();
65+
66+
// get receiving address
7167
await element(by.id('Receive')).tap();
7268
await waitFor(element(by.id('QRCode')))
7369
.toBeVisible()
@@ -76,38 +72,9 @@ d('Onboarding', () => {
7672
console.info('address', address1);
7773

7874
// wipe and restore wallet
79-
await device.launchApp({ delete: true });
80-
81-
await waitFor(element(by.id('Check1'))).toBeVisible();
82-
await element(by.id('Check1')).tap();
83-
await element(by.id('Check2')).tap();
84-
await element(by.id('Continue')).tap();
85-
await waitFor(element(by.id('SkipIntro'))).toBeVisible();
86-
await element(by.id('SkipIntro')).tap();
87-
await element(by.id('RestoreWallet')).tap();
88-
await element(by.id('MultipleDevices-button')).tap();
89-
await element(by.id('Word-0')).replaceText(seed);
90-
await element(by.id('WordIndex-4')).swipe('up');
91-
await element(by.id('AdvancedButton')).tap();
92-
await element(by.id('PassphraseInput')).typeText('supersecret');
93-
await element(by.id('PassphraseInput')).tapReturnKey();
94-
await element(by.id('RestoreButton')).tap();
95-
96-
await waitFor(element(by.id('GetStartedButton')))
97-
.toBeVisible()
98-
.withTimeout(300000); // 5 min
99-
await element(by.id('GetStartedButton')).tap();
100-
101-
// wait for SuggestionsLabel to appear and be accessible
102-
for (let i = 0; i < 60; i++) {
103-
await sleep(1000);
104-
try {
105-
await element(by.id('SuggestionsLabel')).tap();
106-
break;
107-
} catch (e) {}
108-
}
75+
await restoreWallet(seed, passphrase);
10976

110-
// get receing address
77+
// get receiving address
11178
await element(by.id('Receive')).tap();
11279
await waitFor(element(by.id('QRCode')))
11380
.toBeVisible()

0 commit comments

Comments
 (0)