BlueWallet/tests/e2e/bluewallet3.spec.js

102 lines
5.2 KiB
JavaScript
Raw Normal View History

2024-07-13 17:01:05 -04:00
import { hashIt, helperDeleteWallet, helperImportWallet, sleep, yo } from './helperz';
2021-09-17 18:29:35 +01:00
2023-03-04 13:51:11 -04:00
beforeAll(async () => {
// reinstalling the app just for any case to clean up app's storage
await device.launchApp({ delete: true });
}, 300_000);
2021-09-17 18:29:35 +01:00
describe('BlueWallet UI Tests - import Watch-only wallet (zpub)', () => {
/**
* test plan:
* 1. import wallet
* 2. wallet -> send -> import transaction (scan QR)
* 3. provide unsigned psbt from coldcard (UR)
* 4. on psbtWithHardwareWallet, tap scanQr
* 5. provide fully signed psbt (UR)
* 6. verify that we can see broadcast button and camera backdorr button is NOT visible
*/
it('can import zpub as watch-only, import psbt, and then scan signed psbt', async () => {
const lockFile = '/tmp/travislock.' + hashIt('t31');
2021-09-17 18:29:35 +01:00
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile)) return console.warn('skipping', JSON.stringify('t31'), 'as it previously passed on Travis');
2021-09-17 18:29:35 +01:00
}
2023-03-04 13:51:11 -04:00
await device.launchApp({ newInstance: true });
2021-09-17 18:29:35 +01:00
await helperImportWallet(
// MNEMONICS_KEYSTONE
'zpub6s2EvLxwvDpaHNVP5vfordTyi8cH1fR8usmEjz7RsSQjfTTGU2qA5VEcEyYYBxpZAyBarJoTraB4VRJKVz97Au9jRNYfLAeeHC5UnRZbz8Y',
'watchOnly',
2021-09-17 18:29:35 +01:00
'Imported Watch-only',
2024-03-31 17:55:01 -04:00
'0.0001',
2021-09-17 18:29:35 +01:00
);
2023-03-04 13:51:11 -04:00
await sleep(15000);
2021-09-17 18:29:35 +01:00
await element(by.id('ReceiveButton')).tap();
try {
// in case emulator has no google services and doesnt support pushes
// we just dont show this popup
await element(by.text(`No, and do not ask me again.`)).tap();
2024-06-26 22:20:04 +01:00
await element(by.text(`No, and do not ask me again.`)).tap(); // sometimes the first click doesnt work (detox issue, not app's)
2021-09-17 18:29:35 +01:00
} catch (_) {}
await expect(element(by.id('BitcoinAddressQRCodeContainer'))).toBeVisible();
await expect(element(by.text('bc1qc8wun6lf9vcajpddtgdpd2pdrp0kwp29j6upgv'))).toBeVisible();
2021-09-17 18:29:35 +01:00
await element(by.id('SetCustomAmountButton')).tap();
await element(by.id('BitcoinAmountInput')).replaceText('1');
await element(by.id('CustomAmountDescription')).typeText('Test');
2024-07-13 14:20:06 -04:00
await element(by.id('CustomAmountDescription')).tapReturnKey();
2021-09-17 18:29:35 +01:00
await element(by.id('CustomAmountSaveButton')).tap();
2024-07-13 16:54:01 -04:00
await expect(element(by.id('CustomAmountDescriptionText'))).toHaveText('Test');
await expect(element(by.id('BitcoinAmountText'))).toHaveText('1 BTC');
2021-09-17 18:29:35 +01:00
await expect(element(by.id('BitcoinAddressQRCodeContainer'))).toBeVisible();
await expect(element(by.text('bitcoin:bc1qc8wun6lf9vcajpddtgdpd2pdrp0kwp29j6upgv?amount=1&label=Test'))).toBeVisible();
2021-09-17 18:29:35 +01:00
await device.pressBack();
await element(by.id('SendButton')).tap();
await element(by.text('OK')).tap();
await element(by.id('advancedOptionsMenuButton')).tap();
2024-08-04 22:13:25 -04:00
await element(by.text('Import Transaction (QR)')).tap(); // opens camera
2021-09-17 18:29:35 +01:00
// produced by real Keystone device using MNEMONICS_KEYSTONE
2021-09-17 18:29:35 +01:00
const unsignedPsbt =
'UR:CRYPTO-PSBT/HDRNJOJKIDJYZMADAEGOAOAEAEAEADLFIAYKFPTOTIHSMNDLJTLFTYPAHTFHZESOAODIBNADFDCPFZZEKSSTTOJYKPRLJOAEAEAEAEAEZMZMZMZMADNBDSAEAEAEAEAEAECFKOPTBBCFBGNTGUVAEHNDPECFUYNBHKRNPMCMJNYTBKROYKLOPSAEAEAEAEAEADADCTBEDIAEAEAEAEAEAECMAEBBFTZSECYTJZTEKGOEKECAVOGHMTVWGYIAMHCSKOSWCPAMAXENRDWMCPOTZMHKGMFPNTHLMNDMCETOHLOXTANDAMEOTSURLFHHPLTSDPCSJTWSGACSRPLEYNVEGHAEAELAAEAEAELAAEAEAELAAEAEAEAEAEAEAEAEAEAEGETNJYFN';
2021-09-17 18:29:35 +01:00
const signedPsbt =
'UR:CRYPTO-PSBT/HDWTJOJKIDJYZMADAEGOAOAEAEAEADLFIAYKFPTOTIHSMNDLJTLFTYPAHTFHZESOAODIBNADFDCPFZZEKSSTTOJYKPRLJOAEAEAEAEAEZMZMZMZMADNBDSAEAEAEAEAEAECFKOPTBBCFBGNTGUVAEHNDPECFUYNBHKRNPMCMJNYTBKROYKLOPSAEAEAEAEAEADADCTBEDIAEAEAEAEAEAECMAEBBFTZSECYTJZTEKGOEKECAVOGHMTVWGYIAMHCSKOSWADAYJEAOFLDYFYAOCXGEUTDNBDTNMKTOQDLASKMTTSCLCSHPOLGDBEHDBBZMNERLRFSFIDLTMHTLMTLYWKAOCXFRBWHGOSGYRLYKTSSSSSIEWDZOVOSTFNISKTBYCLLRLRHSHFCMSGTTVDRHURNSOLADCLAXENRDWMCPOTZMHKGMFPNTHLMNDMCETOHLOXTANDAMEOTSURLFHHPLTSDPCSJTWSGAAEAEDLFPLTSW';
2021-09-17 18:29:35 +01:00
// tapping 5 times invisible button is a backdoor:
2024-01-13 23:17:25 +00:00
await sleep(5000); // wait for camera screen to initialize
2021-09-17 18:29:35 +01:00
for (let c = 0; c <= 5; c++) {
await element(by.id('ScanQrBackdoorButton')).tap();
await sleep(1000);
}
await element(by.id('scanQrBackdoorInput')).replaceText(unsignedPsbt);
await element(by.id('scanQrBackdoorOkButton')).tap();
// now lets test scanning back QR with UR PSBT. this should lead straight to broadcast dialog
await element(by.id('PsbtWithHardwareScrollView')).swipe('up', 'fast', 1); // in case emu screen is small and it doesnt fit
await element(by.id('PsbtTxScanButton')).tap(); // opening camera
// tapping 5 times invisible button is a backdoor:
2024-01-13 23:17:25 +00:00
await sleep(5000); // wait for camera screen to initialize
2021-09-17 18:29:35 +01:00
for (let c = 0; c <= 5; c++) {
await element(by.id('ScanQrBackdoorButton')).tap();
await sleep(1000);
}
await element(by.id('scanQrBackdoorInput')).replaceText(signedPsbt);
await element(by.id('scanQrBackdoorOkButton')).tap();
await expect(element(by.id('ScanQrBackdoorButton'))).toBeNotVisible();
await yo('PsbtWithHardwareWalletBroadcastTransactionButton');
await device.pressBack();
await device.pressBack();
await device.pressBack();
await helperDeleteWallet('Imported Watch-only', '10000');
2021-09-17 18:29:35 +01:00
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});
});