Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: increase Confirmations e2e stability by terminating ganache on hooks #7287

Merged
merged 3 commits into from
Sep 22, 2023
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
5 changes: 1 addition & 4 deletions e2e/fixtures/fixture-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,11 @@ export async function withFixtures(options, testSuite) {
await device.launchApp({ delete: true });
}

await testSuite({ contractRegistry });
await testSuite({ contractRegistry, ganacheServer });
seaona marked this conversation as resolved.
Show resolved Hide resolved
} 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) {
Expand Down
13 changes: 10 additions & 3 deletions e2e/specs/confirmations/advanced-gas-fees.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,33 @@ 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
seaona marked this conversation as resolved.
Show resolved Hide resolved
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(
{
fixture: new FixtureBuilder().withGanacheNetwork().build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

// Check that we are on the wallet screen
Expand Down
9 changes: 8 additions & 1 deletion e2e/specs/confirmations/send-erc721.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
{
Expand All @@ -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,
);
Expand Down
12 changes: 9 additions & 3 deletions e2e/specs/confirmations/send-eth-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,28 @@ 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(
{
fixture: new FixtureBuilder().withGanacheNetwork().build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapActions();
Expand Down
12 changes: 9 additions & 3 deletions e2e/specs/confirmations/send-eth-multisig.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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,
);
Expand Down
36 changes: 26 additions & 10 deletions e2e/specs/confirmations/sign-messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -32,7 +38,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -59,7 +66,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -86,7 +94,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -113,7 +122,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -140,7 +150,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -167,7 +178,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -194,7 +206,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand All @@ -221,7 +234,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand Down Expand Up @@ -253,7 +267,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand Down Expand Up @@ -285,7 +300,8 @@ describe(Regression('Sign Messages'), () => {
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
async ({ ganacheServer }) => {
ganache = ganacheServer;
await loginToApp();

await TabBarComponent.tapBrowser();
Expand Down