From c17b381a14639c377313cea365d3d15e4269c2e3 Mon Sep 17 00:00:00 2001 From: LuizAsFight Date: Thu, 14 Dec 2023 23:19:48 -0300 Subject: [PATCH] fix: ts tests --- packages/integration-tests/tests/bridge_erc20.ts | 16 ++++++++-------- .../integration-tests/tests/bridge_erc721.ts | 12 ++++++++++-- packages/integration-tests/tests/transfer_eth.ts | 11 ++++++++--- .../src/utils/fuels/relayCommonMessage.ts | 2 +- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/integration-tests/tests/bridge_erc20.ts b/packages/integration-tests/tests/bridge_erc20.ts index 72efb4ef..56fc34b5 100644 --- a/packages/integration-tests/tests/bridge_erc20.ts +++ b/packages/integration-tests/tests/bridge_erc20.ts @@ -30,6 +30,11 @@ LOG_CONFIG.debug = false; const { expect } = chai; +const callsTxParams = { + gasLimit: bn(10_000), + gasPrice: FUEL_TX_PARAMS.gasPrice, +}; + describe('Bridging ERC20 tokens', async function () { // Timeout 6 minutes const DEFAULT_TIMEOUT_MS: number = 400_000; @@ -61,17 +66,11 @@ describe('Bridging ERC20 tokens', async function () { const { value: expectedTokenContractId } = await fuel_testToken.functions .bridged_token() - .txParams({ - gasLimit: bn(1_000), - gasPrice: FUEL_TX_PARAMS.gasPrice, - }) + .txParams(callsTxParams) .dryRun(); const { value: expectedGatewayContractId } = await fuel_testToken.functions .bridged_token_gateway() - .txParams({ - gasLimit: bn(1_000), - gasPrice: FUEL_TX_PARAMS.gasPrice, - }) + .txParams(callsTxParams) .dryRun(); // check that values for the test token and gateway contract match what @@ -206,6 +205,7 @@ describe('Bridging ERC20 tokens', async function () { ); const scope = await fuel_testToken.functions .withdraw(paddedAddress) + .txParams(callsTxParams) .callParams({ forward: { amount: fuelTokenSenderBalance, diff --git a/packages/integration-tests/tests/bridge_erc721.ts b/packages/integration-tests/tests/bridge_erc721.ts index 6f558516..a4dd82ec 100644 --- a/packages/integration-tests/tests/bridge_erc721.ts +++ b/packages/integration-tests/tests/bridge_erc721.ts @@ -19,7 +19,7 @@ import { import chai from 'chai'; import type { Wallet } from 'ethers'; import { BigNumber, utils } from 'ethers'; -import { Address, BN, InputType } from 'fuels'; +import { Address, BN, InputType, bn } from 'fuels'; import type { AbstractAddress, Contract, @@ -31,6 +31,11 @@ LOG_CONFIG.debug = false; const { expect } = chai; +const callsTxParams = { + gasLimit: bn(10_000), + gasPrice: FUEL_TX_PARAMS.gasPrice, +}; + const signerToHexTokenId = (signer: { address: string }) => { return utils.hexZeroPad(BigNumber.from(signer.address).toHexString(), 32); }; @@ -66,9 +71,11 @@ describe('Bridging ERC721 tokens', async function () { const { value: expectedTokenContractId } = await fuel_testToken.functions .bridged_token() + .txParams(callsTxParams) .dryRun(); const { value: expectedGatewayContractId } = await fuel_testToken.functions .bridged_token_gateway() + .txParams(callsTxParams) .dryRun(); // check that values for the test token and gateway contract match what @@ -168,7 +175,7 @@ describe('Bridging ERC721 tokens', async function () { FUEL_MESSAGE_TIMEOUT_MS ); expect(message).to.not.be.null; - const tx = await relayCommonMessage(env.fuel.deployer, message); + const tx = await relayCommonMessage(env.fuel.deployer, message, { ...FUEL_TX_PARAMS, maturity: undefined }); const result = await tx.waitForResult(); expect(result.status).to.equal('success'); @@ -200,6 +207,7 @@ describe('Bridging ERC721 tokens', async function () { '0x' + ethereumTokenReceiverAddress.slice(2).padStart(64, '0'); const scope = await fuel_testToken.functions .withdraw(paddedAddress) + .txParams(callsTxParams) .callParams({ forward: { amount: 1, diff --git a/packages/integration-tests/tests/transfer_eth.ts b/packages/integration-tests/tests/transfer_eth.ts index 308982b2..91653863 100644 --- a/packages/integration-tests/tests/transfer_eth.ts +++ b/packages/integration-tests/tests/transfer_eth.ts @@ -13,7 +13,7 @@ import { import chai from 'chai'; import type { BigNumber, Signer } from 'ethers'; import { parseEther } from 'ethers/lib/utils'; -import { Address, BN, BaseAssetId } from 'fuels'; +import { Address, BN, BaseAssetId, padFirst12BytesOfEvmAddress, bn } from 'fuels'; import type { AbstractAddress, WalletUnlocked as FuelWallet, @@ -22,6 +22,11 @@ import type { const { expect } = chai; +const callsTxParams = { + gasLimit: bn(10_000), + gasPrice: FUEL_TX_PARAMS.gasPrice, +}; + describe('Transferring ETH', async function () { // Timeout 6 minutes const DEFAULT_TIMEOUT_MS: number = 400_000; @@ -131,9 +136,9 @@ describe('Transferring ETH', async function () { it('Send ETH via OutputMessage', async () => { // withdraw ETH back to the base chain const fWithdrawTx = await fuelETHSender.withdrawToBaseLayer( - Address.fromString(ethereumETHReceiverAddress), + Address.fromString(padFirst12BytesOfEvmAddress(ethereumETHReceiverAddress)), fuels_parseEther(NUM_ETH), - FUEL_TX_PARAMS + callsTxParams ); const fWithdrawTxResult = await fWithdrawTx.waitForResult(); expect(fWithdrawTxResult.status).to.equal('success'); diff --git a/packages/test-utils/src/utils/fuels/relayCommonMessage.ts b/packages/test-utils/src/utils/fuels/relayCommonMessage.ts index 2ffc7591..307d35d7 100644 --- a/packages/test-utils/src/utils/fuels/relayCommonMessage.ts +++ b/packages/test-utils/src/utils/fuels/relayCommonMessage.ts @@ -171,7 +171,7 @@ export async function relayCommonMessage( relayer, message, messageRelayDetails, - txParams + txParams || {} ); return relayer.sendTransaction(transaction);