Skip to content

Commit

Permalink
chore: debug gas limit issue in test
Browse files Browse the repository at this point in the history
  • Loading branch information
viraj124 committed Jan 21, 2025
1 parent f253050 commit 3dc09e0
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions packages/integration-tests/tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Address, BN } from 'fuels';
import type {
AbstractAddress,
WalletUnlocked as FuelWallet,
MessageCoin,
MessageProof,
ScriptTransactionRequest,
} from 'fuels';
Expand Down Expand Up @@ -86,34 +87,32 @@ describe('Bridging ERC20 tokens', async function () {
},
});

const cost = await tx.getTransactionCost();

// message coin resource
const resources = await fuelTokenSender.getResourcesToSpend([
[fuels_parseEther('1'), env.fuel.provider.getBaseAssetId()],
]);

expect(resources.length === 1);
const incomingMessagesonFuel = await env.fuel.signers[0].getMessages();

const messageCoin: any = resources[0];
const messageCoin: MessageCoin = {
assetId: env.fuel.provider.getBaseAssetId(),
sender: incomingMessagesonFuel.messages[0].sender,
recipient: incomingMessagesonFuel.messages[0].recipient,
nonce: incomingMessagesonFuel.messages[0].nonce,
daHeight: incomingMessagesonFuel.messages[0].daHeight,
amount: incomingMessagesonFuel.messages[0].amount,
};

// making sure resource is of Message Coin type and DA Height is non zero
expect(messageCoin.daHeight > new BN(0));

const transactionRequest = await tx.getTransactionRequest();

// add message coin input
await transactionRequest.addResources(resources);
transactionRequest.addMessageInput(messageCoin);

// update fee params
transactionRequest.gasLimit = cost.gasUsed;
transactionRequest.maxFee = cost.maxFee;
const cost = await fuelTokenSender.getTransactionCost(transactionRequest);
console.log('tx cost', cost);

await fuelTokenSender.fund(transactionRequest, cost);
// update fee params
transactionRequest.gasLimit = new BN(0x302d1b);

// verify that the message coin is consumed
const incomingMessagesonFuel = await env.fuel.signers[0].getMessages();
expect(incomingMessagesonFuel.messages.length === 0);
const inputs: any = await transactionRequest.inputs;
console.log('tx imputs', inputs);

return transactionRequest;
} else {
Expand Down Expand Up @@ -163,6 +162,8 @@ describe('Bridging ERC20 tokens', async function () {

const tx = await fuelTokenSender.sendTransaction(transactionRequest);

console.log('dddd', tx);

const fWithdrawTxResult = await tx.waitForResult();
expect(fWithdrawTxResult.status).to.equal('success');

Expand Down Expand Up @@ -424,7 +425,7 @@ describe('Bridging ERC20 tokens', async function () {
const tx = await env.eth.fuelMessagePortal
.connect(ethereumTokenSender)
.depositETH(fuelTokenReceiverAddress, {
value: parseEther('1'),
value: parseEther('10'),
});
const receipt = await tx.wait();
expect(receipt.status).to.equal(1);
Expand Down Expand Up @@ -462,10 +463,11 @@ describe('Bridging ERC20 tokens', async function () {

// verify the incoming messages generated when base asset is minted on fuel
const incomingMessagesonFuel = await env.fuel.signers[0].getMessages();
console.log('incomingMessagesonFuel', incomingMessagesonFuel);
expect(incomingMessagesonFuel.messages.length === 1);
expect(
incomingMessagesonFuel.messages[0].amount === fuels_parseEther('1')
);
// expect(
// incomingMessagesonFuel.messages[0] === fuels_parseEther('1')
// );
});

it('Bridge ERC20 token with permit via FuelERC20Gateway', async () => {
Expand Down

0 comments on commit 3dc09e0

Please sign in to comment.