Skip to content

Commit

Permalink
fix: enable e2e contract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight committed Oct 28, 2024
1 parent 9e71031 commit acc8d98
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 90 deletions.
8 changes: 3 additions & 5 deletions docker/fuel-core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# We should be supporting always the same fuel-core version as the fuels (ts-sdk)
# https://github.com/FuelLabs/fuels-ts/blob/master/internal/fuel-core/VERSION
FROM ghcr.io/fuellabs/fuel-core:v0.39.0
FROM ghcr.io/fuellabs/fuel-core:v0.40.0

# dependencies
ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -19,17 +19,15 @@ COPY ./genesis_coins.json .

RUN git clone \
https://github.com/FuelLabs/chain-configuration.git \
/chain-configuration && \
cd /chain-configuration && \
git checkout 0dc0960f14da7b6650b5438dc1e99d7ff7acec73
/chain-configuration

# Copy the base local configuration
RUN cp -R /chain-configuration/local/* ./

# Copy the testnet consensus parameters and state transition bytecode
RUN cp /chain-configuration/upgradelog/ignition-devnet/consensus_parameters/13.json \
./latest_consensus_parameters.json
RUN cp /chain-configuration/upgradelog/ignition-devnet/state_transition_function/15.wasm \
RUN cp /chain-configuration/upgradelog/ignition-devnet/state_transition_function/16.wasm \
./state_transition_bytecode.wasm

# update local state_config with custom genesis coins config
Expand Down
2 changes: 1 addition & 1 deletion packages/connections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"uuid": "^9.0.1"
},
"peerDependencies": {
"fuels": "0.95.0"
"fuels": "0.96.1"
},
"devDependencies": {
"@fuel-wallet/types": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe('Deposit Half ETH', () => {

const depositHalfInput = page
.getByLabel('Deposit half eth card')
.locator('input');
.getByRole('textbox');
await depositHalfInput.fill(depositAmount);

const depositHalfButton = getButtonByText(page, 'Deposit Half ETH', true);
Expand Down Expand Up @@ -96,15 +96,14 @@ test.describe('Deposit Half ETH', () => {
// });

// test to and from addresses
const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,14 @@ test.describe('Forward and Mint Multicall', () => {
// maxFee: fee.add(100),
// });

const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ test.describe('Forward Custom Asset', () => {
};
const { waitForResult } = await contract.functions
.mint(recipient, await getBaseAssetId(), bn(100_000_000_000))
.txParams({ gasLimit: 1_000_000 })
.call();

await waitForResult();
Expand All @@ -68,7 +67,7 @@ test.describe('Forward Custom Asset', () => {
const formattedForwardCustomAssetAmount = '12,345';
const forwardCustomAssetInput = page
.getByLabel('Forward custom asset card')
.locator('input');
.getByRole('textbox');
await forwardCustomAssetInput.fill(forwardCustomAssetAmount);

const forwardCustomAssetButton = getButtonByText(
Expand Down Expand Up @@ -107,10 +106,9 @@ test.describe('Forward Custom Asset', () => {
// maxFee: fee.add(100),
// });

const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);

Expand Down
7 changes: 3 additions & 4 deletions packages/e2e-contract-tests/playwright/e2e/ForwardEth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test.describe('Forward Eth', () => {

const forwardEthInput = page
.getByLabel('Forward eth card')
.locator('input');
.getByRole('textbox');
await forwardEthInput.fill(forwardEthAmount);

const forwardEthButton = getButtonByText(page, 'Forward ETH');
Expand Down Expand Up @@ -85,10 +85,9 @@ test.describe('Forward Eth', () => {
// });

// test to and from addresses
const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,21 @@ test.describe('Forward Half ETH and Mint External Custom Asset', () => {
// maxFee: fee.add(100),
// });

const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: toBech32(EXTERNAL_CONTRACT_ID), isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: EXTERNAL_CONTRACT_ID, isContract: true },
walletNotificationPage,
1,
1
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,14 @@ test.describe('Forward Half ETH and Mint Custom Asset', () => {
// });

// test to and from addresses
const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ test.describe('Forward Half Custom Asset', () => {
const assetId = calculateAssetId(MAIN_CONTRACT_ID, await getBaseAssetId());
const { waitForResult } = await contract.functions
.mint(recipient, await getBaseAssetId(), bn(100_000_000_000))
.txParams({ gasLimit: 1_000_000 })
.call();

await waitForResult();

const forwardHalfCustomAssetInput = page
.getByLabel('Forward half custom asset card')
.locator('input');
.getByRole('textbox');
await forwardHalfCustomAssetInput.fill(forwardCustomAssetAmount);

const forwardHalfCustomAssetButton = getButtonByText(
Expand Down Expand Up @@ -117,15 +116,14 @@ test.describe('Forward Half Custom Asset', () => {
// });

// test to and from addresses
const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down
20 changes: 9 additions & 11 deletions packages/e2e-contract-tests/playwright/e2e/MintAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test.describe('Mint Assets', () => {

const mintAmount = '12345';
const formattedMintAmount = '12,345';
const mintInput = page.getByLabel('Mint asset card').locator('input');
const mintInput = page.getByLabel('Mint asset card').getByRole('textbox');
await mintInput.fill(mintAmount);

const mintButton = getButtonByText(page, 'Mint', true);
Expand All @@ -75,15 +75,14 @@ test.describe('Mint Assets', () => {
// maxFee: fee.add(100),
// });

const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down Expand Up @@ -157,15 +156,14 @@ test.describe('Mint Assets', () => {
// });

// test to and from addresses
const fuelContractId = toBech32(MAIN_CONTRACT_ID);
await checkAddresses(
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
walletNotificationPage
);
await checkAddresses(
{ address: fuelContractId, isContract: true },
{ address: fuelWallet.address.toAddress(), isContract: false },
{ address: MAIN_CONTRACT_ID, isContract: true },
{ address: fuelWallet.address.toString(), isContract: false },
walletNotificationPage
);

Expand Down
11 changes: 4 additions & 7 deletions packages/e2e-contract-tests/playwright/e2e/utils/address.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { Address, type Bech32Address } from 'fuels';
import { Address } from 'fuels';

import { shortAddress } from '../../../src/utils';

Expand All @@ -22,9 +22,8 @@ export const checkAddresses = async (
hasNotText: 'To',
})
.nth(fromPosition);
const fromShortAddress = shortAddress(
Address.fromDynamicInput(from.address).toB256()
);

const fromShortAddress = shortAddress(from.address);
const fromAddressText = fromArticle
.getByRole('paragraph')
.getByText(fromShortAddress, { exact: true });
Expand All @@ -43,9 +42,7 @@ export const checkAddresses = async (
hasNotText: 'From',
})
.nth(toPosition);
const toShortAddress = shortAddress(
Address.fromDynamicInput(to.address).toB256()
);
const toShortAddress = shortAddress(to.address);
const toAddressText = toArticle
.getByRole('paragraph')
.getByText(toShortAddress, { exact: true });
Expand Down
2 changes: 2 additions & 0 deletions packages/e2e-contract-tests/playwright/e2e/utils/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export const connect = async (
await connectButton.click();
await getByAriaLabel(page, `Connect to ${walletName}`, true).click();
await fuelWalletTestHelper.walletConnect();

await page.waitForTimeout(3000);
};
2 changes: 2 additions & 0 deletions packages/e2e-contract-tests/playwright/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const testSetup = async ({
const fuelProvider = await Provider.create(VITE_FUEL_PROVIDER_URL!);
const masterWallet = Wallet.fromMnemonic(VITE_MASTER_WALLET_MNEMONIC!);
masterWallet.connect(fuelProvider);

console.log('--- Master wallet address:', masterWallet.address.toString());
if (VITE_WALLET_SECRET) {
await seedWallet(
masterWallet.address.toString(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* THIS FILE WAS EDITED MANUALLY TO REMOVE THE "declare" OCCURRENCES BREAKING PLAYWRIGHT TESTS */
/* Autogenerated file. Do not edit manually. */

/* eslint-disable max-classes-per-file */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/consistent-type-imports */

/*
Fuels version: 0.95.0
Fuels version: 0.96.0
Forc version: 0.65.2
Fuel-Core version: 0.37.1
Fuel-Core version: 0.38.0
*/

import { Contract, Interface } from "fuels";
Expand Down Expand Up @@ -517,11 +516,14 @@ export class CustomAssetInterface extends Interface {
constructor() {
super(abi);
}

}

export class CustomAsset extends Contract {
static readonly abi = abi;
static readonly storageSlots = storageSlots;


constructor(
id: string | AbstractAddress,
accountOrProvider: Account | Provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */

/*
Fuels version: 0.95.0
Fuels version: 0.96.0
Forc version: 0.65.2
Fuel-Core version: 0.37.1
Fuel-Core version: 0.38.0
*/

import { Contract, ContractFactory, decompressBytecode } from "fuels";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */

/*
Fuels version: 0.95.0
Fuels version: 0.96.0
Forc version: 0.65.2
Fuel-Core version: 0.37.1
Fuel-Core version: 0.38.0
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-contract-tests/src/contracts/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
/* eslint-disable @typescript-eslint/consistent-type-imports */

/*
Fuels version: 0.95.0
Fuels version: 0.96.0
Forc version: 0.65.2
Fuel-Core version: 0.37.1
Fuel-Core version: 0.38.0
*/

export { CustomAsset } from './CustomAsset';
Expand Down
Loading

0 comments on commit acc8d98

Please sign in to comment.