From ad4d7c34d862b2034da4cb5f371f13bb676d7edb Mon Sep 17 00:00:00 2001 From: seaona Date: Thu, 21 Sep 2023 15:27:39 +0200 Subject: [PATCH 1/3] move ganache.quit to hooks to increase stability --- e2e/fixtures/fixture-helper.js | 5 +-- .../confirmations/advanced-gas-fees.spec.js | 13 +++++-- e2e/specs/confirmations/send-erc721.spec.js | 9 ++++- e2e/specs/confirmations/send-eth-flow.spec.js | 12 +++++-- .../confirmations/send-eth-multisig.spec.js | 12 +++++-- e2e/specs/confirmations/sign-messages.spec.js | 36 +++++++++++++------ 6 files changed, 63 insertions(+), 24 deletions(-) diff --git a/e2e/fixtures/fixture-helper.js b/e2e/fixtures/fixture-helper.js index 7fc94a8d781..829bb72e382 100644 --- a/e2e/fixtures/fixture-helper.js +++ b/e2e/fixtures/fixture-helper.js @@ -147,14 +147,11 @@ export async function withFixtures(options, testSuite) { await device.launchApp({ delete: true }); } - await testSuite({ contractRegistry }); + await testSuite({ contractRegistry, ganacheServer }); } catch (error) { console.error(error); throw error; } finally { - if (ganacheOptions) { - await ganacheServer.quit(); - } if (dapp) { for (let i = 0; i < numberOfDapps; i++) { if (dappServer[i] && dappServer[i].listening) { diff --git a/e2e/specs/confirmations/advanced-gas-fees.spec.js b/e2e/specs/confirmations/advanced-gas-fees.spec.js index 1027967e2a9..155d22f7062 100644 --- a/e2e/specs/confirmations/advanced-gas-fees.spec.js +++ b/e2e/specs/confirmations/advanced-gas-fees.spec.js @@ -12,18 +12,24 @@ import { } from '../../fixtures/fixture-helper'; import TabBarComponent from '../../pages/TabBarComponent'; import WalletActionsModal from '../../pages/modals/WalletActionsModal'; +import TestHelpers from '../../helpers'; const VALID_ADDRESS = '0xebe6CcB6B55e1d094d9c58980Bc10Fed69932cAb'; describe(Smoke('Advanced Gas Fees and Priority Tests'), () => { + let ganache; beforeAll(async () => { jest.setTimeout(170000); if (device.getPlatform() === 'android') { - await device.reverseTcpPort('8081'); // because on android we need to expose the localhost ports to run ganache - await device.reverseTcpPort('8545'); + await device.reverseTcpPort('8545'); // ganache } }); + afterEach(async () => { + await ganache.quit(); + await TestHelpers.delay(3000); + }); + it('should edit priority gas settings and send ETH', async () => { await withFixtures( { @@ -31,7 +37,8 @@ describe(Smoke('Advanced Gas Fees and Priority Tests'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); // Check that we are on the wallet screen diff --git a/e2e/specs/confirmations/send-erc721.spec.js b/e2e/specs/confirmations/send-erc721.spec.js index f026b35c3ef..71f4d370d07 100644 --- a/e2e/specs/confirmations/send-erc721.spec.js +++ b/e2e/specs/confirmations/send-erc721.spec.js @@ -16,6 +16,7 @@ import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; describe(Regression('ERC721 tokens'), () => { const NFT_CONTRACT = SMART_CONTRACTS.NFTS; const SENT_COLLECTIBLE_MESSAGE_TEXT = root.transactions.sent_collectible; + let ganache; beforeAll(async () => { jest.setTimeout(150000); @@ -25,6 +26,11 @@ describe(Regression('ERC721 tokens'), () => { } }); + afterEach(async () => { + await ganache.quit(); + await TestHelpers.delay(3000); + }); + it('send an ERC721 token from a dapp', async () => { await withFixtures( { @@ -37,7 +43,8 @@ describe(Regression('ERC721 tokens'), () => { ganacheOptions: defaultGanacheOptions, smartContract: NFT_CONTRACT, }, - async ({ contractRegistry }) => { + async ({ contractRegistry, ganacheServer }) => { + ganache = ganacheServer; const nftsAddress = await contractRegistry.getContractAddress( NFT_CONTRACT, ); diff --git a/e2e/specs/confirmations/send-eth-flow.spec.js b/e2e/specs/confirmations/send-eth-flow.spec.js index 90e073bd722..e2dd2008031 100644 --- a/e2e/specs/confirmations/send-eth-flow.spec.js +++ b/e2e/specs/confirmations/send-eth-flow.spec.js @@ -17,14 +17,19 @@ import WalletActionsModal from '../../pages/modals/WalletActionsModal'; const MYTH_ADDRESS = '0x1FDb169Ef12954F20A15852980e1F0C122BfC1D6'; describe(Regression('Send ETH Tests'), () => { + let ganache; beforeAll(async () => { jest.setTimeout(150000); if (device.getPlatform() === 'android') { - await device.reverseTcpPort('8081'); // because on android we need to expose the localhost ports to run ganache - await device.reverseTcpPort('8545'); + await device.reverseTcpPort('8545'); // ganache } }); + afterEach(async () => { + await ganache.quit(); + await TestHelpers.delay(3000); + }); + it('should send ETH to an EOA', async () => { await withFixtures( { @@ -32,7 +37,8 @@ describe(Regression('Send ETH Tests'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapActions(); diff --git a/e2e/specs/confirmations/send-eth-multisig.spec.js b/e2e/specs/confirmations/send-eth-multisig.spec.js index 3d746419c4d..99ddde24fa6 100644 --- a/e2e/specs/confirmations/send-eth-multisig.spec.js +++ b/e2e/specs/confirmations/send-eth-multisig.spec.js @@ -21,15 +21,20 @@ describe(Regression('Send ETH to Multisig'), () => { const MULTISIG_CONTRACT = SMART_CONTRACTS.MULTISIG; const AMOUNT_TO_SEND = '0.12345'; const TOKEN_NAME = root.unit.eth; + let ganache; beforeAll(async () => { jest.setTimeout(2500000); if (device.getPlatform() === 'android') { - await device.reverseTcpPort('8081'); // because on android we need to expose the localhost ports to run ganache - await device.reverseTcpPort('8545'); + await device.reverseTcpPort('8545'); // ganache } }); + afterEach(async () => { + await ganache.quit(); + await TestHelpers.delay(3000); + }); + it('Send ETH to a Multisig address from inside MetaMask wallet', async () => { await withFixtures( { @@ -38,7 +43,8 @@ describe(Regression('Send ETH to Multisig'), () => { ganacheOptions: defaultGanacheOptions, smartContract: MULTISIG_CONTRACT, }, - async ({ contractRegistry }) => { + async ({ contractRegistry, ganacheServer }) => { + ganache = ganacheServer; const multisigAddress = await contractRegistry.getContractAddress( MULTISIG_CONTRACT, ); diff --git a/e2e/specs/confirmations/sign-messages.spec.js b/e2e/specs/confirmations/sign-messages.spec.js index 8567d8b826a..5d6d292c484 100644 --- a/e2e/specs/confirmations/sign-messages.spec.js +++ b/e2e/specs/confirmations/sign-messages.spec.js @@ -15,12 +15,18 @@ import TestHelpers from '../../helpers'; const MAX_ATTEMPTS = 3; describe(Regression('Sign Messages'), () => { + let ganache; beforeAll(async () => { jest.setTimeout(150000); await device.reverseTcpPort('8545'); // ganache await device.reverseTcpPort('8080'); // test-dapp }); + afterEach(async () => { + await ganache.quit(); + await TestHelpers.delay(3000); + }); + it('should sign personal message', async () => { await withFixtures( { @@ -32,7 +38,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -59,7 +66,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -86,7 +94,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -113,7 +122,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -140,7 +150,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -167,7 +178,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -194,7 +206,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -221,7 +234,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -253,7 +267,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); @@ -285,7 +300,8 @@ describe(Regression('Sign Messages'), () => { restartDevice: true, ganacheOptions: defaultGanacheOptions, }, - async () => { + async ({ ganacheServer }) => { + ganache = ganacheServer; await loginToApp(); await TabBarComponent.tapBrowser(); From 50a81fa8b3b7c090f6bf45fcd75178f550aecb40 Mon Sep 17 00:00:00 2001 From: seaona Date: Thu, 21 Sep 2023 15:29:03 +0200 Subject: [PATCH 2/3] temp make Confirm. e2e smoke so we run ci --- e2e/specs/confirmations/send-erc721.spec.js | 4 ++-- e2e/specs/confirmations/send-eth-flow.spec.js | 4 ++-- e2e/specs/confirmations/send-eth-multisig.spec.js | 4 ++-- e2e/specs/confirmations/sign-messages.spec.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/specs/confirmations/send-erc721.spec.js b/e2e/specs/confirmations/send-erc721.spec.js index 71f4d370d07..3ce2495a548 100644 --- a/e2e/specs/confirmations/send-erc721.spec.js +++ b/e2e/specs/confirmations/send-erc721.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import { Regression } from '../../tags'; +import { Smoke } from '../../tags'; import TestHelpers from '../../helpers'; import { loginToApp } from '../../viewHelper'; import TabBarComponent from '../../pages/TabBarComponent'; @@ -13,7 +13,7 @@ import { import root from '../../../locales/languages/en.json'; import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; -describe(Regression('ERC721 tokens'), () => { +describe(Smoke('ERC721 tokens'), () => { const NFT_CONTRACT = SMART_CONTRACTS.NFTS; const SENT_COLLECTIBLE_MESSAGE_TEXT = root.transactions.sent_collectible; let ganache; diff --git a/e2e/specs/confirmations/send-eth-flow.spec.js b/e2e/specs/confirmations/send-eth-flow.spec.js index e2dd2008031..03eeb3e5cc0 100644 --- a/e2e/specs/confirmations/send-eth-flow.spec.js +++ b/e2e/specs/confirmations/send-eth-flow.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import { Regression } from '../../tags'; +import { Smoke } from '../../tags'; import TestHelpers from '../../helpers'; import AmountView from '../../pages/AmountView'; import SendView from '../../pages/SendView'; @@ -16,7 +16,7 @@ import WalletActionsModal from '../../pages/modals/WalletActionsModal'; const MYTH_ADDRESS = '0x1FDb169Ef12954F20A15852980e1F0C122BfC1D6'; -describe(Regression('Send ETH Tests'), () => { +describe(Smoke('Send ETH Tests'), () => { let ganache; beforeAll(async () => { jest.setTimeout(150000); diff --git a/e2e/specs/confirmations/send-eth-multisig.spec.js b/e2e/specs/confirmations/send-eth-multisig.spec.js index 99ddde24fa6..16c64026794 100644 --- a/e2e/specs/confirmations/send-eth-multisig.spec.js +++ b/e2e/specs/confirmations/send-eth-multisig.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import { Regression } from '../../tags'; +import { Smoke } from '../../tags'; import TestHelpers from '../../helpers'; import AmountView from '../../pages/AmountView'; @@ -17,7 +17,7 @@ import { } from '../../fixtures/fixture-helper'; import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; -describe(Regression('Send ETH to Multisig'), () => { +describe(Smoke('Send ETH to Multisig'), () => { const MULTISIG_CONTRACT = SMART_CONTRACTS.MULTISIG; const AMOUNT_TO_SEND = '0.12345'; const TOKEN_NAME = root.unit.eth; diff --git a/e2e/specs/confirmations/sign-messages.spec.js b/e2e/specs/confirmations/sign-messages.spec.js index 5d6d292c484..65a0f87d525 100644 --- a/e2e/specs/confirmations/sign-messages.spec.js +++ b/e2e/specs/confirmations/sign-messages.spec.js @@ -9,12 +9,12 @@ import { withFixtures, defaultGanacheOptions, } from '../../fixtures/fixture-helper'; -import { Regression } from '../../tags'; +import { Smoke } from '../../tags'; import TestHelpers from '../../helpers'; const MAX_ATTEMPTS = 3; -describe(Regression('Sign Messages'), () => { +describe(Smoke('Sign Messages'), () => { let ganache; beforeAll(async () => { jest.setTimeout(150000); From a274ebe68db40df3df5349b423a4260710b398e9 Mon Sep 17 00:00:00 2001 From: seaona Date: Thu, 21 Sep 2023 19:22:50 +0200 Subject: [PATCH 3/3] Remove Smoke tag to tests --- e2e/specs/confirmations/send-erc721.spec.js | 4 ++-- e2e/specs/confirmations/send-eth-flow.spec.js | 4 ++-- e2e/specs/confirmations/send-eth-multisig.spec.js | 4 ++-- e2e/specs/confirmations/sign-messages.spec.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/specs/confirmations/send-erc721.spec.js b/e2e/specs/confirmations/send-erc721.spec.js index 3ce2495a548..71f4d370d07 100644 --- a/e2e/specs/confirmations/send-erc721.spec.js +++ b/e2e/specs/confirmations/send-erc721.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import { Smoke } from '../../tags'; +import { Regression } from '../../tags'; import TestHelpers from '../../helpers'; import { loginToApp } from '../../viewHelper'; import TabBarComponent from '../../pages/TabBarComponent'; @@ -13,7 +13,7 @@ import { import root from '../../../locales/languages/en.json'; import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; -describe(Smoke('ERC721 tokens'), () => { +describe(Regression('ERC721 tokens'), () => { const NFT_CONTRACT = SMART_CONTRACTS.NFTS; const SENT_COLLECTIBLE_MESSAGE_TEXT = root.transactions.sent_collectible; let ganache; diff --git a/e2e/specs/confirmations/send-eth-flow.spec.js b/e2e/specs/confirmations/send-eth-flow.spec.js index 03eeb3e5cc0..e2dd2008031 100644 --- a/e2e/specs/confirmations/send-eth-flow.spec.js +++ b/e2e/specs/confirmations/send-eth-flow.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import { Smoke } from '../../tags'; +import { Regression } from '../../tags'; import TestHelpers from '../../helpers'; import AmountView from '../../pages/AmountView'; import SendView from '../../pages/SendView'; @@ -16,7 +16,7 @@ import WalletActionsModal from '../../pages/modals/WalletActionsModal'; const MYTH_ADDRESS = '0x1FDb169Ef12954F20A15852980e1F0C122BfC1D6'; -describe(Smoke('Send ETH Tests'), () => { +describe(Regression('Send ETH Tests'), () => { let ganache; beforeAll(async () => { jest.setTimeout(150000); diff --git a/e2e/specs/confirmations/send-eth-multisig.spec.js b/e2e/specs/confirmations/send-eth-multisig.spec.js index 16c64026794..99ddde24fa6 100644 --- a/e2e/specs/confirmations/send-eth-multisig.spec.js +++ b/e2e/specs/confirmations/send-eth-multisig.spec.js @@ -1,6 +1,6 @@ 'use strict'; -import { Smoke } from '../../tags'; +import { Regression } from '../../tags'; import TestHelpers from '../../helpers'; import AmountView from '../../pages/AmountView'; @@ -17,7 +17,7 @@ import { } from '../../fixtures/fixture-helper'; import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; -describe(Smoke('Send ETH to Multisig'), () => { +describe(Regression('Send ETH to Multisig'), () => { const MULTISIG_CONTRACT = SMART_CONTRACTS.MULTISIG; const AMOUNT_TO_SEND = '0.12345'; const TOKEN_NAME = root.unit.eth; diff --git a/e2e/specs/confirmations/sign-messages.spec.js b/e2e/specs/confirmations/sign-messages.spec.js index 65a0f87d525..5d6d292c484 100644 --- a/e2e/specs/confirmations/sign-messages.spec.js +++ b/e2e/specs/confirmations/sign-messages.spec.js @@ -9,12 +9,12 @@ import { withFixtures, defaultGanacheOptions, } from '../../fixtures/fixture-helper'; -import { Smoke } from '../../tags'; +import { Regression } from '../../tags'; import TestHelpers from '../../helpers'; const MAX_ATTEMPTS = 3; -describe(Smoke('Sign Messages'), () => { +describe(Regression('Sign Messages'), () => { let ganache; beforeAll(async () => { jest.setTimeout(150000);