Skip to content

Commit

Permalink
fix: TS Linting in test packages (#351)
Browse files Browse the repository at this point in the history
- add ts linting for all test packages
  • Loading branch information
viraj124 authored Oct 25, 2024
1 parent ae2f174 commit e24dcb6
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 109 deletions.
6 changes: 6 additions & 0 deletions .changeset/small-singers-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@fuel-bridge/solidity-contracts': minor
'@fuel-bridge/test-utils': minor
---

ts linting for test packages
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/typechain/
docker/l1-chain/hardhat
dist
**/exports/
2 changes: 1 addition & 1 deletion packages/integration-tests/tests/bridge_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ describe('Bridging ERC20 tokens', async function () {

it('Rate limit parameters are updated when current withdrawn amount is more than the new limit & set a new higher limit', async () => {
const deployer = await env.eth.deployer;
let newRateLimit = '5';
const newRateLimit = '5';

let withdrawnAmountBeforeReset =
await env.eth.fuelERC20Gateway.currentPeriodAmount(
Expand Down
36 changes: 13 additions & 23 deletions packages/integration-tests/tests/bridge_mainnet_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import type { BridgeFungibleToken } from '@fuel-bridge/fungible-token';
import {
RATE_LIMIT_AMOUNT,
RATE_LIMIT_DURATION,
USDT_ADDRESS,
USDC_ADDRESS,
WBTC_ADDRESS,
WETH_ADDRESS,
} from '@fuel-bridge/solidity-contracts/protocol/constants';
import {
import type {
CustomToken,
CustomTokenWETH,
} from '@fuel-bridge/solidity-contracts/typechain';
import {
CustomToken__factory,
CustomTokenWETH__factory,
} from '@fuel-bridge/solidity-contracts/typechain';
import {
USDT_ADDRESS,
USDC_ADDRESS,
WBTC_ADDRESS,
WETH_ADDRESS,
} from '@fuel-bridge/solidity-contracts/protocol/constants';
import type { TestEnvironment } from '@fuel-bridge/test-utils';
import {
setupEnvironment,
Expand Down Expand Up @@ -89,8 +89,7 @@ describe('Bridge mainnet tokens', function () {
fuel_AssetId
);

let transactionRequest;
transactionRequest = await fuel_bridge.functions
const transactionRequest = await fuel_bridge.functions
.withdraw(paddedAddress)
.addContracts([fuel_bridge, fuel_bridgeImpl])
.txParams({
Expand Down Expand Up @@ -232,7 +231,6 @@ describe('Bridge mainnet tokens', function () {
const NUM_TOKENS = 100000000000000000000n;
let ethereumTokenSender: Signer;
let ethereumTokenSenderAddress: string;
let ethereumTokenSenderBalance: bigint;
let fuelTokenReceiver: FuelWallet;
let fuelTokenReceiverAddress: string;
let fuelTokenReceiverBalance: BN;
Expand All @@ -247,20 +245,12 @@ describe('Bridge mainnet tokens', function () {
await weth_testToken
.connect(ethereumTokenSender)
.deposit({ value: NUM_TOKENS });

ethereumTokenSenderBalance = await weth_testToken.balanceOf(
ethereumTokenSenderAddress
);
} else {
const mintAmount =
BigInt(NUM_TOKENS) / 10n ** (18n - decimals[index]);
await customToken
.mint(ethereumTokenSender, mintAmount)
.then((tx) => tx.wait());

ethereumTokenSenderBalance = await customToken.balanceOf(
ethereumTokenSenderAddress
);
}

fuelTokenReceiver = env.fuel.signers[0];
Expand Down Expand Up @@ -302,10 +292,10 @@ describe('Bridge mainnet tokens', function () {

fuelTokenMessageNonce = new BN(event.args.nonce.toString());

let newSenderBalance;

// check that the sender balance has decreased by the expected amount
newSenderBalance = await token.balanceOf(ethereumTokenSenderAddress);
const newSenderBalance = await token.balanceOf(
ethereumTokenSenderAddress
);

expect(newSenderBalance === 0n).to.be.true;
});
Expand All @@ -315,15 +305,15 @@ describe('Bridge mainnet tokens', function () {
this.timeout(FUEL_MESSAGE_TIMEOUT_MS);

// relay the message ourselves
let message = await waitForMessage(
const message = await waitForMessage(
env.fuel.provider,
fuelTokenMessageReceiver,
fuelTokenMessageNonce,
FUEL_MESSAGE_TIMEOUT_MS
);
expect(message).to.not.be.null;

let tx = await relayCommonMessage(env.fuel.deployer, message, {
const tx = await relayCommonMessage(env.fuel.deployer, message, {
gasLimit: 30000000,
maturity: undefined,
contractIds: [fuel_bridgeImpl.id.toHexString()],
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/tests/bridge_proxy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Proxy } from '@fuel-bridge/fungible-token';
import type { TestEnvironment } from '@fuel-bridge/test-utils';
import { setupEnvironment, getOrDeployL2Bridge } from '@fuel-bridge/test-utils';
import chai from 'chai';
import type { Contract, FuelError } from 'fuels';
import { Proxy } from '@fuel-bridge/fungible-token';

const { expect } = chai;

Expand Down
9 changes: 5 additions & 4 deletions packages/integration-tests/tests/transfer_eth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TestEnvironment } from '@fuel-bridge/test-utils';
import {
TestEnvironment,
setupEnvironment,
fuels_parseEther,
createRelayMessageParams,
Expand All @@ -14,9 +14,8 @@ import {
hardhatSkipTime,
} from '@fuel-bridge/test-utils';
import chai from 'chai';
import type { Signer } from 'ethers';
import { parseEther } from 'ethers';
import type { JsonRpcProvider } from 'ethers';
import type { Signer, JsonRpcProvider } from 'ethers';
import { Address, BN, padFirst12BytesOfEvmAddress } from 'fuels';
import type {
AbstractAddress,
Expand Down Expand Up @@ -264,6 +263,8 @@ describe('Transferring ETH', async function () {
// withdraw ETH back to the base chain
const blocksPerCommitInterval =
await env.eth.fuelChainState.BLOCKS_PER_COMMIT_INTERVAL();

// eslint-disable-next-line no-constant-condition
while (true) {
const currentBlock = await env.fuel.provider.getBlockNumber();
debug(`Current block ${currentBlock.toString()}`);
Expand Down Expand Up @@ -349,7 +350,7 @@ describe('Transferring ETH', async function () {
});

describe('ETH Withdrawls based on rate limit updates', async () => {
let NUM_ETH = '9';
const NUM_ETH = '9';
const largeRateLimit = `30`;
let fuelETHSender: FuelWallet;
let ethereumETHReceiver: Signer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import {
import { randomAddress, randomBytes32 } from '../../protocol/utils';
import {
CustomToken__factory,
NoDecimalsToken__factory
NoDecimalsToken__factory,
} from '../../typechain';
import type {
MockFuelMessagePortal,
FuelERC20GatewayV4,
Token,
CustomToken,
NoDecimalsToken,

MockPermitToken} from '../../typechain';
MockPermitToken,
} from '../../typechain';
import { impersonateAccount } from '../utils/impersonateAccount';

type Env = {
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/src/scripts/check-balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import { password } from '@inquirer/prompts';
import { Provider, WalletUnlocked } from 'fuels';

let { L2_ADDRESS, L2_RPC } = process.env;
let { L2_ADDRESS } = process.env;
const { L2_RPC } = process.env;

const main = async () => {
const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 });
Expand Down
5 changes: 3 additions & 2 deletions packages/test-utils/src/scripts/check-nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* This is a stand-alone script that looks for a message nonce
*/

import { BN, Message, Provider } from 'fuels';
import type { Message } from 'fuels';
import { BN, Provider } from 'fuels';

let { L2_RPC, L2_MESSAGE_NONCE } = process.env;
const { L2_RPC, L2_MESSAGE_NONCE } = process.env;

const main = async () => {
if (!L2_MESSAGE_NONCE) {
Expand Down
4 changes: 1 addition & 3 deletions packages/test-utils/src/scripts/check-proxy-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*/

import { Proxy } from '@fuel-bridge/fungible-token';

import { Provider } from 'fuels';

let { L2_RPC, L2_BRIDGE_ID } = process.env;
const L1_LLAMA_RPC = 'https://eth.llamarpc.com';
const { L2_RPC, L2_BRIDGE_ID } = process.env;
const main = async () => {
const fuel_provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 });

Expand Down
13 changes: 4 additions & 9 deletions packages/test-utils/src/scripts/deploy-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ import {
BridgeFungibleTokenFactory,
ProxyFactory,
} from '@fuel-bridge/fungible-token';

import {
DeployContractResult,
Provider,
Wallet,
WalletUnlocked,
ZeroBytes32,
} from 'fuels';
import { password } from '@inquirer/prompts';
import type { DeployContractResult, WalletUnlocked } from 'fuels';
import { Provider, Wallet, ZeroBytes32 } from 'fuels';

let { L1_TOKEN_GATEWAY, L2_SIGNER, L2_RPC } = process.env;
let { L2_SIGNER } = process.env;
const { L1_TOKEN_GATEWAY, L2_RPC } = process.env;

// This helper avoids an exception in the case that the contract
// was already deployed, and returns the contract instead
Expand Down
5 changes: 3 additions & 2 deletions packages/test-utils/src/scripts/deposit-to-coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* to convert a message coin into a coin utxo
*/

import { Provider, TransactionStatus, Wallet } from 'fuels';
import { password } from '@inquirer/prompts';
import { Provider, TransactionStatus, Wallet } from 'fuels';

let { L2_SIGNER, L2_RPC } = process.env;
let { L2_SIGNER } = process.env;
const { L2_RPC } = process.env;

const main = async () => {
if (!L2_RPC) {
Expand Down
13 changes: 8 additions & 5 deletions packages/test-utils/src/scripts/relay-deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
*/

import { Proxy } from '@fuel-bridge/fungible-token';

import { contractMessagePredicate } from '@fuel-bridge/message-predicates';

import { password } from '@inquirer/prompts';
import {
Account,
BN,
Expand All @@ -16,7 +15,7 @@ import {
getPredicateRoot,
hexlify,
} from 'fuels';
import { password } from '@inquirer/prompts';

import {
FUEL_MESSAGE_TIMEOUT_MS,
debug,
Expand All @@ -26,7 +25,9 @@ import {

const TOKEN_RECIPIENT_DATA_OFFSET = 160;

let { L2_SIGNER, L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE, L2_TOKEN_RECEIVER } =
let { L2_SIGNER } = process.env;

const { L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE, L2_TOKEN_RECEIVER } =
process.env;

const main = async () => {
Expand All @@ -45,7 +46,7 @@ const main = async () => {
console.log('\t> Balance: ', (await wallet.getBalance()).toString());

debug('Detecting if the bridge is a proxy...');
let implementation_id: string | null = await proxy.functions
const implementation_id: string | null = await proxy.functions
.proxy_target()
.dryRun()
.then((result) => {
Expand All @@ -63,7 +64,9 @@ const main = async () => {
let endCursor: string | undefined;

if (L2_MESSAGE_NONCE) nonce = new BN(L2_MESSAGE_NONCE);

else
// eslint-disable-next-line no-constant-condition
while (true) {
const response = await provider.getMessages(predicateRoot, {
after: endCursor,
Expand Down
10 changes: 5 additions & 5 deletions packages/test-utils/src/scripts/relay-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
*/

import { Proxy } from '@fuel-bridge/fungible-token';

import { contractMessagePredicate } from '@fuel-bridge/message-predicates';

import { password } from '@inquirer/prompts';
import {
Account,
BN,
Expand All @@ -15,15 +14,16 @@ import {
Wallet,
getPredicateRoot,
} from 'fuels';
import { password } from '@inquirer/prompts';

import {
FUEL_MESSAGE_TIMEOUT_MS,
debug,
relayCommonMessage,
waitForMessage,
} from '../utils';

let { L2_SIGNER, L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE } = process.env;
let { L2_SIGNER } = process.env;
const { L2_RPC, L2_BRIDGE_ID, L2_MESSAGE_NONCE } = process.env;

const main = async () => {
if (!L2_RPC) {
Expand Down Expand Up @@ -51,7 +51,7 @@ const main = async () => {
console.log('\t> Balance: ', (await wallet.getBalance()).toString());

debug('Detecting if the bridge is a proxy...');
let implementation_id: string | null = await proxy.functions
const implementation_id: string | null = await proxy.functions
.proxy_target()
.dryRun()
.then((result) => {
Expand Down
9 changes: 5 additions & 4 deletions packages/test-utils/src/scripts/transfer-bridge-ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
*/

import { Proxy } from '@fuel-bridge/fungible-token';

import { Provider, Wallet } from 'fuels';
import { password } from '@inquirer/prompts';
import { Provider, Wallet } from 'fuels';

import { debug } from '../utils';

let { L2_SIGNER, L2_RPC, L2_BRIDGE_ID, L2_NEW_OWNER } = process.env;
let { L2_SIGNER } = process.env;
const { L2_RPC, L2_BRIDGE_ID, L2_NEW_OWNER } = process.env;

const main = async () => {
const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 });
Expand All @@ -27,7 +28,7 @@ const main = async () => {
console.log('\t> Balance: ', (await wallet.getBalance()).toString());

debug('Detecting if the bridge is a proxy...');
let owner: string | null = await proxy.functions
const owner: string | null = await proxy.functions
._proxy_owner()
.dryRun()
.then((result) => {
Expand Down
Loading

0 comments on commit e24dcb6

Please sign in to comment.