Skip to content

Commit

Permalink
fix: ts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight committed Dec 15, 2023
1 parent 2f7d29b commit c17b381
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
16 changes: 8 additions & 8 deletions packages/integration-tests/tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -206,6 +205,7 @@ describe('Bridging ERC20 tokens', async function () {
);
const scope = await fuel_testToken.functions
.withdraw(paddedAddress)
.txParams(callsTxParams)
.callParams({
forward: {
amount: fuelTokenSenderBalance,
Expand Down
12 changes: 10 additions & 2 deletions packages/integration-tests/tests/bridge_erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions packages/integration-tests/tests/transfer_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/src/utils/fuels/relayCommonMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export async function relayCommonMessage(
relayer,
message,
messageRelayDetails,
txParams
txParams || {}
);

return relayer.sendTransaction(transaction);
Expand Down

0 comments on commit c17b381

Please sign in to comment.