Skip to content

Commit

Permalink
tests: update Delegation constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
DiRaiks committed Jan 9, 2025
1 parent a11d6b6 commit 29ef4ad
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions test/0.8.25/vaults/delegation/delegation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import {
Delegation,
DepositContract__MockForStakingVault,
LidoLocator__HarnessForDashboard,
StakingVault,
StETH__MockForDelegation,
VaultFactory,
Expand Down Expand Up @@ -35,6 +36,7 @@ describe("Delegation.sol", () => {
let rewarder: HardhatEthersSigner;
const recipient = certainAddress("some-recipient");

let lidoLocator: LidoLocator__HarnessForDashboard;
let steth: StETH__MockForDelegation;
let weth: WETH9__MockForVault;
let wsteth: WstETH__HarnessForVault;
Expand All @@ -56,8 +58,9 @@ describe("Delegation.sol", () => {
weth = await ethers.deployContract("WETH9__MockForVault");
wsteth = await ethers.deployContract("WstETH__HarnessForVault", [steth]);
hub = await ethers.deployContract("VaultHub__MockForDelegation", [steth]);
lidoLocator = await ethers.deployContract("LidoLocator__HarnessForDashboard", [steth, wsteth]);

delegationImpl = await ethers.deployContract("Delegation", [steth, weth, wsteth]);
delegationImpl = await ethers.deployContract("Delegation", [weth, lidoLocator]);
expect(await delegationImpl.WETH()).to.equal(weth);
expect(await delegationImpl.STETH()).to.equal(steth);
expect(await delegationImpl.WSTETH()).to.equal(wsteth);
Expand Down Expand Up @@ -111,32 +114,28 @@ describe("Delegation.sol", () => {

context("constructor", () => {
it("reverts if stETH is zero address", async () => {
await expect(ethers.deployContract("Delegation", [ethers.ZeroAddress, weth, wsteth]))
await expect(ethers.deployContract("Delegation", [weth, ethers.ZeroAddress]))
.to.be.revertedWithCustomError(delegation, "ZeroArgument")
.withArgs("_stETH");
.withArgs("_lidoLocator");
});

it("reverts if wETH is zero address", async () => {
await expect(ethers.deployContract("Delegation", [steth, ethers.ZeroAddress, wsteth]))
await expect(ethers.deployContract("Delegation", [ethers.ZeroAddress, lidoLocator]))
.to.be.revertedWithCustomError(delegation, "ZeroArgument")
.withArgs("_WETH");
});

it("reverts if wstETH is zero address", async () => {
await expect(ethers.deployContract("Delegation", [steth, weth, ethers.ZeroAddress]))
.to.be.revertedWithCustomError(delegation, "ZeroArgument")
.withArgs("_wstETH");
});

it("sets the stETH address", async () => {
const delegation_ = await ethers.deployContract("Delegation", [steth, weth, wsteth]);
const delegation_ = await ethers.deployContract("Delegation", [weth, lidoLocator]);
expect(await delegation_.STETH()).to.equal(steth);
expect(await delegation_.WETH()).to.equal(weth);
expect(await delegation_.WSTETH()).to.equal(wsteth);
});
});

context("initialize", () => {
it("reverts if staking vault is zero address", async () => {
const delegation_ = await ethers.deployContract("Delegation", [steth, weth, wsteth]);
const delegation_ = await ethers.deployContract("Delegation", [weth, lidoLocator]);

await expect(delegation_.initialize(ethers.ZeroAddress))
.to.be.revertedWithCustomError(delegation_, "ZeroArgument")
Expand All @@ -148,7 +147,7 @@ describe("Delegation.sol", () => {
});

it("reverts if called on the implementation", async () => {
const delegation_ = await ethers.deployContract("Delegation", [steth, weth, wsteth]);
const delegation_ = await ethers.deployContract("Delegation", [weth, lidoLocator]);

await expect(delegation_.initialize(vault)).to.be.revertedWithCustomError(delegation_, "NonProxyCallsForbidden");
});
Expand Down

0 comments on commit 29ef4ad

Please sign in to comment.