Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions test/helpers/electrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const peer = {
ssl: 60002,
};

const TIMEOUT = 30 * 1000; // 30 seconds
const TIMEOUT = 120 * 1000; // 120 seconds

function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
Expand Down Expand Up @@ -76,8 +76,21 @@ const initElectrum = async (): Promise<ElectrumClient> => {
break;
}

// Actively check if Electrum has the block at nodeHeight
// This handles the case where Electrum is catching up but no new blocks are mined
const { error } = await electrum.getHeader({
height: nodeHeight,
network: 'bitcoinRegtest',
timeout: 5000,
});
if (!error) {
// Electrum has caught up to nodeHeight
electrumHeight = nodeHeight;
break;
}

if (Date.now() - startTime > TIMEOUT) {
throw new Error('Electrum sync timeout');
throw new Error('Electrum sync timeout exceeded 120 seconds');
}

await sleep(1000);
Expand Down
18 changes: 7 additions & 11 deletions test/specs/numberpad.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import BitcoinJsonRpc from 'bitcoin-json-rpc';
import {
completeOnboarding,
enterAddress,
Expand All @@ -15,26 +14,23 @@ import {
import initElectrum from '../helpers/electrum';
import { launchFreshApp, reinstallApp } from '../helpers/setup';
import { ciIt } from '../helpers/suite';
import { bitcoinURL } from '../helpers/constants';
import { ensureLocalFunds } from '../helpers/regtest';

describe('@numberpad - NumberPad', () => {
let electrum: Awaited<ReturnType<typeof initElectrum>> | undefined;
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();
}

before(async () => {
await ensureLocalFunds();
electrum = await initElectrum();
await reinstallApp();
await completeOnboarding();
await receiveOnchainFunds({ sats: 10_000 });
});

after(async () => {
await electrum?.stop();
});

beforeEach(async () => {
await launchFreshApp();
await electrum?.waitForSync();
Expand Down
10 changes: 6 additions & 4 deletions test/specs/security.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('@security - Security And Privacy', () => {
await tap('DrawerSettings');
await tap('SecuritySettings');
await tap('PINCode');
await sleep(1000);
await tap('SecureWalletContinue');
await multiTap('N1', PIN_LENGTH); // enter PIN
await multiTap('N2', PIN_LENGTH); // retype wrong PIN
Expand All @@ -63,7 +64,7 @@ describe('@security - Security And Privacy', () => {
await doNavigationClose();

// - login with PIN
await launchFreshApp({ tryHandleAlert: false });
await launchFreshApp();
await elementById('PinPad').waitForDisplayed();
await sleep(1000);
await multiTap('N1', PIN_LENGTH);
Expand Down Expand Up @@ -104,7 +105,7 @@ describe('@security - Security And Privacy', () => {
await multiTap('N2', PIN_LENGTH); // correct new pin in the confirmation
await tap('OK');

await launchFreshApp({ tryHandleAlert: false });
await launchFreshApp();
await elementById('PinPad').waitForDisplayed();
await sleep(1000);
await multiTap('N2', PIN_LENGTH);
Expand All @@ -118,14 +119,15 @@ describe('@security - Security And Privacy', () => {
await tap('DisablePin');
await multiTap('N2', PIN_LENGTH);
await sleep(1000);
await launchFreshApp({ tryHandleAlert: false });
await launchFreshApp();
await elementById('TotalBalance').waitForDisplayed();

// enable PIN for last test
await tap('HeaderMenu');
await tap('DrawerSettings');
await tap('SecuritySettings');
await tap('PINCode');
await sleep(1000);
await tap('SecureWalletContinue');
await multiTap('N1', PIN_LENGTH); // enter PIN
await multiTap('N1', PIN_LENGTH); // retype PIN
Expand All @@ -135,7 +137,7 @@ describe('@security - Security And Privacy', () => {
await sleep(1000);

// now lets restart the app and fail to enter correct PIN 8 times
await launchFreshApp({ tryHandleAlert: false });
await launchFreshApp();
await elementById('PinPad').waitForDisplayed();
for (let i = 1; i <= MAX_ATTEMPTS_BEFORE_LAST; i++) {
await multiTap('N9', PIN_LENGTH); // wrong PIN
Expand Down
56 changes: 24 additions & 32 deletions test/specs/send.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,39 +325,31 @@ describe('@send - Send', () => {

// send to unified invoice w/ expired invoice
let amtAfterUnified3: string;
if (driver.isAndroid) {
console.info('Sending to unified invoice w/ expired invoice...');
const unified3 =
'bitcoin:bcrt1qaytrqsrgg75rtxrtr7ur6k75la8p3v95mey48z?lightning=LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X';
console.info({ unified3 });

// const ln =
// 'LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X';
// const dec = await lnd.decodePayReq({ payReq: ln });
// console.info(JSON.stringify(dec, null, 2));
console.info('Sending to unified invoice w/ expired invoice...');
const unified3 =
'bitcoin:bcrt1qaytrqsrgg75rtxrtr7ur6k75la8p3v95mey48z?lightning=LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X';
console.info({ unified3 });

// const ln =
// 'LNBCRT1PN33T20DQQNP4QTNTQ4D2DHDYQ420HAUQF5TS7X32TNW9WGYEPQZQ6R9G69QPHW4RXPP5QU7UYXJYJA9PJV7H6JPEYEFFNZ98N686JDEAAK8AUD5AGC5X70HQSP54V5LEFATCQDEU8TLKAF6MDK3ZLU6MWUA52J4JEMD5XA85KGKMTTQ9QYYSGQCQPCXQRRSSRZJQWU6G4HMGH26EXXQYPQD8XHVWLARA66PL53V7S9CV2EE808UGDRN4APYQQQQQQQGRCQQQQLGQQQQQQGQ2QX7F74RT5SQE0KEYCU47LYMSVY2LM4QA4KLR65PPSY55M0H4VR8AN7WVM9EFVSPYJ5R8EFGVXTGVATAGFTC372VRJ3HEPSEELFZ7FQFCQ9XDU9X';
// const dec = await lnd.decodePayReq({ payReq: ln });
// console.info(JSON.stringify(dec, null, 2));

await sleep(1000);
await enterAddress(unified3, { acceptCameraPermission: false });
await elementById('AssetButton-savings').waitForDisplayed();
await tap('N1');
await multiTap('N0', 4);
await tap('ContinueAmount');
await reviewAmt.waitForDisplayed();
await expect(reviewAmt).toHaveText('10 000');
await dragOnElement('GRAB', 'right', 0.95);
await elementById('SendSuccess').waitForDisplayed();
await tap('Close');
await expect(totalBalance).not.toHaveText(amtAfterUnified2);
amtAfterUnified3 = await totalBalance.getText();
console.info({ amtAfterUnified3 });
await expectTextWithin('ActivitySpending', '7 000');
} else {
// https://github.com/synonymdev/bitkit-ios/issues/300
console.info(
'Skipping sending to unified invoice w/ expired invoice on iOS due to /bitkit-ios/issues/300'
);
amtAfterUnified3 = amtAfterUnified2;
}
await sleep(1000);
await enterAddress(unified3, { acceptCameraPermission: false });
await elementById('AssetButton-savings').waitForDisplayed();
await tap('N1');
await multiTap('N0', 4);
await tap('ContinueAmount');
await reviewAmt.waitForDisplayed();
await expect(reviewAmt).toHaveText('10 000');
await dragOnElement('GRAB', 'right', 0.95);
await elementById('SendSuccess').waitForDisplayed();
await tap('Close');
await expect(totalBalance).not.toHaveText(amtAfterUnified2);
amtAfterUnified3 = await totalBalance.getText();
console.info({ amtAfterUnified3 });
await expectTextWithin('ActivitySpending', '7 000');

// send to unified invoice w/o amount (lightning)
console.info('Sending to unified invoice w/o amount (lightning)...');
Expand Down
2 changes: 1 addition & 1 deletion wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const config: WebdriverIO.Config = {
// baseUrl: 'http://localhost:8080',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 30000,
waitforTimeout: process.env.CI ? 30000 : 10000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
Expand Down