From bd3093fd77d8d8d4d483b2eac60bb7b99eaa08b7 Mon Sep 17 00:00:00 2001 From: Dhruv-Varshney-developer Date: Sat, 11 Jan 2025 02:47:01 +0530 Subject: [PATCH] improve(test): Added tests for Zora_SpokePool.sol Signed-off-by: Dhruv-Varshney-developer --- .../Zora_SpokePool.ts | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/evm/hardhat/chain-specific-spokepools/Zora_SpokePool.ts diff --git a/test/evm/hardhat/chain-specific-spokepools/Zora_SpokePool.ts b/test/evm/hardhat/chain-specific-spokepools/Zora_SpokePool.ts new file mode 100644 index 000000000..f01a97663 --- /dev/null +++ b/test/evm/hardhat/chain-specific-spokepools/Zora_SpokePool.ts @@ -0,0 +1,57 @@ +import { + ethers, + expect, + Contract, + SignerWithAddress, + getContractFactory, + FakeContract, + createFakeFromABI, +} from "../../../../utils/utils"; +import { hre } from "../../../../utils/utils.hre"; +import { hubPoolFixture } from "../fixtures/HubPool.Fixture"; +import { CCTPTokenMessengerInterface } from "../../../../utils/abis"; + +describe("Zora Spoke Pool", function () { + let hubPool: Contract, spokePool: Contract, weth: Contract, usdc: Contract; + let owner: SignerWithAddress; + let cctpTokenMessenger: FakeContract; + + beforeEach(async function () { + [owner] = await ethers.getSigners(); + ({ weth, usdc, hubPool } = await hubPoolFixture()); + + cctpTokenMessenger = await createFakeFromABI(CCTPTokenMessengerInterface); + + spokePool = await hre.upgrades.deployProxy( + await getContractFactory("Zora_SpokePool", owner), + [0, owner.address, hubPool.address], + { + kind: "uups", + unsafeAllow: ["delegatecall"], + constructorArgs: [weth.address, 60 * 60, 9 * 60 * 60, usdc.address, cctpTokenMessenger.address], + } + ); + }); + + describe("Initialization", function () { + 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 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"); + }); + + it("Should revert on reinitialization", async function () { + await expect(spokePool.connect(owner).initialize(0, owner.address, hubPool.address)).to.be.reverted; + }); + }); +});