Skip to content

Commit

Permalink
TST: speed up travis reruns
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed May 23, 2020
1 parent 222eb1c commit f37cdd0
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion tests/e2e/bluewallet.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/* global it, describe, expect, element, by, waitFor, device */
/* global it, describe, expect, element, by, waitFor, device, jasmine */

const bitcoin = require('bitcoinjs-lib');
const assert = require('assert');
const createHash = require('create-hash');

jasmine.getEnv().addReporter({
specStarted: result => (jasmine.currentTest = result),
specDone: result => (jasmine.currentTest = result),
});

describe('BlueWallet UI Tests', () => {
it('selftest passes', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
await waitFor(element(by.id('WalletsList')))
.toBeVisible()
.withTimeout(300 * 1000);
Expand All @@ -17,19 +28,31 @@ describe('BlueWallet UI Tests', () => {
await waitFor(element(by.id('SelfTestOk')))
.toBeVisible()
.withTimeout(300 * 1000);
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});

it('can create wallet, reload app and it persists', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
await yo('WalletsList');

await helperCreateWallet();

await device.launchApp({ newInstance: true });
await yo('WalletsList');
await expect(element(by.id('cr34t3d'))).toBeVisible();
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});

it('can encrypt storage, with plausible deniability', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
await yo('WalletsList');

// lets create a wallet
Expand Down Expand Up @@ -162,9 +185,15 @@ describe('BlueWallet UI Tests', () => {

// previously created wallet in FAKE storage should be visible
await expect(element(by.id('fake_wallet'))).toBeVisible();
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});

it('can encrypt storage, and decrypt storage works', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
await yo('WalletsList');
await helperCreateWallet();
await element(by.id('SettingsButton')).tap();
Expand Down Expand Up @@ -232,9 +261,15 @@ describe('BlueWallet UI Tests', () => {
// relaunch app
await device.launchApp({ newInstance: true });
await yo('cr34t3d'); // success
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});

it.skip('can encrypt storage, and decrypt storage, but this time the fake one', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
// this test mostly repeats previous one, except in the end it logins with FAKE password to unlock FAKE
// storage bucket, and then decrypts it. effectively, everything from MAIN storage bucket is lost
if (process.env.TRAVIS) return; // skipping on CI to not take time (plus it randomly fails)
Expand Down Expand Up @@ -305,9 +340,15 @@ describe('BlueWallet UI Tests', () => {
// relaunch app
await device.launchApp({ newInstance: true });
await yo('fake_wallet'); // success, we are observing wallet in FAKE storage. wallet from main storage is lost
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});

it('can import BIP84 mnemonic, fetch balance & transactions, then create a transaction', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
if (!process.env.HD_MNEMONIC_BIP84) {
console.error('process.env.HD_MNEMONIC_BIP84 not set, skipped');
return;
Expand Down Expand Up @@ -361,9 +402,15 @@ describe('BlueWallet UI Tests', () => {
assert.strictEqual(transaction.outs.length, 2);
assert.strictEqual(bitcoin.address.fromOutputScript(transaction.outs[0].script), 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl'); // to address
assert.strictEqual(transaction.outs[0].value, 10000);
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});

it('can import zpub as watch-only and create PSBT', async () => {
const lockFile = '/tmp/travislock.' + hashIt(jasmine.currentTest.fullName);
if (process.env.TRAVIS) {
if (require('fs').existsSync(lockFile))
return console.warn('skipping', jasmine.currentTest.fullName, 'as it previously passed on Travis');
}
await helperImportWallet(
'zpub6r7jhKKm7BAVx3b3nSnuadY1WnshZYkhK8gKFoRLwK9rF3Mzv28BrGcCGA3ugGtawi1WLb2vyjQAX9ZTDGU5gNk2bLdTc3iEXr6tzR1ipNP',
'Imported Watch-only',
Expand All @@ -381,6 +428,7 @@ describe('BlueWallet UI Tests', () => {
} catch (_) {}

await yo('TextHelperForPSBT');
process.env.TRAVIS && require('fs').writeFileSync(lockFile, '1');
});
});

Expand Down Expand Up @@ -438,3 +486,10 @@ async function helperImportWallet(importText, expectedWalletLabel, expectedBalan
// label might change in the future
expect(element(by.id('WalletBalance'))).toHaveText(expectedBalance);
}

function hashIt(s) {
return createHash('sha256')
.update(s)
.digest()
.toString('hex');
}

0 comments on commit f37cdd0

Please sign in to comment.