2024-05-20 11:54:13 +02:00
import assert from 'assert' ;
import * as bitcoin from 'bitcoinjs-lib' ;
2021-09-17 19:29:35 +02:00
import {
2024-05-20 11:54:13 +02:00
expectToBeVisible ,
extractTextFromElementById ,
hashIt ,
helperCreateWallet ,
2021-09-17 19:29:35 +02:00
helperDeleteWallet ,
2024-05-20 11:54:13 +02:00
helperSwitchAdvancedMode ,
2021-09-17 19:29:35 +02:00
sleep ,
sup ,
yo ,
} from './helperz' ;
2020-05-23 08:50:08 +02:00
2023-03-04 18:51:11 +01:00
/ * *
* this testsuite is for test cases that require no wallets to be present
* /
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 19:29:35 +02:00
describe ( 'BlueWallet UI Tests - no wallets' , ( ) => {
2020-04-20 14:29:37 +02:00
it ( 'selftest passes' , async ( ) => {
2022-06-03 18:54:05 +02:00
const lockFile = '/tmp/travislock.' + hashIt ( 't1' ) ;
2020-05-23 08:50:08 +02:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't1' ) , 'as it previously passed on Travis' ) ;
2020-05-23 08:50:08 +02:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2020-04-20 14:29:37 +02:00
await waitFor ( element ( by . id ( 'WalletsList' ) ) )
. toBeVisible ( )
. withTimeout ( 300 * 1000 ) ;
// go to settings, press SelfTest and wait for OK
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
await element ( by . id ( 'AboutButton' ) ) . tap ( ) ;
await element ( by . id ( 'AboutScrollView' ) ) . swipe ( 'up' , 'fast' , 1 ) ; // in case emu screen is small and it doesnt fit
await element ( by . id ( 'RunSelfTestButton' ) ) . tap ( ) ;
await waitFor ( element ( by . id ( 'SelfTestOk' ) ) )
. toBeVisible ( )
. withTimeout ( 300 * 1000 ) ;
2021-09-16 20:56:09 +02:00
await device . pressBack ( ) ;
await device . pressBack ( ) ;
await device . pressBack ( ) ;
2020-05-23 08:50:08 +02:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
2020-04-20 14:29:37 +02:00
} ) ;
2021-08-19 18:30:19 +02:00
it ( 'all settings screens work' , async ( ) => {
2022-06-03 18:54:05 +02:00
const lockFile = '/tmp/travislock.' + hashIt ( 't2' ) ;
2021-03-01 11:20:01 +01:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't2' ) , 'as it previously passed on Travis' ) ;
2021-03-01 11:20:01 +01:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2021-03-01 11:20:01 +01:00
await yo ( 'WalletsList' ) ;
// go to settings, press SelfTest and wait for OK
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
// general
await element ( by . id ( 'GeneralSettings' ) ) . tap ( ) ;
2021-04-06 12:31:56 +02:00
// privacy
// trigger switches
await element ( by . id ( 'SettingsPrivacy' ) ) . tap ( ) ;
2023-03-30 02:46:11 +02:00
await element ( by . id ( 'ClipboardSwitch' ) ) . tap ( ) ;
await element ( by . id ( 'ClipboardSwitch' ) ) . tap ( ) ;
await element ( by . id ( 'QuickActionsSwitch' ) ) . tap ( ) ;
await element ( by . id ( 'QuickActionsSwitch' ) ) . tap ( ) ;
2021-04-06 12:31:56 +02:00
await device . pressBack ( ) ;
// enable AdvancedMode
2021-03-01 11:20:01 +01:00
await element ( by . id ( 'AdvancedMode' ) ) . tap ( ) ;
await device . pressBack ( ) ;
2021-09-16 20:56:09 +02:00
// disable it:
await element ( by . id ( 'GeneralSettings' ) ) . tap ( ) ;
await element ( by . id ( 'AdvancedMode' ) ) . tap ( ) ;
await device . pressBack ( ) ;
2021-03-01 11:20:01 +01:00
//
// currency
// change currency to ARS ($) and switch it back to USD ($)
await element ( by . id ( 'Currency' ) ) . tap ( ) ;
await element ( by . text ( 'ARS ($)' ) ) . tap ( ) ;
2022-07-24 20:56:33 +02:00
await expect ( element ( by . text ( 'Price is obtained from Yadio' ) ) ) . toBeVisible ( ) ;
2021-03-01 11:20:01 +01:00
await element ( by . text ( 'USD ($)' ) ) . tap ( ) ;
await device . pressBack ( ) ;
// language
// change language to Chinese (ZH), test it and switch back to English
await element ( by . id ( 'Language' ) ) . tap ( ) ;
await element ( by . text ( 'Chinese (ZH)' ) ) . tap ( ) ;
await device . pressBack ( ) ;
await expect ( element ( by . text ( '语言' ) ) ) . toBeVisible ( ) ;
await element ( by . id ( 'Language' ) ) . tap ( ) ;
await element ( by . text ( 'English' ) ) . tap ( ) ;
await device . pressBack ( ) ;
// security
await element ( by . id ( 'SecurityButton' ) ) . tap ( ) ;
await device . pressBack ( ) ;
// network
await element ( by . id ( 'NetworkSettings' ) ) . tap ( ) ;
// network -> electrum server
// change electrum server to electrum.blockstream.info and revert it back
await element ( by . id ( 'ElectrumSettings' ) ) . tap ( ) ;
await element ( by . id ( 'HostInput' ) ) . replaceText ( 'electrum.blockstream.info\n' ) ;
await element ( by . id ( 'PortInput' ) ) . replaceText ( '50001\n' ) ;
await element ( by . id ( 'Save' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . id ( 'ResetToDefault' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await expect ( element ( by . id ( 'HostInput' ) ) ) . toHaveText ( '' ) ;
await expect ( element ( by . id ( 'PortInput' ) ) ) . toHaveText ( '' ) ;
2021-07-05 05:05:04 +02:00
await expect ( element ( by . id ( 'SSLPortInput' ) ) ) . toHaveToggleValue ( false ) ;
2021-03-01 11:20:01 +01:00
await device . pressBack ( ) ;
// network -> lightning
// change URI and revert it back
2023-06-02 12:27:01 +02:00
/* muted since https:/ / lndhub . herokuapp . com is down
2021-03-01 11:20:01 +01:00
await element ( by . id ( 'LightningSettings' ) ) . tap ( ) ;
await element ( by . id ( 'URIInput' ) ) . replaceText ( 'invalid\n' ) ;
await element ( by . id ( 'Save' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
2021-08-30 05:51:24 +02:00
await expect ( element ( by . text ( 'Invalid LNDHub URI' ) ) ) . toBeVisible ( ) ;
2021-03-01 11:20:01 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . id ( 'URIInput' ) ) . replaceText ( 'https://lndhub.herokuapp.com\n' ) ;
await element ( by . id ( 'Save' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
await expect ( element ( by . text ( 'Your changes have been saved successfully.' ) ) ) . toBeVisible ( ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . id ( 'URIInput' ) ) . replaceText ( '\n' ) ;
await element ( by . id ( 'Save' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
await expect ( element ( by . text ( 'Your changes have been saved successfully.' ) ) ) . toBeVisible ( ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await device . pressBack ( ) ;
2023-06-02 12:27:01 +02:00
* /
2021-03-01 11:20:01 +01:00
2021-04-11 22:53:05 +02:00
// notifications
2021-03-04 08:06:07 +01:00
// turn on notifications if available
2021-04-13 14:26:37 +02:00
// console.warn('yo');
// await sleep(300000);
2021-03-04 08:06:07 +01:00
if ( await expectToBeVisible ( 'NotificationSettings' ) ) {
2021-04-13 14:26:37 +02:00
await element ( by . id ( 'NotificationSettings' ) ) . tap ( ) ;
2021-03-04 08:06:07 +01:00
await element ( by . id ( 'NotificationsSwitch' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . id ( 'NotificationsSwitch' ) ) . tap ( ) ;
await device . pressBack ( ) ;
2021-03-31 17:21:39 +02:00
await device . pressBack ( ) ;
2021-04-13 14:26:37 +02:00
} else {
await device . pressBack ( ) ;
2021-03-04 08:06:07 +01:00
}
2021-03-01 11:20:01 +01:00
2021-03-31 17:21:39 +02:00
// tools
await element ( by . id ( 'Tools' ) ) . tap ( ) ;
// tools -> broadcast
// try to broadcast wrong tx
await element ( by . id ( 'Broadcast' ) ) . tap ( ) ;
await element ( by . id ( 'TxHex' ) ) . replaceText ( 'invalid\n' ) ;
await element ( by . id ( 'BroadcastButton' ) ) . tap ( ) ;
await sup ( 'OK' ) ;
// await expect(element(by.text('the transaction was rejected by network rules....'))).toBeVisible();
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await device . pressBack ( ) ;
2021-04-01 12:11:53 +02:00
// IsItMyAddress
await element ( by . id ( 'IsItMyAddress' ) ) . tap ( ) ;
await element ( by . id ( 'AddressInput' ) ) . replaceText ( 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl' ) ;
await element ( by . id ( 'CheckAddress' ) ) . tap ( ) ;
await expect ( element ( by . id ( 'Result' ) ) ) . toHaveText ( 'None of the available wallets own the provided address.' ) ;
await device . pressBack ( ) ;
2021-03-31 18:38:43 +02:00
await device . pressBack ( ) ;
2021-03-01 11:20:01 +01:00
// about
await element ( by . id ( 'AboutButton' ) ) . tap ( ) ;
await device . pressBack ( ) ;
2021-09-16 20:56:09 +02:00
await device . pressBack ( ) ;
2021-03-01 11:20:01 +01:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
} ) ;
2021-01-24 01:40:39 +01:00
it ( 'can create wallet, reload app and it persists. then go to receive screen, set custom amount and label. Dismiss modal and go to WalletsList.' , async ( ) => {
2022-06-03 18:54:05 +02:00
const lockFile = '/tmp/travislock.' + hashIt ( 't3' ) ;
2020-05-23 08:50:08 +02:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't3' ) , 'as it previously passed on Travis' ) ;
2020-05-23 08:50:08 +02:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2020-04-30 14:47:10 +02:00
await yo ( 'WalletsList' ) ;
await helperCreateWallet ( ) ;
await device . launchApp ( { newInstance : true } ) ;
await yo ( 'WalletsList' ) ;
await expect ( element ( by . id ( 'cr34t3d' ) ) ) . toBeVisible ( ) ;
2021-01-23 05:50:52 +01:00
await element ( by . id ( 'cr34t3d' ) ) . tap ( ) ;
await element ( by . id ( 'ReceiveButton' ) ) . tap ( ) ;
2023-12-20 22:24:26 +01:00
await element ( by . text ( 'Yes, I have.' ) ) . tap ( ) ;
2021-01-27 14:57:07 +01:00
try {
// in case emulator has no google services and doesnt support pushes
// we just dont show this popup
2023-12-20 22:24:26 +01:00
await element ( by . text ( ` No, and do not ask me again. ` ) ) . tap ( ) ;
2024-06-26 23:20:04 +02: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-01-27 14:57:07 +01:00
} catch ( _ ) { }
2021-01-23 05:50:52 +01:00
await yo ( 'BitcoinAddressQRCodeContainer' ) ;
2024-03-27 05:37:43 +01:00
await yo ( 'CopyTextToClipboard' ) ;
2021-01-23 05:50:52 +01:00
await element ( by . id ( 'SetCustomAmountButton' ) ) . tap ( ) ;
2021-07-06 11:38:53 +02:00
await element ( by . id ( 'BitcoinAmountInput' ) ) . replaceText ( '1' ) ;
2021-01-23 05:50:52 +01:00
await element ( by . id ( 'CustomAmountDescription' ) ) . typeText ( 'test' ) ;
2024-07-13 20:20:06 +02:00
await element ( by . id ( 'CustomAmountDescription' ) ) . tapReturnKey ( ) ;
2021-01-23 05:50:52 +01:00
await element ( by . id ( 'CustomAmountSaveButton' ) ) . tap ( ) ;
await sup ( '1 BTC' ) ;
await sup ( 'test' ) ;
await yo ( 'BitcoinAddressQRCodeContainer' ) ;
2024-03-27 05:37:43 +01:00
await yo ( 'CopyTextToClipboard' ) ;
2021-01-23 05:50:52 +01:00
await device . pressBack ( ) ;
await device . pressBack ( ) ;
2021-09-16 20:56:09 +02:00
await helperDeleteWallet ( 'cr34t3d' ) ;
2020-05-23 08:50:08 +02:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
2020-04-30 14:47:10 +02:00
} ) ;
2021-09-16 20:56:09 +02:00
it ( 'can encrypt storage, with plausible deniabilityl decrypt fake storage' , async ( ) => {
2022-06-03 18:54:05 +02:00
const lockFile = '/tmp/travislock.' + hashIt ( 't4' ) ;
2020-05-23 08:50:08 +02:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't4' ) , 'as it previously passed on Travis' ) ;
2020-05-23 08:50:08 +02:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2020-03-19 16:51:35 +01:00
await yo ( 'WalletsList' ) ;
// lets create a wallet
await helperCreateWallet ( ) ;
2020-03-18 16:38:52 +01:00
2020-03-19 16:51:35 +01:00
// go to settings
await expect ( element ( by . id ( 'SettingsButton' ) ) ) . toBeVisible ( ) ;
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
2020-03-20 16:25:23 +01:00
await expect ( element ( by . id ( 'SecurityButton' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
// go to Security page where we will enable encryption
2020-03-20 16:25:23 +01:00
await element ( by . id ( 'SecurityButton' ) ) . tap ( ) ;
2024-06-12 18:46:44 +02:00
// await expect(element(by.id('EncyptedAndPasswordProtected'))).toBeVisible(); // @see https://github.com/@rneui/themed/@rneui/themed/issues/2519
2020-03-19 16:51:35 +01:00
await expect ( element ( by . id ( 'PlausibleDeniabilityButton' ) ) ) . toBeNotVisible ( ) ;
2020-03-18 18:03:05 +01:00
if ( device . getPlatform ( ) === 'ios' ) {
console . warn ( 'Android only test skipped' ) ;
return ;
}
2020-03-19 16:51:35 +01:00
// lets encrypt the storage.
2020-03-18 18:03:05 +01:00
// first, trying to mistype second password:
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.CompoundButton' ) ) . tap ( ) ; // thats a switch lol. lets tap it
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( '08902' ) ;
2020-03-18 18:03:05 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( '666' ) ;
2020-03-18 18:03:05 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-12 22:14:57 +01:00
await expect ( element ( by . text ( 'Passwords do not match.' ) ) ) . toBeVisible ( ) ;
2020-03-18 18:03:05 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-03-19 16:51:35 +01:00
// now, lets put correct passwords and encrypt the storage
await element ( by . type ( 'android.widget.CompoundButton' ) ) . tap ( ) ; // thats a switch lol
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'qqq' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'qqq' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-03-16 14:51:08 +01:00
2020-03-19 16:51:35 +01:00
// relaunch app
await device . launchApp ( { newInstance : true } ) ;
await waitFor ( element ( by . text ( 'OK' ) ) )
2020-03-18 16:38:52 +01:00
. toBeVisible ( )
2020-03-19 17:55:35 +01:00
. withTimeout ( 33000 ) ;
2020-03-18 16:38:52 +01:00
2020-11-22 10:18:05 +01:00
// trying to decrypt with incorrect password
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Your storage is encrypted. Password is required to decrypt it.' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'wrong' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Incorrect password. Please try again.' ) ) ) . toBeVisible ( ) ;
2020-03-18 16:38:52 +01:00
2020-03-19 16:51:35 +01:00
// correct password
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'qqq' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await yo ( 'WalletsList' ) ;
2020-03-18 16:38:52 +01:00
2020-03-19 16:51:35 +01:00
// previously created wallet should be visible
2020-03-18 16:38:52 +01:00
await expect ( element ( by . id ( 'cr34t3d' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
// now lets enable plausible deniability feature
// go to settings -> security screen -> plausible deniability screen
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
2020-03-20 16:25:23 +01:00
await expect ( element ( by . id ( 'SecurityButton' ) ) ) . toBeVisible ( ) ;
await element ( by . id ( 'SecurityButton' ) ) . tap ( ) ;
2024-06-12 18:46:44 +02:00
// await expect(element(by.id('EncyptedAndPasswordProtected'))).toBeVisible(); // @see https://github.com/@rneui/themed/@rneui/themed/issues/2519
2020-03-19 16:51:35 +01:00
await expect ( element ( by . id ( 'PlausibleDeniabilityButton' ) ) ) . toBeVisible ( ) ;
await element ( by . id ( 'PlausibleDeniabilityButton' ) ) . tap ( ) ;
// trying to enable plausible denability
await element ( by . id ( 'CreateFakeStorageButton' ) ) . tap ( ) ;
2020-12-12 22:14:57 +01:00
await expect ( element ( by . text ( 'Password for the fake storage should not match the password for your main storage.' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
// trying MAIN password: should fail, obviously
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'qqq' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Password is currently in use. Please try a different password.' ) ) ) . toBeVisible ( ) ;
2020-04-30 14:47:10 +02:00
if ( process . env . TRAVIS ) await sleep ( 3000 ) ; // hopefully helps prevent crash
2020-03-19 16:51:35 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-04-30 14:47:10 +02:00
if ( process . env . TRAVIS ) await sleep ( 3000 ) ; // hopefully helps prevent crash
2020-03-19 16:51:35 +01:00
// trying new password, but will mistype
await element ( by . id ( 'CreateFakeStorageButton' ) ) . tap ( ) ;
2020-04-30 14:47:10 +02:00
if ( process . env . TRAVIS ) await sleep ( 3000 ) ; // hopefully helps prevent crash
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'passwordForFakeStorage' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Re-type password' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'passwordForFakeStorageWithTypo' ) ; // retyping with typo
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Passwords do not match. Please try again.' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
// trying new password
await element ( by . id ( 'CreateFakeStorageButton' ) ) . tap ( ) ;
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'passwordForFakeStorage' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Re-type password' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'passwordForFakeStorage' ) ; // retyping
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await expect ( element ( by . text ( 'Success' ) ) ) . toBeVisible ( ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
// created fake storage.
// creating a wallet inside this fake storage
await helperCreateWallet ( 'fake_wallet' ) ;
// relaunch the app, unlock with fake password, expect to see fake wallet
// relaunch app
2020-03-18 16:38:52 +01:00
await device . launchApp ( { newInstance : true } ) ;
2020-03-19 16:51:35 +01:00
await waitFor ( element ( by . text ( 'OK' ) ) )
2020-03-18 16:38:52 +01:00
. toBeVisible ( )
2020-03-19 17:55:35 +01:00
. withTimeout ( 33000 ) ;
2020-03-19 16:51:35 +01:00
//
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Your storage is encrypted. Password is required to decrypt it.' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'qqq' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await yo ( 'WalletsList' ) ;
// previously created wallet IN MAIN STORAGE should be visible
await expect ( element ( by . id ( 'cr34t3d' ) ) ) . toBeVisible ( ) ;
// relaunch app
await device . launchApp ( { newInstance : true } ) ;
await sleep ( 3000 ) ;
//
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Your storage is encrypted. Password is required to decrypt it.' ) ) ) . toBeVisible ( ) ;
2020-03-19 16:51:35 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'passwordForFakeStorage' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await yo ( 'WalletsList' ) ;
// previously created wallet in FAKE storage should be visible
await expect ( element ( by . id ( 'fake_wallet' ) ) ) . toBeVisible ( ) ;
2020-03-20 12:46:45 +01:00
2021-09-16 20:56:09 +02:00
// now derypting it, to cleanup
2020-03-20 12:46:45 +01:00
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
2020-03-20 16:25:23 +01:00
await element ( by . id ( 'SecurityButton' ) ) . tap ( ) ;
2020-03-20 12:46:45 +01:00
// correct password
await element ( by . type ( 'android.widget.CompoundButton' ) ) . tap ( ) ; // thats a switch lol
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2021-09-16 20:56:09 +02:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'passwordForFakeStorage' ) ;
2020-03-20 12:46:45 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2021-09-16 20:56:09 +02:00
await helperDeleteWallet ( 'fake_wallet' ) ;
2020-05-23 08:50:08 +02:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
2020-03-20 12:46:45 +01:00
} ) ;
2021-09-16 20:56:09 +02:00
it ( 'can encrypt storage, and decrypt storage works' , async ( ) => {
2022-06-03 18:54:05 +02:00
const lockFile = '/tmp/travislock.' + hashIt ( 't5' ) ;
2020-05-23 08:50:08 +02:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't5' ) , 'as it previously passed on Travis' ) ;
2020-05-23 08:50:08 +02:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2020-03-20 12:46:45 +01:00
await yo ( 'WalletsList' ) ;
await helperCreateWallet ( ) ;
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
2020-03-20 16:25:23 +01:00
await element ( by . id ( 'SecurityButton' ) ) . tap ( ) ;
2020-03-20 12:46:45 +01:00
if ( device . getPlatform ( ) === 'ios' ) {
console . warn ( 'Android only test skipped' ) ;
return ;
}
// lets encrypt the storage.
// lets put correct passwords and encrypt the storage
await element ( by . type ( 'android.widget.CompoundButton' ) ) . tap ( ) ; // thats a switch lol
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'pass' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'pass' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await element ( by . id ( 'PlausibleDeniabilityButton' ) ) . tap ( ) ;
// trying to enable plausible denability
await element ( by . id ( 'CreateFakeStorageButton' ) ) . tap ( ) ;
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'fake' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Re-type password' ) ) ) . toBeVisible ( ) ;
2020-03-20 12:46:45 +01:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'fake' ) ; // retyping
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await expect ( element ( by . text ( 'Success' ) ) ) . toBeVisible ( ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
// created fake storage.
// creating a wallet inside this fake storage
await helperCreateWallet ( 'fake_wallet' ) ;
// relaunch app
await device . launchApp ( { newInstance : true } ) ;
await waitFor ( element ( by . text ( 'OK' ) ) )
. toBeVisible ( )
. withTimeout ( 33000 ) ;
//
2020-12-09 21:47:46 +01:00
await expect ( element ( by . text ( 'Your storage is encrypted. Password is required to decrypt it.' ) ) ) . toBeVisible ( ) ;
2021-09-16 20:56:09 +02:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'pass' ) ;
2020-03-20 12:46:45 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await yo ( 'WalletsList' ) ;
2021-09-16 20:56:09 +02:00
// previously created wallet IN MAIN STORAGE should be visible
await expect ( element ( by . id ( 'cr34t3d' ) ) ) . toBeVisible ( ) ;
2020-03-20 12:46:45 +01:00
// now go to settings, and decrypt
await element ( by . id ( 'SettingsButton' ) ) . tap ( ) ;
2020-03-20 16:25:23 +01:00
await element ( by . id ( 'SecurityButton' ) ) . tap ( ) ;
2020-03-20 12:46:45 +01:00
2021-09-16 20:56:09 +02:00
// putting FAKE storage password. should not succeed
2020-03-20 12:46:45 +01:00
await element ( by . type ( 'android.widget.CompoundButton' ) ) . tap ( ) ; // thats a switch lol
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2021-09-16 20:56:09 +02:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'fake' ) ;
2020-03-20 12:46:45 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2020-12-10 16:28:56 +01:00
await expect ( element ( by . text ( 'Incorrect password. Please try again.' ) ) ) . toBeVisible ( ) ;
2020-03-20 12:46:45 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
// correct password
await element ( by . type ( 'android.widget.CompoundButton' ) ) . tap ( ) ; // thats a switch lol
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2021-09-16 20:56:09 +02:00
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( 'pass' ) ;
2020-03-20 12:46:45 +01:00
await element ( by . text ( 'OK' ) ) . tap ( ) ;
// relaunch app
await device . launchApp ( { newInstance : true } ) ;
2021-09-16 20:56:09 +02:00
await yo ( 'cr34t3d' ) ; // success
await helperDeleteWallet ( 'cr34t3d' ) ;
2020-05-23 08:50:08 +02:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
2020-03-20 12:46:45 +01:00
} ) ;
2024-03-01 12:45:05 +01:00
it ( 'can import 2of2 multisig using individual cosigners (1 signer, 1 xpub)' , async ( ) => {
const lockFile = '/tmp/travislock.' + hashIt ( 'can import 2of2 multisig using individual cosigners (1 signer, 1 xpub)' ) ;
if ( process . env . TRAVIS ) {
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping as it previously passed on Travis' ) ;
}
await device . launchApp ( { newInstance : true } ) ;
await helperSwitchAdvancedMode ( ) ;
await yo ( 'WalletsList' ) ;
await element ( by . id ( 'WalletsList' ) ) . swipe ( 'left' , 'fast' , 1 ) ; // in case emu screen is small and it doesnt fit
2024-03-15 21:05:15 +01:00
await sleep ( 200 ) ; // Wait until bounce animation finishes.
2024-03-01 12:45:05 +01:00
// going to Import Wallet screen and importing Vault
await element ( by . id ( 'CreateAWallet' ) ) . tap ( ) ;
await yo ( 'ActivateVaultButton' ) ;
await element ( by . id ( 'ActivateVaultButton' ) ) . tap ( ) ;
await element ( by . id ( 'Create' ) ) . tap ( ) ;
// vault settings:
await element ( by . id ( 'VaultAdvancedCustomize' ) ) . tap ( ) ;
await element ( by . id ( 'DecreaseN' ) ) . tap ( ) ;
await element ( by . id ( 'ModalDoneButton' ) ) . tap ( ) ;
//
await element ( by . id ( 'LetsStart' ) ) . tap ( ) ;
// key1 - seed:
await element ( by . id ( 'VaultCosignerImport1' ) ) . tap ( ) ;
await element ( by . id ( 'ScanOrOpenFile' ) ) . tap ( ) ;
await sleep ( 5000 ) ; // wait for camera screen to initialize
for ( let c = 0 ; c <= 5 ; c ++ ) {
await element ( by . id ( 'ScanQrBackdoorButton' ) ) . tap ( ) ;
}
await element ( by . id ( 'scanQrBackdoorInput' ) ) . replaceText (
'pipe goose bottom run seed curious thought kangaroo example family coral success' ,
) ;
await element ( by . id ( 'scanQrBackdoorOkButton' ) ) . tap ( ) ;
await element ( by . id ( 'DoImportKeyButton' ) ) . tap ( ) ; // when seed - need to extra tap the button
// key2 - xpub:
await element ( by . id ( 'VaultCosignerImport2' ) ) . tap ( ) ;
await element ( by . id ( 'ScanOrOpenFile' ) ) . tap ( ) ;
await sleep ( 5000 ) ; // wait for camera screen to initialize
for ( let c = 0 ; c <= 5 ; c ++ ) {
await element ( by . id ( 'ScanQrBackdoorButton' ) ) . tap ( ) ;
}
await element ( by . id ( 'scanQrBackdoorInput' ) ) . replaceText (
'ur:crypto-account/oeadcypdlouebgaolytaadmetaaddloxaxhdclaxfdyksnwkuypkfevlfzfroyiyecoeosbakbpdcldawzhtcarkwsndcphphsbsdsayaahdcxfgjyckryosmwtdptlbflonbkimlsmovolslbytonayisprvoieftgeflzcrtvesbamtaaddyotadlocsdyykaeykaeykaoykaocypdlouebgaxaaaycyttatrnolimvetsst' ,
) ;
await element ( by . id ( 'scanQrBackdoorOkButton' ) ) . tap ( ) ;
// when xpub - it automatically closes the modal, so no need to tap the button
await element ( by . id ( 'CreateButton' ) ) . tap ( ) ;
await yo ( 'Multisig Vault' ) ;
await element ( by . id ( 'Multisig Vault' ) ) . tap ( ) ; // go inside the wallet
await element ( by . id ( 'ReceiveButton' ) ) . tap ( ) ;
await element ( by . text ( 'Yes, I have.' ) ) . 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 23:20:04 +02:00
await element ( by . text ( ` No, and do not ask me again. ` ) ) . tap ( ) ; // sometimes the first click doesnt work (detox issue, not app's)
2024-03-01 12:45:05 +01:00
} catch ( _ ) { }
await sup ( 'bc1qmf06nt4jhvzz4387ak8fecs42k6jqygr2unumetfc7xkdup7ah9s8phlup' ) ;
await device . pressBack ( ) ;
await element ( by . id ( 'WalletDetails' ) ) . tap ( ) ;
await sup ( '2 / 2 (native segwit)' ) ;
await device . pressBack ( ) ;
await helperDeleteWallet ( 'Multisig Vault' ) ;
await helperSwitchAdvancedMode ( ) ; // turn off advanced mode
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
} ) ;
2021-09-27 20:24:51 +02:00
it ( 'can import multisig setup from UR, and create tx, and sign on hw devices' , async ( ) => {
2022-06-03 18:54:05 +02:00
const lockFile = '/tmp/travislock.' + hashIt ( 't6' ) ;
2020-11-05 18:17:27 +01:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't6' ) , 'as it previously passed on Travis' ) ;
2020-11-05 18:17:27 +01:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2020-11-04 20:41:40 +01:00
await yo ( 'WalletsList' ) ;
await element ( by . id ( 'WalletsList' ) ) . swipe ( 'left' , 'fast' , 1 ) ; // in case emu screen is small and it doesnt fit
2024-03-15 21:05:15 +01:00
await sleep ( 200 ) ; // Wait until bounce animation finishes.
2020-11-04 20:41:40 +01:00
// going to Import Wallet screen and importing mnemonic
await element ( by . id ( 'CreateAWallet' ) ) . tap ( ) ;
await element ( by . id ( 'ImportWallet' ) ) . tap ( ) ;
await element ( by . id ( 'ScanImport' ) ) . tap ( ) ;
const urs = [
'UR:BYTES/1OF2/J8RX04F2WJ9SSY577U30R55ELM4LUCJCXJVJTD60SYV9A286Q0AQH7QXL6/TYQMJGEQGFK82E2HV9KXCET5YPXH2MR5D9EKJEEQWDJHGATSYPNXJMR9PG3JQARGD9EJQENFD3JJQCM0DE6XZ6TWWVSX7MNV0YS8QATZD35KXGRTV4UHXGRPDEJZQ6TNYPEKZEN9YP6X7Z3RYPJXJUM5WF5KYAT5V5SXZMT0DENJQCM0WD5KWMN9WFES5GC2FESK6EF6YPXH2MR5D9EKJEEQ2ESH2MR5PFGX7MRFVDUN5GPJYPHKVGPJPFZX2UNFWESHG6T0DCAZQMF0XSUZWTESYUHNQFE0XGNS53N0WFKKZAP6YPGRY46NFQ9Q53PNXAZ5Z3PC8QAZQKNSW43RWDRFDFCXV6Z92F9YU6NGGD94S5NNWP2XGNZ22C6K2M69D4F4YKNYFPC5GANS' ,
'UR:BYTES/2OF2/J8RX04F2WJ9SSY577U30R55ELM4LUCJCXJVJTD60SYV9A286Q0AQH7QXL6/8944VARY2EZHJ62CDVMHQKRC2F3XVKN629M8X3ZXWPNYGJZ9FPT8G4NS0Q6YG73EG3R42468DCE9S6E40FRN2AF5X4G4GNTNT9FNYAN2DA5YU5G2PGCNVWZYGSMRQVE6YPD8QATZXU6K6S298PZK57TC2DAX772SD4RKUEP4G5MY672YXAQ5C36WDEJ8YA2HWC6NY7RS0F5K6KJ3FD6KKAMKG4N9S4ZGW9K5SWRWVF3XXDNRVDGR2APJV9XNXMTHWVEHQJ6E2DHYKUZTF4XHJARYVF8Y2KJX24UYK7N6W3V5VNFC2PHQ5ZSJDYL5T' ,
] ;
await waitFor ( element ( by . id ( 'UrProgressBar' ) ) ) . toBeNotVisible ( ) ;
for ( const ur of urs ) {
2021-03-24 18:17:17 +01:00
// tapping 5 times invisible button is a backdoor:
2024-01-14 00:17:25 +01:00
await sleep ( 5000 ) ; // wait for camera screen to initialize
2020-11-19 15:33:18 +01:00
for ( let c = 0 ; c <= 5 ; c ++ ) {
2020-11-04 20:41:40 +01:00
await element ( by . id ( 'ScanQrBackdoorButton' ) ) . tap ( ) ;
}
await element ( by . id ( 'scanQrBackdoorInput' ) ) . replaceText ( ur ) ;
await element ( by . id ( 'scanQrBackdoorOkButton' ) ) . tap ( ) ;
await waitFor ( element ( by . id ( 'UrProgressBar' ) ) ) . toBeVisible ( ) ;
}
if ( process . env . TRAVIS ) await sleep ( 60000 ) ;
await sup ( 'OK' , 3 * 61000 ) ; // waiting for wallet import
await element ( by . text ( 'OK' ) ) . tap ( ) ;
// ok, wallet imported
// lets go inside wallet
const expectedWalletLabel = 'Multisig Vault' ;
await element ( by . text ( expectedWalletLabel ) ) . tap ( ) ;
2020-11-05 18:17:27 +01:00
// sending...
await element ( by . id ( 'SendButton' ) ) . tap ( ) ;
await element ( by . id ( 'AddressInput' ) ) . replaceText ( 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl' ) ;
await element ( by . id ( 'BitcoinAmountInput' ) ) . typeText ( '0.0005\n' ) ;
// setting fee rate:
2021-09-27 20:24:51 +02:00
const feeRate = 3 ;
2020-11-05 18:17:27 +01:00
await element ( by . id ( 'chooseFee' ) ) . tap ( ) ;
await element ( by . id ( 'feeCustom' ) ) . tap ( ) ;
await element ( by . type ( 'android.widget.EditText' ) ) . typeText ( feeRate + '' ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
if ( process . env . TRAVIS ) await sleep ( 5000 ) ;
try {
await element ( by . id ( 'CreateTransactionButton' ) ) . tap ( ) ;
} catch ( _ ) { }
await waitFor ( element ( by . id ( 'ItemUnsigned' ) ) ) . toBeVisible ( ) ;
await waitFor ( element ( by . id ( 'ItemSigned' ) ) ) . toBeNotVisible ( ) ; // not a single green checkmark
await element ( by . id ( 'ProvideSignature' ) ) . tap ( ) ;
await element ( by . id ( 'CosignedScanOrImportFile' ) ) . tap ( ) ;
2021-09-27 20:24:51 +02:00
const ursSignedByPassport = [
'UR:CRYPTO-PSBT/22-4/LPCMAACFAXPLCYZTVYVOPKHDWPHKAXPYJOIHIDHNJSATRTSWEYGUHDURWYDECAGLAAHTTBHTFZFPWDRTLROXLUEHCXAHJTIHTEHDHKTEVTOTIOWFSKGEOSCFFLDRGLFTCYKELSRDNSHYGLLEVYIDGYZOEEDAAOENHGASFDHFVWNSATVYCFETATZSFROXFPMHGUJNWDSPNYMHHGPAIMGYURAYCXLEZEZSCLKBJZLFSRAOOYMSYNCEHDOSPYGTTDSODRSKLALBCAVYBNOLOEGSOYVOVLMWFDPFHGBAVDAEAEAEADADWMDTGDPTADAEADADSTENFYASFDTBCLDINBAOHFHYTPPKWYMSSNDKHKKNUOIELPDRKTOYHPCFCSWNFXPKFZNEPKVOIOCNAOAXMNPSKPLTGYFLRHLOHGUYKISWBWVEGUGMLAAYDLLDLSAAVDTDSADLIDFXYLKKFYURMTOXLKMDRSTYTERSJNHSBDPSGOGWJKJESTWLZCTKGE' ,
'UR:CRYPTO-PSBT/52-4/LPCSEEAACFAXPLCYZTVYVOPKHDWPPECPWPHNLBGMLDGOMWJYMDASCFYTOEGRTDGMZOCXFGFEGOSPBDSBISPKCNNYNBIORDRLRTRTHGAAHLGDFWJTVWCEYKGLVEIODSYKKNMSBGNYSAZEZEADGHSAAEAEAECPAMAXCSPLEHGDWFSAGETNWLPRECKOSKDWURMKMYSOASBEBDBNLBFMESCHZEVSJTJKDNADCEENTDROWFVYWEPDRNMDSNYKPMRYZMRLMNRYPAAYBKTDCLGDJKIYBNTYFXECMKWFLSWFWPCPGYBKEHSETTOECANTRHKGFGCLSROLMYLKNSOLHGGDHPOXWPMWCKLYETCLMWAMIDISHKKPJTWDHFPTECMOBALNDABSPTAXAEAELAAEADAEAELSAOGDPTAEAHFLGMCLAXDWPLAHBSMTLSHFPKRLMTIYLRYATNLGPLWFLYHFTOTLRDWZHKBWLAHNFNCPWTIMRFLUVYHLBWKBCXGYNLFYDPOL' ,
'UR:CRYPTO-PSBT/76-4/LPCSGSAACFAXPLCYZTVYVOPKHDWPBKEHRTTTFDCTNTRHKGFGCXSAHSRHWDMDTONBRLROWMSFCPBTHNTIAAGMPLAEAECPAOAXFXPSGMTABNWEIAJTHSCLAOSERKVLJKADWEBKTBBTRKJPTPYKMKLTMSRYRKDYPLLKCECMLGTBAXDYAEAELAAEAEAELAAEAEAELAAOAEAELAADAEAEAEAEAEAEAECPAOAXCSMYGWCMSGFWBTIENEOTRHHDFTVTLYTASNUYWZAMFSNLZSYLHGDKDWAYKBFYZTECCETEKBPMLODYAEAELAAEAEAELAAEAEAELAAOAEAELAADAEAEAEAEAEAEAEADADFLGMCLAXCSMYGWCMSGFWBTIENEOTRHHDFTVTLYTASNUYWZAMFSNLZSYLHGDKDWAYKBFYZTECCLAXFXPSGMTABNWEIAJTHSCLAOSERKVLJKADWEBKTBBTRKJPTPYKMKLTMSRYRKDYPLLKGMPLAEAEAEWLCMNTPF' ,
'UR:CRYPTO-PSBT/416-4/LPCFADNBAACFAXPLCYZTVYVOPKHDWPONBWDWPACLGTAEIDWLWZBAZODNCSMSEHZELBIYDLMWCSHDIADKNYWNZSSGPKVEFLMKLRKNCELEDAMYEMBYKIJKFNDEDMIAHPLBRDPMLTROWMFNWSLTROCMIOYKWPFZDSLGLGDKWSOYPFAHMODAMYENSAIOSEGAZEEHTSLBKGOEDMWZUTRFNYJEKIPEEMIYJSOTUEZERORFPSGRPABSSKLOGOONAECAGRSFBDLRWFEMLNSALRCWZOWNLPHNPTNSLPJTKBMTEYNSISTAFTEHSEGDOTENSNMHKNFGCLFXOXMYPLCELTKOMTNEGRTOJYGURHKGPMTAFHHKWPKIOTJPGWVSKNSKSSFTOYPTKKSGSRFGIORHMDDAFHNYKTHPCPOTKEGELANNLEWEGMJEKPIYGYSFECJNCWFNRYVLTBTBWPHTKBISTLRLDEMWADCWMNKTTARKDRJSZCJPLRCNFSHGNEGAMTYLVLGOWS' ,
2020-11-05 18:17:27 +01:00
] ;
2021-09-27 20:24:51 +02:00
for ( const ur of ursSignedByPassport ) {
2021-03-24 18:17:17 +01:00
// tapping 5 times invisible button is a backdoor:
2024-01-14 00:17:25 +01:00
await sleep ( 5000 ) ; // wait for camera screen to initialize
2020-11-19 15:33:18 +01:00
for ( let c = 0 ; c <= 5 ; c ++ ) {
2020-11-05 18:17:27 +01:00
await element ( by . id ( 'ScanQrBackdoorButton' ) ) . tap ( ) ;
}
await element ( by . id ( 'scanQrBackdoorInput' ) ) . replaceText ( ur ) ;
await element ( by . id ( 'scanQrBackdoorOkButton' ) ) . tap ( ) ;
await waitFor ( element ( by . id ( 'UrProgressBar' ) ) ) . toBeVisible ( ) ;
}
await waitFor ( element ( by . id ( 'ItemSigned' ) ) ) . toBeVisible ( ) ; // one green checkmark visible
await element ( by . id ( 'ProvideSignature' ) ) . tap ( ) ;
await element ( by . id ( 'CosignedScanOrImportFile' ) ) . tap ( ) ;
2021-09-27 20:24:51 +02:00
const urSignedByPassportAndKeystone = [
'UR:CRYPTO-PSBT/105-2/LPCSINAOCFAXOLCYSBLUFDHSHKADTEHKAXOTJOJKIDJYZMADAEKIAOAEAEAEADSGMHIEQDIAFLKPVABAJEHLLNVLRKKPCPDAHYNSOTTSOYBTIMMUCYAASSMDAMDAMKAEAEAEAEAEZMZMZMZMAOGDSRAEAEAEAEAEAECMAEBBKBOTLPWFGMRNINIMPFYNWLGEBAVTVLSWTYPAGEGUWFVLAEAEAEAEAEAECPAECXHEJTWTTTWEPDFMMDSNYKDPRYZMRLBARSPAAYLETDCLGDJKIHBNTYFXCHNNWTRHFEAEAEAEAEAEADAEWDAOAEAEAEAEADADSTENIYASISYLVDVLGWCXRPBWVYVSDALOTLCESKTTFEJTWDTBPTECMOMNLNDABSDTADAEAEAEAEADAEAELAAOGDPTADAEAEAEAEAECPAECXCLSWSSWSCPVTGTESFWSBCTCSETNSPYNLBKJLZTUEMWSOMSNNTYGSLSFPNEPKVOIOONMOAOAEAEAEAEAECMAEBBMNAMRTRKDYGUHDURWSVOLGDRRLESMEDLOLGWLYNTAOFLDYFYAOCXDYYTJOMYYAUELEDYKIYLADUROYFNURDRGLFTCYKEKEFEIAOYGSTNCPIDGYZOEEDAAOCXHGCAENYKHNJLGOHEJOGMRLBNTDWYGWJOPFPYFMKKTISROXGMIMGYURAYCXLEUOZSADCLAOJPBGWSASPTIATTPMLECMPRIHSTMDJYLOYKTKRTHHTLSTFZKPOYWKBKROASBGBAVDAEAEAEAEADADDNGDPTADAEAEAEAEAECPAECXCLSWSSWSCPVTGTESFWSBCTCSETNSPYNLBKJLZTUEMWSOMSNNTYGSLSFPNEPKVOIOCPAOAXFTRPWPCPGYBKEHRTTTFDCTNTRHKGFGCXSAHSRHWDMDTONBRLROWMSFCPBTHNTIAAFLDYFYAOCXISRERKHDRDGAPMATEHJLFL' ,
'UR:CRYPTO-PSBT/158-2/LPCSNNAOCFAXOLCYSBLUFDHSHKADTEZECFFTHDETNBADMOCLINLNOSOXZEYKGDPYTPKTRETNURTIZOPDAOCXIAAOWETTJKMDUOSBONAASWNLMERLZSGLCYCTGAKBDAFHGHWKMTRSNLAAYKFWWPRSADADAHFLGMCLAXBAPLDADMGDFLRHLOHGUYHESWEOSKMDMTJLDRTKSSRDFGDWSNTNCHZEVSJTJKDNCNCLAXFTRPWPCPGYBKEHRTTTFDCTNTRHKGFGCXSAHSRHWDMDTONBRLROWMSFCPBTHNTIAAGMPLCPAMAXBAPLDADMGDFLRHLOHGUYHESWEOSKMDMTJLDRTKSSRDFGDWSNTNCHZEVSJTJKDNCNCECMLGTBAXDYAEAELAAEAEAELAAEAEAELAAOAEAELAAEAEAEAEAXAEAEAECPAMAXFTRPWPCPGYBKEHRTTTFDCTNTRHKGFGCXSAHSRHWDMDTONBRLROWMSFCPBTHNTIAACETEKBPMLODYAEAELAAEAEAELAAEAEAELAAOAEAELAAEAEAEAEAXAEAEAEAEAEADADFLGMCLAXCSMYGWCMSGFWBTIENEOTRHHDFTVTLYTASNUYWZAMFSNLZSYLHGDKDWAYKBFYZTECCLAXFXPSGMTABNWEIAJTHSCLAOSERKVLJKADWEBKTBBTRKJPTPYKMKLTMSRYRKDYPLLKGMPLCPAOAXCSMYGWCMSGFWBTIENEOTRHHDFTVTLYTASNUYWZAMFSNLZSYLHGDKDWAYKBFYZTECCETEKBPMLODYAEAELAAEAEAELAAEAEAELAAOAEAELAADAEAEAEAEAEAEAECPAOAXFXPSGMTABNWEIAJTHSCLAOSERKVLJKADWEBKTBBTRKJPTPYKMKLTMSRYRKDYPLLKCECMLGTBAXDYAEAELAAEAEAELAAEAEAELAAOAEAELAADAEAEAEAEAEAEAEAENNHKLKUO' ,
2020-11-05 18:17:27 +01:00
] ;
2021-09-27 20:24:51 +02:00
for ( const ur of urSignedByPassportAndKeystone ) {
2021-03-24 18:17:17 +01:00
// tapping 5 times invisible button is a backdoor:
2024-01-14 00:17:25 +01:00
await sleep ( 5000 ) ; // wait for camera screen to initialize
2020-11-19 15:33:18 +01:00
for ( let c = 0 ; c <= 5 ; c ++ ) {
2020-11-05 18:17:27 +01:00
await element ( by . id ( 'ScanQrBackdoorButton' ) ) . tap ( ) ;
}
await element ( by . id ( 'scanQrBackdoorInput' ) ) . replaceText ( ur ) ;
await element ( by . id ( 'scanQrBackdoorOkButton' ) ) . tap ( ) ;
await waitFor ( element ( by . id ( 'UrProgressBar' ) ) ) . toBeVisible ( ) ;
}
await waitFor ( element ( by . id ( 'ExportSignedPsbt' ) ) ) . toBeVisible ( ) ;
await element ( by . id ( 'PsbtMultisigConfirmButton' ) ) . tap ( ) ;
// created. verifying:
await yo ( 'TransactionValue' ) ;
2021-12-26 09:11:07 +01:00
await expect ( element ( by . id ( 'TransactionValue' ) ) ) . toHaveText ( '0.0005' ) ;
2020-11-05 18:17:27 +01:00
await element ( by . id ( 'TransactionDetailsButton' ) ) . tap ( ) ;
const txhex = await extractTextFromElementById ( 'TxhexInput' ) ;
const transaction = bitcoin . Transaction . fromHex ( txhex ) ;
2021-09-27 20:24:51 +02:00
assert . ok ( transaction . ins . length === 1 ) ;
2020-11-05 18:17:27 +01:00
assert . strictEqual ( transaction . outs . length , 2 ) ;
assert . strictEqual ( bitcoin . address . fromOutputScript ( transaction . outs [ 0 ] . script ) , 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl' ) ; // to address
assert . strictEqual ( transaction . outs [ 0 ] . value , 50000 ) ;
2021-09-16 20:56:09 +02:00
await device . pressBack ( ) ;
await device . pressBack ( ) ;
await device . pressBack ( ) ;
await device . pressBack ( ) ;
await helperDeleteWallet ( expectedWalletLabel , '108880' ) ;
2020-11-05 18:17:27 +01:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
2020-08-11 20:16:24 +02:00
} ) ;
2020-11-04 17:24:39 +01:00
2021-09-23 15:05:10 +02:00
it ( 'can discover wallet account and import it' , async ( ) => {
2024-03-01 12:45:05 +01:00
const lockFile = '/tmp/travislock.' + hashIt ( 't7' ) ;
2021-07-20 16:36:44 +02:00
if ( process . env . TRAVIS ) {
2022-06-03 18:54:05 +02:00
if ( require ( 'fs' ) . existsSync ( lockFile ) ) return console . warn ( 'skipping' , JSON . stringify ( 't6' ) , 'as it previously passed on Travis' ) ;
2021-07-20 16:36:44 +02:00
}
2023-03-04 18:51:11 +01:00
await device . launchApp ( { newInstance : true } ) ;
2021-09-23 15:05:10 +02:00
await yo ( 'WalletsList' ) ;
// enable AdvancedMode to see derivation path in wallet details
await helperSwitchAdvancedMode ( ) ;
await element ( by . id ( 'WalletsList' ) ) . swipe ( 'left' , 'fast' , 1 ) ; // in case emu screen is small and it doesnt fit
2024-03-15 21:05:15 +01:00
await sleep ( 200 ) ; // Wait until bounce animation finishes.
2021-09-23 15:05:10 +02:00
// going to Import Wallet screen and importing mnemonic
await element ( by . id ( 'CreateAWallet' ) ) . tap ( ) ;
2023-11-22 05:25:37 +01:00
await element ( by . id ( 'ScrollView' ) ) . swipe ( 'up' , 'fast' , 0.9 ) ; // in case emu screen is small and it doesnt fit
2021-09-23 15:05:10 +02:00
await element ( by . id ( 'ImportWallet' ) ) . tap ( ) ;
await element ( by . id ( 'MnemonicInput' ) ) . replaceText (
2021-07-20 16:36:44 +02:00
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about' ,
) ;
2021-09-23 15:05:10 +02:00
await element ( by . id ( 'AskPassphrase' ) ) . tap ( ) ;
await element ( by . id ( 'SearchAccounts' ) ) . tap ( ) ;
await element ( by . id ( 'DoImport' ) ) . tap ( ) ;
await sleep ( 1000 ) ;
// cancel import and start over
await element ( by . text ( 'Cancel' ) ) . tap ( ) ;
await element ( by . id ( 'DoImport' ) ) . tap ( ) ;
await sleep ( 1000 ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
await waitFor ( element ( by . id ( 'Loading' ) ) ) // wait for discovery to be completed
. not . toExist ( )
. withTimeout ( 300 * 1000 ) ;
2021-07-20 16:36:44 +02:00
2021-09-23 15:05:10 +02:00
await expect ( element ( by . text ( "m/44'/0'/1'" ) ) ) . toBeVisible ( ) ;
await expect ( element ( by . text ( "m/49'/0'/0'" ) ) ) . toBeVisible ( ) ;
await expect ( element ( by . text ( "m/84'/0'/0'" ) ) ) . toBeVisible ( ) ;
// open custom derivation path screen and import the wallet
await element ( by . id ( 'CustomDerivationPathButton' ) ) . tap ( ) ;
await element ( by . id ( 'DerivationPathInput' ) ) . replaceText ( "m/44'/0'/1'" ) ;
2023-12-20 22:24:26 +01:00
await waitFor ( element ( by . text ( 'Found' ) ) ) // wait for discovery to be completed
2021-09-23 15:05:10 +02:00
. toExist ( )
. withTimeout ( 300 * 1000 ) ;
2023-12-20 22:24:26 +01:00
await element ( by . text ( 'Found' ) ) . tap ( ) ;
2021-09-23 15:05:10 +02:00
await element ( by . id ( 'ImportButton' ) ) . tap ( ) ;
await element ( by . text ( 'OK' ) ) . tap ( ) ;
2021-07-20 16:36:44 +02:00
2021-09-23 15:05:10 +02:00
// go to wallet and check derivation path
await element ( by . id ( 'Imported HD Legacy (BIP44 P2PKH)' ) ) . tap ( ) ;
await element ( by . id ( 'WalletDetails' ) ) . tap ( ) ;
await expect ( element ( by . id ( 'DerivationPath' ) ) ) . toHaveText ( "m/44'/0'/1'" ) ;
2021-07-20 16:36:44 +02:00
2021-09-16 20:56:09 +02:00
await device . pressBack ( ) ;
await device . pressBack ( ) ;
2021-09-23 15:05:10 +02:00
await helperDeleteWallet ( 'Imported HD Legacy (BIP44 P2PKH)' ) ;
await helperSwitchAdvancedMode ( ) ;
2021-09-16 20:56:09 +02:00
2021-07-20 16:36:44 +02:00
process . env . TRAVIS && require ( 'fs' ) . writeFileSync ( lockFile , '1' ) ;
} ) ;
2020-03-16 14:51:08 +01:00
} ) ;