Skip to content

Commit

Permalink
test: Added tests for Base_SpokePool
Browse files Browse the repository at this point in the history
Signed-off-by: Dhruv-Varshney-Developer <[email protected]>
  • Loading branch information
Dhruv-Varshney-developer committed Dec 21, 2024
1 parent aec5098 commit c630e21
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions test/evm/hardhat/chain-specific-spokepools/Base_SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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"],
Expand All @@ -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;
});
});
});

0 comments on commit c630e21

Please sign in to comment.