From cea26dedb28ad468c91e38e188f03569195d56af Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Wed, 18 Dec 2024 13:13:58 +0530 Subject: [PATCH 01/11] docs: readme update. Signed-off-by: Dhruv-Varshney-Developer --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d37373a11..16c2b9a7a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ The latest contract deployments on Production will always be under the `deployed This repository assumes you have [Node](https://nodejs.org/en/download/package-manager) installed, with a minimum version of 16.18.0. Depending on what you want to do with the repo you might also need [foundry](https://book.getfoundry.sh/getting-started/installation) and [anchor](https://www.anchor-lang.com/docs/installation) to also be installed. If you have build issues please insure these are both installed first. -Note if you get build issues on the initial `yarn` command try downgrading to node 20.17 (`nvm use 20.17`). If you've never used anchor before you might need to run `avm use latest` as well. +**Note** + If you get build issues on the initial `yarn` command try downgrading to node 20.17 (`nvm use 20.17`). If you've never used anchor before you might need to run `avm use latest` as well. ## Build From aa4241119c09a3e2f9760318f1a3f80c5d2a0407 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Thu, 19 Dec 2024 18:32:15 +0530 Subject: [PATCH 02/11] docs: spelling mistake fixed. Signed-off-by: Dhruv-Varshney-Developer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16c2b9a7a..6660ce688 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The latest contract deployments on Production will always be under the `deployed ## Requirements -This repository assumes you have [Node](https://nodejs.org/en/download/package-manager) installed, with a minimum version of 16.18.0. Depending on what you want to do with the repo you might also need [foundry](https://book.getfoundry.sh/getting-started/installation) and [anchor](https://www.anchor-lang.com/docs/installation) to also be installed. If you have build issues please insure these are both installed first. +This repository assumes you have [Node](https://nodejs.org/en/download/package-manager) installed, with a minimum version of 16.18.0. Depending on what you want to do with the repo you might also need [foundry](https://book.getfoundry.sh/getting-started/installation) and [anchor](https://www.anchor-lang.com/docs/installation) to also be installed. If you have build issues please ensure these are both installed first. **Note** If you get build issues on the initial `yarn` command try downgrading to node 20.17 (`nvm use 20.17`). If you've never used anchor before you might need to run `avm use latest` as well. From 9d3aebafe950bac1794b80739e938fe74039dd40 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Thu, 19 Dec 2024 21:53:02 +0530 Subject: [PATCH 03/11] refactor:disable ESlint warnings. Signed-off-by: Dhruv-Varshney-Developer --- scripts/svm/generateExternalTypes.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/svm/generateExternalTypes.ts b/scripts/svm/generateExternalTypes.ts index 514718d41..478649ef2 100644 --- a/scripts/svm/generateExternalTypes.ts +++ b/scripts/svm/generateExternalTypes.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-process-exit */ import * as anchor from "@coral-xyz/anchor"; import { exec } from "child_process"; import * as fs from "fs"; From a47051ccf3151d070285ed6c95d1a7f7405d8698 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Thu, 19 Dec 2024 22:00:27 +0530 Subject: [PATCH 04/11] refactor: Disable ESLint warnings for missing requires and camelCase Signed-off-by: Dhruv-Varshney-Developer --- scripts/svm/bridgeLiabilityToHubPool.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/svm/bridgeLiabilityToHubPool.ts b/scripts/svm/bridgeLiabilityToHubPool.ts index d0b9b0aa1..2d8892d73 100644 --- a/scripts/svm/bridgeLiabilityToHubPool.ts +++ b/scripts/svm/bridgeLiabilityToHubPool.ts @@ -1,3 +1,6 @@ +/* eslint-disable node/no-missing-require */ +/* eslint-disable node/no-missing-import */ +/* eslint-disable camelcase */ /** * Script: Bridge USDC Liability to Hub Pool * @@ -27,10 +30,8 @@ import * as anchor from "@coral-xyz/anchor"; import { AnchorProvider, BN, Program } from "@coral-xyz/anchor"; import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { PublicKey, SystemProgram } from "@solana/web3.js"; -// eslint-disable-next-line camelcase import { MessageTransmitter } from "../../target/types/message_transmitter"; import { SvmSpoke } from "../../target/types/svm_spoke"; -// eslint-disable-next-line camelcase import { CIRCLE_IRIS_API_URL_DEVNET, CIRCLE_IRIS_API_URL_MAINNET, @@ -124,7 +125,7 @@ async function bridgeLiabilityToHubPool(): Promise { // Resolve Solana USDC addresses. const svmUsdc = isDevnet ? SOLANA_USDC_DEVNET : SOLANA_USDC_MAINNET; - const [statePda, _] = PublicKey.findProgramAddressSync( + const [statePda] = PublicKey.findProgramAddressSync( [Buffer.from("state"), seed.toArrayLike(Buffer, "le", 8)], svmSpokeProgram.programId ); From db8776fbf1da2c2841959441a6fd99ba0dd6cdb1 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Thu, 19 Dec 2024 22:02:11 +0530 Subject: [PATCH 05/11] fix: disable eslint warnings for imports and requires. Signed-off-by: Dhruv-Varshney-Developer --- scripts/svm/closeRelayerPdas.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/svm/closeRelayerPdas.ts b/scripts/svm/closeRelayerPdas.ts index 4e15c6f51..9ad98d0c9 100644 --- a/scripts/svm/closeRelayerPdas.ts +++ b/scripts/svm/closeRelayerPdas.ts @@ -1,3 +1,5 @@ +/* eslint-disable node/no-missing-require */ +/* eslint-disable node/no-missing-import */ // This script closes all Relayer PDAs associated with tracking fill Status. Relayers should do this periodically to // reclaim the lamports within these tracking accounts. Fill Status PDAs can be closed on the deposit has expired. import * as anchor from "@coral-xyz/anchor"; From 232e6259ce5e504716f07996712c9264cd36c9c8 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Fri, 20 Dec 2024 16:18:51 +0530 Subject: [PATCH 06/11] fix: disable eslint no missing imports warnings. Signed-off-by: Dhruv-Varshney-Developer --- test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts index 3080995ff..0bfe097bd 100644 --- a/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts +++ b/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts @@ -1,3 +1,4 @@ +/* eslint-disable node/no-missing-import */ import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants"; import { ethers, expect, Contract, SignerWithAddress, getContractFactory, seedContract } from "../../../../utils/utils"; import { hre } from "../../../../utils/utils.hre"; From f6053c288590d2e2c50cb8f477546be8bdf39691 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Sat, 21 Dec 2024 05:04:30 +0530 Subject: [PATCH 07/11] test: added tests for Base_SpokePool.sol Signed-off-by: Dhruv-Varshney-Developer --- .../Base_SpokePool.ts | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts diff --git a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts new file mode 100644 index 000000000..ed8156add --- /dev/null +++ b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts @@ -0,0 +1,186 @@ +/* eslint-disable node/no-missing-import */ +import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants"; +import { + ethers, + expect, + Contract, + FakeContract, + SignerWithAddress, + getContractFactory, + seedContract, +} from "../../../../utils/utils"; +import { hre } from "../../../../utils/utils.hre"; +import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; +import { constructSingleRelayerRefundTree } from "../MerkleLib.utils"; +import { smock } from "@defi-wonderland/smock"; + +let hubPool: Contract, spokePool: Contract, weth: Contract, usdc: Contract; +let owner: SignerWithAddress, relayer: SignerWithAddress, rando: SignerWithAddress; +let cctpTokenMessenger: FakeContract; + +// ABI for CCTP Token Messenger +const tokenMessengerAbi = [ + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint32", name: "destinationDomain", type: "uint32" }, + ], + name: "depositForBurn", + outputs: [{ internalType: "uint64", name: "", type: "uint64" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "localToken", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, +]; + +describe("Base Spoke Pool", function () { + beforeEach(async function () { + [owner, relayer, rando] = await ethers.getSigners(); + ({ weth, usdc, hubPool } = await hubPoolFixture()); + + // Create fake CCTP Token Messenger instead of mock + cctpTokenMessenger = await smock.fake(tokenMessengerAbi, { + address: "0x0a992d191DEeC32aFe36203Ad87D7d289a738F81", // Example address + }); + cctpTokenMessenger.localToken.returns(usdc.address); + + // Deploy Base SpokePool + spokePool = await hre.upgrades.deployProxy( + await getContractFactory("Base_SpokePool", owner), + [0, hubPool.address, hubPool.address], + { + kind: "uups", + unsafeAllow: ["delegatecall"], + constructorArgs: [weth.address, 60 * 60, 9 * 60 * 60, usdc.address, cctpTokenMessenger.address], + } + ); + + // Seed spoke pool with tokens for testing + await seedContract(spokePool, relayer, [usdc], weth, amountHeldByPool); + }); + + describe("Initialization", function () { + it("Should initialize with correct parameters", async function () { + expect(await spokePool.crossDomainAdmin()).to.equal(hubPool.address); + expect(await spokePool.withdrawalRecipient()).to.equal(hubPool.address); + expect(await spokePool.wrappedNativeToken()).to.equal(weth.address); + expect(await spokePool.l2Usdc()).to.equal(usdc.address); + expect(await spokePool.cctpTokenMessenger()).to.equal(cctpTokenMessenger.address); + }); + + it("Should start with deposit ID 0", async function () { + expect(await spokePool.numberOfDeposits()).to.equal(0); + }); + }); + + describe("Token transfers", function () { + it("Should correctly bridge tokens to hub pool", async function () { + const { leaves, tree } = await constructSingleRelayerRefundTree( + usdc.address, + await spokePool.callStatic.chainId() + ); + await spokePool.connect(owner).relayRootBundle(tree.getHexRoot(), mockTreeRoot); + + await spokePool.connect(relayer).executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0])); + + // Verify CCTP messenger was called correctly + expect(cctpTokenMessenger.depositForBurn).to.have.been.calledWith( + hubPool.address, + amountToReturn, + 1 // Ethereum domain ID + ); + }); + + it("Should handle wrapped native token transfers", async function () { + const { leaves, tree } = await constructSingleRelayerRefundTree( + weth.address, + await spokePool.callStatic.chainId() + ); + await spokePool.connect(owner).relayRootBundle(tree.getHexRoot(), mockTreeRoot); + + await expect(() => + spokePool.connect(relayer).executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0])) + ).to.changeTokenBalances(weth, [spokePool, hubPool], [amountToReturn.mul(-1), amountToReturn]); + }); + }); + + describe("Admin functions", function () { + it("Only cross domain owner can upgrade logic contract", async function () { + const implementation = await hre.upgrades.deployImplementation( + await getContractFactory("Base_SpokePool", owner), + { + kind: "uups", + unsafeAllow: ["delegatecall"], + constructorArgs: [weth.address, 60 * 60, 9 * 60 * 60, usdc.address, cctpTokenMessenger.address], + } + ); + + await expect(spokePool.connect(rando).upgradeTo(implementation)).to.be.revertedWith( + "Ownable: caller is not the owner" + ); + await spokePool.connect(owner).upgradeTo(implementation); + }); + + it("Only owner can set the cross domain admin", async function () { + await expect(spokePool.connect(rando).setCrossDomainAdmin(rando.address)).to.be.reverted; + await spokePool.connect(owner).setCrossDomainAdmin(rando.address); + expect(await spokePool.crossDomainAdmin()).to.equal(rando.address); + }); + + it("Only owner can enable a route", async function () { + await expect(spokePool.connect(rando).setEnableRoute(usdc.address, 1, true)).to.be.reverted; + await spokePool.connect(owner).setEnableRoute(usdc.address, 1, true); + expect(await spokePool.enabledDepositRoutes(usdc.address, 1)).to.equal(true); + }); + }); + + describe("CCTP functionality", function () { + it("Should correctly handle CCTP token deposits", async function () { + const amount = ethers.utils.parseUnits("100", 6); // USDC has 6 decimals + const destinationDomain = 1; // Ethereum domain + + // Mock the CCTP messenger response + cctpTokenMessenger.depositForBurn.returns(123); // Return some nonce + + // Perform deposit + await usdc.connect(owner).approve(spokePool.address, amount); + const depositTx = await spokePool + .connect(owner) + .deposit(usdc.address, amount, destinationDomain, owner.address, 0); + + // Verify CCTP messenger was called with correct parameters + expect(cctpTokenMessenger.depositForBurn).to.have.been.calledWith(hubPool.address, amount, destinationDomain); + + await expect(depositTx) + .to.emit(spokePool, "TokensDeposited") + .withArgs(owner.address, usdc.address, amount, destinationDomain); + }); + }); + + describe("Error cases", function () { + it("Should revert if trying to initialize twice", async function () { + await expect(spokePool.initialize(0, hubPool.address, hubPool.address)).to.be.revertedWith( + "Initializable: contract is already initialized" + ); + }); + + it("Should revert if CCTP messenger call fails", async function () { + const amount = ethers.utils.parseUnits("100", 6); + + // Make the CCTP messenger revert + cctpTokenMessenger.depositForBurn.reverts("CCTP: Transfer failed"); + + await usdc.connect(owner).approve(spokePool.address, amount); + await expect(spokePool.connect(owner).deposit(usdc.address, amount, 1, owner.address, 0)).to.be.revertedWith( + "CCTP: Transfer failed" + ); + }); + }); +}); From aec509896de9bf1daa4bbd81e90f994c9dbfd784 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Sat, 21 Dec 2024 16:55:50 +0530 Subject: [PATCH 08/11] wip: Removed irrelevant code from test file. Signed-off-by: Dhruv-Varshney-Developer --- .../Base_SpokePool.ts | 136 +----------------- 1 file changed, 5 insertions(+), 131 deletions(-) diff --git a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts index ed8156add..9558632d5 100644 --- a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts +++ b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts @@ -1,36 +1,15 @@ /* eslint-disable node/no-missing-import */ -import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants"; -import { - ethers, - expect, - Contract, - FakeContract, - SignerWithAddress, - getContractFactory, - seedContract, -} from "../../../../utils/utils"; +import { ethers, expect, Contract, FakeContract, SignerWithAddress, getContractFactory } from "../../../../utils/utils"; import { hre } from "../../../../utils/utils.hre"; import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; -import { constructSingleRelayerRefundTree } from "../MerkleLib.utils"; import { smock } from "@defi-wonderland/smock"; let hubPool: Contract, spokePool: Contract, weth: Contract, usdc: Contract; -let owner: SignerWithAddress, relayer: SignerWithAddress, rando: SignerWithAddress; +let owner: SignerWithAddress; let cctpTokenMessenger: FakeContract; // ABI for CCTP Token Messenger const tokenMessengerAbi = [ - { - inputs: [ - { internalType: "address", name: "recipient", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - { internalType: "uint32", name: "destinationDomain", type: "uint32" }, - ], - name: "depositForBurn", - outputs: [{ internalType: "uint64", name: "", type: "uint64" }], - stateMutability: "nonpayable", - type: "function", - }, { inputs: [], name: "localToken", @@ -42,13 +21,10 @@ const tokenMessengerAbi = [ describe("Base Spoke Pool", function () { beforeEach(async function () { - [owner, relayer, rando] = await ethers.getSigners(); + [owner] = await ethers.getSigners(); ({ weth, usdc, hubPool } = await hubPoolFixture()); - // Create fake CCTP Token Messenger instead of mock - cctpTokenMessenger = await smock.fake(tokenMessengerAbi, { - address: "0x0a992d191DEeC32aFe36203Ad87D7d289a738F81", // Example address - }); + cctpTokenMessenger = await smock.fake(tokenMessengerAbi); cctpTokenMessenger.localToken.returns(usdc.address); // Deploy Base SpokePool @@ -61,17 +37,11 @@ describe("Base Spoke Pool", function () { constructorArgs: [weth.address, 60 * 60, 9 * 60 * 60, usdc.address, cctpTokenMessenger.address], } ); - - // Seed spoke pool with tokens for testing - await seedContract(spokePool, relayer, [usdc], weth, amountHeldByPool); }); describe("Initialization", function () { it("Should initialize with correct parameters", async function () { - expect(await spokePool.crossDomainAdmin()).to.equal(hubPool.address); - expect(await spokePool.withdrawalRecipient()).to.equal(hubPool.address); - expect(await spokePool.wrappedNativeToken()).to.equal(weth.address); - expect(await spokePool.l2Usdc()).to.equal(usdc.address); + expect(await spokePool._l2Usdc).to.equal(usdc.address); expect(await spokePool.cctpTokenMessenger()).to.equal(cctpTokenMessenger.address); }); @@ -80,107 +50,11 @@ describe("Base Spoke Pool", function () { }); }); - describe("Token transfers", function () { - it("Should correctly bridge tokens to hub pool", async function () { - const { leaves, tree } = await constructSingleRelayerRefundTree( - usdc.address, - await spokePool.callStatic.chainId() - ); - await spokePool.connect(owner).relayRootBundle(tree.getHexRoot(), mockTreeRoot); - - await spokePool.connect(relayer).executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0])); - - // Verify CCTP messenger was called correctly - expect(cctpTokenMessenger.depositForBurn).to.have.been.calledWith( - hubPool.address, - amountToReturn, - 1 // Ethereum domain ID - ); - }); - - it("Should handle wrapped native token transfers", async function () { - const { leaves, tree } = await constructSingleRelayerRefundTree( - weth.address, - await spokePool.callStatic.chainId() - ); - await spokePool.connect(owner).relayRootBundle(tree.getHexRoot(), mockTreeRoot); - - await expect(() => - spokePool.connect(relayer).executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0])) - ).to.changeTokenBalances(weth, [spokePool, hubPool], [amountToReturn.mul(-1), amountToReturn]); - }); - }); - - describe("Admin functions", function () { - it("Only cross domain owner can upgrade logic contract", async function () { - const implementation = await hre.upgrades.deployImplementation( - await getContractFactory("Base_SpokePool", owner), - { - kind: "uups", - unsafeAllow: ["delegatecall"], - constructorArgs: [weth.address, 60 * 60, 9 * 60 * 60, usdc.address, cctpTokenMessenger.address], - } - ); - - await expect(spokePool.connect(rando).upgradeTo(implementation)).to.be.revertedWith( - "Ownable: caller is not the owner" - ); - await spokePool.connect(owner).upgradeTo(implementation); - }); - - it("Only owner can set the cross domain admin", async function () { - await expect(spokePool.connect(rando).setCrossDomainAdmin(rando.address)).to.be.reverted; - await spokePool.connect(owner).setCrossDomainAdmin(rando.address); - expect(await spokePool.crossDomainAdmin()).to.equal(rando.address); - }); - - it("Only owner can enable a route", async function () { - await expect(spokePool.connect(rando).setEnableRoute(usdc.address, 1, true)).to.be.reverted; - await spokePool.connect(owner).setEnableRoute(usdc.address, 1, true); - expect(await spokePool.enabledDepositRoutes(usdc.address, 1)).to.equal(true); - }); - }); - - describe("CCTP functionality", function () { - it("Should correctly handle CCTP token deposits", async function () { - const amount = ethers.utils.parseUnits("100", 6); // USDC has 6 decimals - const destinationDomain = 1; // Ethereum domain - - // Mock the CCTP messenger response - cctpTokenMessenger.depositForBurn.returns(123); // Return some nonce - - // Perform deposit - await usdc.connect(owner).approve(spokePool.address, amount); - const depositTx = await spokePool - .connect(owner) - .deposit(usdc.address, amount, destinationDomain, owner.address, 0); - - // Verify CCTP messenger was called with correct parameters - expect(cctpTokenMessenger.depositForBurn).to.have.been.calledWith(hubPool.address, amount, destinationDomain); - - await expect(depositTx) - .to.emit(spokePool, "TokensDeposited") - .withArgs(owner.address, usdc.address, amount, destinationDomain); - }); - }); - describe("Error cases", function () { it("Should revert if trying to initialize twice", async function () { await expect(spokePool.initialize(0, hubPool.address, hubPool.address)).to.be.revertedWith( "Initializable: contract is already initialized" ); }); - - it("Should revert if CCTP messenger call fails", async function () { - const amount = ethers.utils.parseUnits("100", 6); - - // Make the CCTP messenger revert - cctpTokenMessenger.depositForBurn.reverts("CCTP: Transfer failed"); - - await usdc.connect(owner).approve(spokePool.address, amount); - await expect(spokePool.connect(owner).deposit(usdc.address, amount, 1, owner.address, 0)).to.be.revertedWith( - "CCTP: Transfer failed" - ); - }); }); }); From c630e217c236bea6c7f0a190e1d14bf52a1d2406 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-Developer Date: Sun, 22 Dec 2024 00:01:53 +0530 Subject: [PATCH 09/11] test: Added tests for Base_SpokePool Signed-off-by: Dhruv-Varshney-Developer --- .../Base_SpokePool.ts | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts index 9558632d5..cece79c41 100644 --- a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts +++ b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts @@ -8,7 +8,6 @@ let hubPool: Contract, spokePool: Contract, weth: Contract, usdc: Contract; let owner: SignerWithAddress; let cctpTokenMessenger: FakeContract; -// ABI for CCTP Token Messenger const tokenMessengerAbi = [ { inputs: [], @@ -25,12 +24,10 @@ describe("Base Spoke Pool", function () { ({ weth, usdc, hubPool } = await hubPoolFixture()); cctpTokenMessenger = await smock.fake(tokenMessengerAbi); - cctpTokenMessenger.localToken.returns(usdc.address); - // Deploy Base SpokePool spokePool = await hre.upgrades.deployProxy( await getContractFactory("Base_SpokePool", owner), - [0, hubPool.address, hubPool.address], + [0, owner.address, hubPool.address], { kind: "uups", unsafeAllow: ["delegatecall"], @@ -40,21 +37,26 @@ describe("Base Spoke Pool", function () { }); describe("Initialization", function () { - it("Should initialize with correct parameters", async function () { - expect(await spokePool._l2Usdc).to.equal(usdc.address); + it("Should initialize with correct constructor parameters", async function () { + expect(await spokePool.wrappedNativeToken()).to.equal(weth.address); + expect(await spokePool.usdcToken()).to.equal(usdc.address); expect(await spokePool.cctpTokenMessenger()).to.equal(cctpTokenMessenger.address); }); - it("Should start with deposit ID 0", async function () { + it("Should initialize with correct proxy parameters", async function () { expect(await spokePool.numberOfDeposits()).to.equal(0); + expect(await spokePool.crossDomainAdmin()).to.equal(owner.address); + expect(await spokePool.withdrawalRecipient()).to.equal(hubPool.address); + }); + + it("Should initialize with correct OVM_ETH", async function () { + expect(await spokePool.l2Eth()).to.equal("0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000"); }); }); describe("Error cases", function () { - it("Should revert if trying to initialize twice", async function () { - await expect(spokePool.initialize(0, hubPool.address, hubPool.address)).to.be.revertedWith( - "Initializable: contract is already initialized" - ); + it("Should revert on reinitialization", async function () { + await expect(spokePool.connect(owner).initialize(0, owner.address, hubPool.address)).to.be.reverted; }); }); }); From 77f90bd59badae6b2f09ffa7b0a4ddf458fd4e76 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-developer Date: Wed, 1 Jan 2025 07:53:37 +0530 Subject: [PATCH 10/11] fix: ESLint warnings for node/no-missing-import Signed-off-by: Dhruv-Varshney-developer --- .eslintrc.js | 7 +++++++ scripts/svm/bridgeLiabilityToHubPool.ts | 2 -- scripts/svm/closeRelayerPdas.ts | 2 -- scripts/svm/generateExternalTypes.ts | 1 - .../hardhat/chain-specific-spokepools/Base_SpokePool.ts | 1 - .../chain-specific-spokepools/Ethereum_SpokePool.ts | 1 - 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9b249eca7..a39f8791d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,6 +13,13 @@ module.exports = { }, rules: { "node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }], + "node/no-missing-import": [ + "error", + { + tryExtensions: [".js", ".ts"], + resolvePaths: ["."], + }, + ], "mocha/no-exclusive-tests": "error", "@typescript-eslint/no-var-requires": 0, }, diff --git a/scripts/svm/bridgeLiabilityToHubPool.ts b/scripts/svm/bridgeLiabilityToHubPool.ts index 2d8892d73..9d6eee01c 100644 --- a/scripts/svm/bridgeLiabilityToHubPool.ts +++ b/scripts/svm/bridgeLiabilityToHubPool.ts @@ -1,5 +1,3 @@ -/* eslint-disable node/no-missing-require */ -/* eslint-disable node/no-missing-import */ /* eslint-disable camelcase */ /** * Script: Bridge USDC Liability to Hub Pool diff --git a/scripts/svm/closeRelayerPdas.ts b/scripts/svm/closeRelayerPdas.ts index 9ad98d0c9..4e15c6f51 100644 --- a/scripts/svm/closeRelayerPdas.ts +++ b/scripts/svm/closeRelayerPdas.ts @@ -1,5 +1,3 @@ -/* eslint-disable node/no-missing-require */ -/* eslint-disable node/no-missing-import */ // This script closes all Relayer PDAs associated with tracking fill Status. Relayers should do this periodically to // reclaim the lamports within these tracking accounts. Fill Status PDAs can be closed on the deposit has expired. import * as anchor from "@coral-xyz/anchor"; diff --git a/scripts/svm/generateExternalTypes.ts b/scripts/svm/generateExternalTypes.ts index 478649ef2..514718d41 100644 --- a/scripts/svm/generateExternalTypes.ts +++ b/scripts/svm/generateExternalTypes.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-process-exit */ import * as anchor from "@coral-xyz/anchor"; import { exec } from "child_process"; import * as fs from "fs"; diff --git a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts index cece79c41..0767150fb 100644 --- a/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts +++ b/test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts @@ -1,4 +1,3 @@ -/* eslint-disable node/no-missing-import */ import { ethers, expect, Contract, FakeContract, SignerWithAddress, getContractFactory } from "../../../../utils/utils"; import { hre } from "../../../../utils/utils.hre"; import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; diff --git a/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts index 0bfe097bd..3080995ff 100644 --- a/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts +++ b/test/evm/hardhat/chain-specific-spokepools/Ethereum_SpokePool.ts @@ -1,4 +1,3 @@ -/* eslint-disable node/no-missing-import */ import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants"; import { ethers, expect, Contract, SignerWithAddress, getContractFactory, seedContract } from "../../../../utils/utils"; import { hre } from "../../../../utils/utils.hre"; From ab6c87a253a685155d2d317a6ab63db0b866fbf4 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-developer Date: Wed, 1 Jan 2025 07:58:51 +0530 Subject: [PATCH 11/11] fix: ESLint errors for mocha/no-exclusive-tests Signed-off-by: Dhruv-Varshney-developer --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index a39f8791d..ee57e5879 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,7 @@ module.exports = { node: true, }, plugins: ["@typescript-eslint"], - extends: ["standard", "plugin:prettier/recommended", "plugin:node/recommended"], + extends: ["standard", "plugin:prettier/recommended", "plugin:node/recommended", "plugin:mocha/recommended"], parser: "@typescript-eslint/parser", parserOptions: { ecmaVersion: 12,