Skip to content

Commit

Permalink
chore: fix flaky contract tests (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight authored Nov 1, 2024
1 parent 448d6db commit 32dde0e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-tests-e2e-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
tests-e2e-contracts:
name: Test
runs-on: buildjet-8vcpu-ubuntu-2204
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pr-tests-e2e-crx-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
tests-e2e-crx-lock:
name: Test
runs-on: buildjet-8vcpu-ubuntu-2204
timeout-minutes: 5
timeout-minutes: 7
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
Expand Down Expand Up @@ -54,6 +54,3 @@ jobs:
name: playwright-app-crx-lock-report
path: packages/app/playwright-results
retention-days: 30

- name: Stop Test Node
run: pnpm node:clean
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test.describe('Forward Half Custom Asset', () => {
context,
page,
extensionId,
amountToFund: bn.parseUnits(forwardCustomAssetAmount, 1).mul(2),
amountToFund: bn.parseUnits('0.001'),
}));
});

Expand Down
7 changes: 6 additions & 1 deletion packages/e2e-contract-tests/playwright/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ export const testSetup = async ({
const randomMnemonic = Mnemonic.generate();
const fuelWallet = Wallet.fromMnemonic(randomMnemonic);
fuelWallet.connect(fuelProvider);
console.log(
`asd Master wallet sending funds(${bn(
amountToFund
).format()} ETH) to test wallet address`
);
const txResponse = await masterWallet.transfer(
fuelWallet.address,
bn(amountToFund)
);
await txResponse.waitForResult();
console.log('asd Success sending funds');

await page.pause();
const fuelWalletTestHelper = await FuelWalletTestHelper.walletSetup({
context,
fuelExtensionId: extensionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ export class FuelWalletTestHelper {
await popupNotSignedUpPage.goto(
`chrome-extension://${fuelExtensionId}/popup.html`
);
await popupNotSignedUpPage.waitForTimeout(2000);
await popupNotSignedUpPage.close();
const signupPage = await context.waitForEvent('page', {
predicate: (page) => page.url().includes('sign-up'),
});
expect(signupPage.url()).toContain('sign-up');
await popupNotSignedUpPage.close();

const importSeedPhraseButton = signupPage
.locator('h3')
Expand Down Expand Up @@ -85,11 +84,9 @@ export class FuelWalletTestHelper {
.getByText('Wallet created successfully')
.waitFor({ state: 'visible', timeout: 9000 });

await signupPage.pause();
await signupPage.goto(
`chrome-extension://${fuelExtensionId}/popup.html#/wallet`
);
await signupPage.pause();

const fuelWalletTestHelper = new FuelWalletTestHelper(context);

Expand Down
17 changes: 15 additions & 2 deletions packages/playwright-utils/src/playwright-utils/seedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,27 @@ export async function seedWallet(
const genesisWallet = Wallet.fromPrivateKey(genesisSecret!, fuelProvider);
const parameters: TxParamsType = { gasLimit: bn(100_000), ...options };
console.log(
`asd Seeding Master wallet (${amount.format()} ETH) from SECRET wallet`,
`asd SECRET wallet sending funds(${amount.format()} ETH) to Master wallet`,
genesisWallet.address.toString()
);
const response = await genesisWallet.transfer(

const transferPromise = genesisWallet.transfer(
Address.fromString(address),
amount,
baseAssetId,
parameters
);

const timeoutPromise = new Promise<never>((_, reject) => {
setTimeout(
() =>
reject(
new Error('Funding Master wallet did not complete after 10 seconds')
),
10000
);
});

const response = await Promise.race([transferPromise, timeoutPromise]);
await response.wait();
}

0 comments on commit 32dde0e

Please sign in to comment.