-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransfer.e2e.ts
More file actions
391 lines (341 loc) · 13.2 KB
/
transfer.e2e.ts
File metadata and controls
391 lines (341 loc) · 13.2 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
import BitcoinJsonRpc from 'bitcoin-json-rpc';
import initElectrum from '../helpers/electrum';
import {
completeOnboarding,
sleep,
receiveOnchainFunds,
tap,
expectText,
elementByText,
elementsById,
elementById,
multiTap,
dragOnElement,
expectTextWithin,
swipeFullScreen,
mineBlocks,
elementByIdWithin,
enterAddress,
dismissQuickPayIntro,
doNavigationClose,
waitForToast,
getTextUnder,
acknowledgeExternalSuccess,
dismissBackgroundPaymentsTimedSheet,
expectNoTextWithin,
} from '../helpers/actions';
import {
checkChannelStatus,
connectToLND,
getLDKNodeID,
setupLND,
waitForActiveChannel,
waitForPeerConnection,
} from '../helpers/lnd';
import { bitcoinURL, lndConfig } from '../helpers/constants';
import { launchFreshApp, reinstallApp } from '../helpers/setup';
import { ciIt } from '../helpers/suite';
describe('@transfer - Transfer', () => {
let electrum: { waitForSync: () => any; stop: () => void };
const rpc = new BitcoinJsonRpc(bitcoinURL);
before(async () => {
let balance = await rpc.getBalance();
const address = await rpc.getNewAddress();
while (balance < 10) {
await rpc.generateToAddress(10, address);
balance = await rpc.getBalance();
}
electrum = await initElectrum();
});
beforeEach(async () => {
await reinstallApp();
await completeOnboarding();
await electrum?.waitForSync();
});
after(() => {
electrum?.stop();
});
// Test Plan
// Can buy a channel from Blocktank with default and custom receive capacity
// - cannot continue with zero spending balance
// - can change amount
// Advanced
// - can change amount
// Can open a channel to external node
// - open channel to LND
// - send payment
// - close the channel
ciIt(
'@transfer_1 - Can buy a channel from Blocktank with default and custom receive capacity',
async () => {
await receiveOnchainFunds(rpc, { sats: 1000_000, expectHighBalanceWarning: true });
// switch to EUR
await tap('HeaderMenu');
await tap('DrawerSettings');
await tap('GeneralSettings');
await tap('CurrenciesSettings');
await elementByText('EUR (€)').click();
await doNavigationClose();
if (driver.isAndroid) await launchFreshApp();
await tap('Suggestion-lightning');
await tap('TransferIntro-button');
await tap('FundTransfer');
await tap('SpendingIntro-button');
await sleep(3000); // let the animation finish
// can continue with default client balance (0)
await tap('SpendingAmountContinue');
await sleep(100);
await tap('SpendingConfirmAdvanced');
await tap('SpendingAdvancedMin');
await expectText('100 000', { strategy: 'contains' });
await tap('SpendingAdvancedDefault');
await tap('SpendingAdvancedNumberField'); // change to fiat
const label = await getTextUnder('SpendingAdvancedNumberField');
const eurBalance = Number.parseInt(label, 10);
await expect(eurBalance).toBeGreaterThan(440);
await expect(eurBalance).toBeLessThan(460);
await tap('SpendingAdvancedNumberField'); // change back to sats
await tap('SpendingAdvancedContinue');
await tap('NavigationBack');
// can continue with max client balance
await tap('SpendingAmountMax');
await elementById('SpendingAmountContinue').waitForEnabled();
await sleep(500);
await tap('SpendingAmountContinue');
await elementById('SpendingConfirmAdvanced').waitForDisplayed();
await tap('NavigationBack');
// can continue with 25% client balance
await elementById('SpendingAmountQuarter').waitForEnabled();
await tap('SpendingAmountQuarter');
await elementById('SpendingAmountContinue').waitForEnabled();
await sleep(500);
await tap('SpendingAmountContinue');
await elementById('SpendingConfirmAdvanced').waitForDisplayed();
await tap('NavigationBack');
await tap('NavigationBack');
await tap('SpendingIntro-button');
// can change client balance
await tap('N2');
await multiTap('N0', 5);
await tap('SpendingAmountContinue');
await expectText('200 000', { strategy: 'contains' });
await tap('SpendingConfirmMore');
await expectText('200 000');
await tap('LiquidityContinue');
// Swipe to confirm (set x offset to avoid navigating back)
await dragOnElement('GRAB', 'right', 0.95);
await elementById('LightningSettingUp').waitForDisplayed();
await tap('TransferSuccess-button');
// verify transfer activity on savings
await tap('ActivitySavings');
await elementById('Activity-1').waitForDisplayed();
await elementById('Activity-2').waitForDisplayed();
await expectTextWithin('Activity-1', 'Transfer', { timeout: 60_000 });
await expectTextWithin('Activity-1', '-');
await tap('NavigationBack');
// transfer in progress
//await elementById('Suggestion-lightning_setting_up').waitForDisplayed();
// Get another channel with custom receiving capacity
await tap('ActivitySavings');
await tap('TransferToSpending');
await tap('N1');
await multiTap('N0', 5);
await tap('SpendingAmountContinue');
await expectText('100 000', { strategy: 'contains' });
await sleep(500);
await tap('SpendingConfirmAdvanced');
await sleep(500);
// Receiving Capacity
// can continue with min amount
await tap('SpendingAdvancedMin');
await sleep(500);
await expectText('2 500');
await expectText('—', { visible: false });
await tap('SpendingAdvancedContinue');
await sleep(500);
await tap('SpendingConfirmDefault');
await sleep(500);
await tap('SpendingConfirmAdvanced');
await sleep(500);
// can continue with default amount
await tap('SpendingAdvancedDefault');
await sleep(500);
await expectText('—', { visible: false });
await tap('SpendingAdvancedContinue');
await sleep(500);
await tap('SpendingConfirmDefault');
await sleep(500);
await tap('SpendingConfirmAdvanced');
await sleep(500);
// can continue with max amount
await tap('SpendingAdvancedMax');
await sleep(500);
await expectText('—', { visible: false });
await tap('SpendingAdvancedContinue');
await sleep(500);
await tap('SpendingConfirmDefault');
await sleep(500);
await tap('SpendingConfirmAdvanced');
await sleep(500);
// can set custom amount
await tap('N1');
await tap('N5');
await multiTap('N0', 4);
await tap('SpendingAdvancedContinue');
await expectTextWithin('SpendingConfirmChannel', '100 000');
await expectTextWithin('SpendingConfirmChannel', '150 000');
// Swipe to confirm (set x offset to avoid navigating back)
await dragOnElement('GRAB', 'right', 0.95);
await elementById('LightningSettingUp').waitForDisplayed();
await tap('TransferSuccess-button');
// verify both transfers activities on savings
await tap('ActivitySavings');
await elementById('Activity-1').waitForDisplayed();
await elementById('Activity-2').waitForDisplayed();
await elementById('Activity-3').waitForDisplayed();
await expectTextWithin('Activity-1', 'Transfer');
await expectTextWithin('Activity-1', '-');
await elementById('Activity-2').waitForDisplayed();
await expectTextWithin('Activity-2', 'Transfer', { timeout: 60_000 });
await expectTextWithin('Activity-2', '-');
await tap('NavigationBack');
// transfer in progress
//await elementById('Suggestion-lightning_setting_up').waitForDisplayed();
// check channel status
await tap('HeaderMenu');
await tap('DrawerSettings');
await tap('AdvancedSettings');
await tap('Channels');
const channels = await elementsById('Channel');
channels[driver.isAndroid ? 1 : 0].click();
await expectTextWithin('TotalSize', '₿ 250 000');
await expectText('Processing payment');
await doNavigationClose();
// check activities
await sleep(1000);
await swipeFullScreen('up');
await elementById('ActivityShort-0').waitForDisplayed();
await expectTextWithin('ActivityShort-0', 'Transfer');
await elementById('ActivityShort-1').waitForDisplayed();
await expectTextWithin('ActivityShort-1', 'Transfer');
// TODO: enable when boost backup is operational
// https://github.com/synonymdev/bitkit-android/issues/321
//const seed = await getSeed();
//await waitForBackup();
//await restoreWallet(seed);
// check transfer card
//await elementById('Suggestion-lightning_setting_up').waitForDisplayed();
// check activity after restore
//await swipeFullScreen('up');
//await tap('ActivityShort-1');
//await elementById('StatusTransfer').waitForDisplayed();
// boost the transfer
//await tap('BoostButton');
//await elementById('CPFPBoost').waitForDisplayed();
//await dragOnElement('GRAB', 'right', 0.95); // Swipe to confirm
// check Activity
//await elementById('BoostingIcon').waitForDisplayed();
// reset & restore again
// await waitForBackup();
// await restoreWallet(seed);
// // check activity after restore
// await swipeFullScreen('up');
// await elementById('BoostingIcon').waitForDisplayed();
// await tap('ActivityShort-1');
// await elementById('StatusBoosting').waitForDisplayed();
}
);
ciIt('@transfer_2 - Can open a channel to external node', async () => {
await receiveOnchainFunds(rpc, { sats: 100_000 });
// send funds to LND node and open a channel
const { lnd, lndNodeID } = await setupLND(rpc, lndConfig);
await electrum?.waitForSync();
// get LDK Node id
const ldkNodeId = await getLDKNodeID();
// connect to LND
await connectToLND(lndNodeID, { navigationClose: false });
// wait for peer to be connected
await waitForPeerConnection(lnd, ldkNodeId);
// Set amount
await tap('N2');
await multiTap('N0', 4);
await tap('ExternalAmountContinue');
await sleep(500);
// change fee
// this should be removed from Andorid:
// https://github.com/synonymdev/bitkit-android/issues/548
if (driver.isAndroid) {
await tap('SetCustomFee');
await sleep(500);
await tap('NRemove');
await sleep(1000); // wait for input to register
await tap('FeeCustomContinue');
await tap('N5');
await sleep(1000); // wait for input to register
await tap('FeeCustomContinue');
}
// Swipe to confirm
await dragOnElement('GRAB', 'right', 0.95);
console.info('channel opening...');
await sleep(1000);
await acknowledgeExternalSuccess();
if (driver.isAndroid) {
await tap('NavigationBack');
await doNavigationClose();
}
// check transfer card
// await elementById('Suggestion-lightning_setting_up').waitForDisplayed();
const totalBalance = await elementByIdWithin('TotalBalance-primary', 'MoneyText');
const totalAmtAfterChannelOpen = await totalBalance.getText();
await expect(totalBalance).not.toHaveText('100 000');
// check activity
await swipeFullScreen('up');
await elementById('ActivityShort-0').waitForDisplayed();
await expectTextWithin('ActivityShort-0', 'Transfer');
await elementById('ActivityShort-1').waitForDisplayed();
await expectTextWithin('ActivityShort-1', 'Received');
await swipeFullScreen('down');
await mineBlocks(rpc, 6);
await electrum?.waitForSync();
await waitForToast('SpendingBalanceReadyToast');
await sleep(1000);
if (driver.isIOS) {
await dismissBackgroundPaymentsTimedSheet({ triggerTimedSheet: driver.isIOS });
await dismissQuickPayIntro({ triggerTimedSheet: driver.isIOS });
} else {
await dismissQuickPayIntro({ triggerTimedSheet: true });
}
await expectNoTextWithin('ActivitySpending', '0');
await waitForActiveChannel(lnd, ldkNodeId);
// check transfer card
// await elementById('Suggestion-lightning_setting_up').waitForDisplayed({reverse: true});
// check channel status
await checkChannelStatus({ size: '20 000' });
// get invoice
const { paymentRequest } = await lnd.addInvoice({ memo: 'zero' });
// send payment
await enterAddress(paymentRequest);
await multiTap('N1', 3);
await tap('ContinueAmount');
await dragOnElement('GRAB', 'right', 0.95); // Swipe to confirm
await elementById('SendSuccess').waitForDisplayed();
await tap('Close');
await expect(totalBalance).not.toHaveText(totalAmtAfterChannelOpen);
// close the channel
await tap('ActivitySpending');
await tap('TransferToSavings');
await tap('SavingsIntro-button');
await tap('AvailabilityContinue');
await sleep(1000);
await dragOnElement('GRAB', 'right', 0.95);
await elementById('TransferSuccess').waitForDisplayed();
await tap('TransferSuccess-button');
if (driver.isAndroid) await tap('NavigationBack');
// check channel is closed
await tap('HeaderMenu');
await tap('DrawerSettings');
await tap('AdvancedSettings');
await tap('Channels');
await expectText('Connection 1', { visible: false });
});
});