Skip to content

Commit

Permalink
Update error handling on some contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Sep 26, 2024
1 parent 17a2fcf commit 0cb2a14
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion contracts/MaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ contract MaticX is
require(_stakeManager != address(0), "Zero stake manager address");
stakeManager = IStakeManager(_stakeManager);

require(_maticToken != address(0), "Zero matic token address");
require(_maticToken != address(0), "Zero Matic token address");
maticToken = IERC20Upgradeable(_maticToken);

require(_manager != address(0), "Zero manager address");
Expand Down
2 changes: 1 addition & 1 deletion contracts/ValidatorRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract ValidatorRegistry is
require(_stakeManager != address(0), "Zero stake manager address");
stakeManager = IStakeManager(_stakeManager);

require(_maticToken != address(0), "Zero matic token address");
require(_maticToken != address(0), "Zero Matic token address");
maticToken = _maticToken;

// slither-disable-next-line missing-zero-check
Expand Down
4 changes: 2 additions & 2 deletions test/MaticX.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe("MaticX", function () {
);
});

it("Should revert with the right error if passing the zero matic token address", async function () {
it("Should revert with the right error if passing the zero Matic token address", async function () {
const { validatorRegistry, stakeManager, manager, treasury } =
await loadFixture(deployFixture);

Expand All @@ -218,7 +218,7 @@ describe("MaticX", function () {
treasury.address,
]);
await expect(promise).to.be.revertedWith(
"Zero matic token address"
"Zero Matic token address"
);
});

Expand Down
34 changes: 34 additions & 0 deletions test/ValidatorRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,40 @@ describe("ValidatorRegistry", function () {
);
});

it("Should revert with the right error if passing the zero Matic token address", async function () {
const { stakeManager, maticX, manager } =
await loadFixture(deployFixture);

const ValidatorRegistry =
await ethers.getContractFactory("ValidatorRegistry");
const promise = upgrades.deployProxy(ValidatorRegistry, [
stakeManager.address,
ethers.constants.AddressZero,
maticX.address,
manager.address,
]);
await expect(promise).to.be.revertedWith(
"Zero Matic token address"
);
});

it("Should revert with the right error if passing the zero Matic token address", async function () {
const { stakeManager, maticX, matic } =
await loadFixture(deployFixture);

const ValidatorRegistry =
await ethers.getContractFactory("ValidatorRegistry");
const promise = upgrades.deployProxy(ValidatorRegistry, [
stakeManager.address,
matic.address,
maticX.address,
ethers.constants.AddressZero,
]);
await expect(promise).to.be.revertedWith(
"Zero manager address"
);
});

it("Should revert with the right error if reinitializing", async function () {
const {
validatorRegistry,
Expand Down

0 comments on commit 0cb2a14

Please sign in to comment.