Skip to content

Commit

Permalink
Rename variable on MaticX contract
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Sep 6, 2024
1 parent 87844af commit 5b12398
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions contracts/MaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ contract MaticX is
* @param _validatorRegistry - Address of the validator registry
* @param _stakeManager - Address of the stake manager
* @param _maticToken - Address of the MATIC token
* @param _admin - Address of the admin
* @param _manager - Address of the manager
* @param _treasury - Address of the treasury
*/
function initialize(
address _validatorRegistry,
address _stakeManager,
address _maticToken,
address _admin,
address _manager,
address _treasury
) external initializer {
__AccessControl_init();
__Pausable_init();
__ERC20_init("Liquid Staking Matic", "MaticX");

_setupRole(DEFAULT_ADMIN_ROLE, _admin);
_setupRole(DEFAULT_ADMIN_ROLE, _manager);

validatorRegistry = _validatorRegistry;
stakeManager = _stakeManager;
Expand Down
16 changes: 8 additions & 8 deletions test/ChildPool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
describe("ChildPool", () => {
let childPool: ChildPool;
let deployer: SignerWithAddress;
let admin: SignerWithAddress;
let manager: SignerWithAddress;
let instantPoolOwner: SignerWithAddress;
let treasury: SignerWithAddress;
let users: SignerWithAddress[] = [];
Expand Down Expand Up @@ -127,7 +127,7 @@ describe("ChildPool", () => {

beforeEach(async () => {
[deployer, ...users] = await ethers.getSigners();
admin = deployer;
manager = deployer;
treasury = users[1];
instantPoolOwner = deployer;
polygonMock = (await (
Expand All @@ -148,9 +148,9 @@ describe("ChildPool", () => {
fxStateRootTunnel = (await (
await ethers.getContractFactory("FxStateRootTunnel")
).deploy(
admin.address,
manager.address,
fxRootMock.address,
admin.address
manager.address
)) as FxStateRootTunnel;
await fxStateRootTunnel.deployed();

Expand All @@ -170,7 +170,7 @@ describe("ChildPool", () => {
stakeManagerMock.address,
polygonMock.address,
ethers.constants.AddressZero,
admin.address,
manager.address,
]
)) as ValidatorRegistry;
await validatorRegistry.deployed();
Expand All @@ -181,7 +181,7 @@ describe("ChildPool", () => {
validatorRegistry.address,
stakeManagerMock.address,
polygonMock.address,
admin.address,
manager.address,
treasury.address,
]
)) as MaticX;
Expand All @@ -192,7 +192,7 @@ describe("ChildPool", () => {
[
fxStateChildTunnel.address,
maticX.address,
admin.address,
manager.address,
instantPoolOwner.address,
treasury.address,
10,
Expand All @@ -205,7 +205,7 @@ describe("ChildPool", () => {
await validatorRegistry.addValidator(1);
await validatorRegistry.grantRole(
await validatorRegistry.BOT(),
admin.address
manager.address
);
await validatorRegistry.setPreferredDepositValidatorId(1);
await validatorRegistry.setPreferredWithdrawalValidatorId(1);
Expand Down
48 changes: 24 additions & 24 deletions test/ValidatorRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

describe("ValidatorRegistry contract", function () {
let deployer: SignerWithAddress;
let admin: SignerWithAddress;
let manager: SignerWithAddress;
let treasury: SignerWithAddress;
let users: SignerWithAddress[] = [];
let maticX: MaticX;
Expand Down Expand Up @@ -87,7 +87,7 @@ describe("ValidatorRegistry contract", function () {

beforeEach(async () => {
[deployer, ...users] = await ethers.getSigners();
admin = deployer;
manager = deployer;
treasury = deployer;

polygonMock = (await (
Expand All @@ -106,7 +106,7 @@ describe("ValidatorRegistry contract", function () {
stakeManagerMock.address,
polygonMock.address,
ethers.constants.AddressZero,
admin.address,
manager.address,
]
)) as ValidatorRegistry;
await validatorRegistry.deployed();
Expand All @@ -117,7 +117,7 @@ describe("ValidatorRegistry contract", function () {
validatorRegistry.address,
stakeManagerMock.address,
polygonMock.address,
admin.address,
manager.address,
treasury.address,
]
)) as MaticX;
Expand All @@ -128,15 +128,15 @@ describe("ValidatorRegistry contract", function () {
// add bot role for deployer
await validatorRegistry.grantRole(
await validatorRegistry.BOT(),
admin.address
manager.address
);
});

it("Should add new validators", async function () {
const validatorIds = [3, 6];

for (const id of validatorIds) {
await createValidator(admin, id);
await createValidator(manager, id);
const constractAddress = await getValidatorContract(id);
expect(constractAddress).to.be.properAddress;
}
Expand All @@ -145,7 +145,7 @@ describe("ValidatorRegistry contract", function () {
const validators = await getValidators();
expect(validators).to.be.empty;
for (const id of validatorIds) {
await expect(await addValidator(admin, id))
await expect(await addValidator(manager, id))
.emit(validatorRegistry, "AddValidator")
.withArgs(id);
expectedValidators.push(BigNumber.from(id));
Expand All @@ -155,12 +155,12 @@ describe("ValidatorRegistry contract", function () {
});

it("Should not add existing validator", async function () {
await createValidator(admin, 1);
await expect(await addValidator(admin, 1))
await createValidator(manager, 1);
await expect(await addValidator(manager, 1))
.emit(validatorRegistry, "AddValidator")
.withArgs(1);

await expect(addValidator(admin, 1)).to.be.revertedWith(
await expect(addValidator(manager, 1)).to.be.revertedWith(
"Validator id already exists in our registry"
);
});
Expand All @@ -169,8 +169,8 @@ describe("ValidatorRegistry contract", function () {
const validatorIds = [3, 6];
const expectedValidators = [];
for (const id of validatorIds) {
await createValidator(admin, id);
await expect(await addValidator(admin, id))
await createValidator(manager, id);
await expect(await addValidator(manager, id))
.emit(validatorRegistry, "AddValidator")
.withArgs(id);
expectedValidators.push(BigNumber.from(id));
Expand All @@ -179,7 +179,7 @@ describe("ValidatorRegistry contract", function () {
const validators = await getValidators();
expect(validators).to.eql(expectedValidators);
for (const id of validatorIds) {
await expect(await removeValidator(admin, id))
await expect(await removeValidator(manager, id))
.emit(validatorRegistry, "RemoveValidator")
.withArgs(id);
expectedValidators.splice(0, 1);
Expand All @@ -189,31 +189,31 @@ describe("ValidatorRegistry contract", function () {
});

it("Should not remove an validator when it is preferred for deposits", async function () {
await createValidator(admin, 1);
await addValidator(admin, 1);
await expect(await setPreferredDepositValidatorId(admin, 1))
await createValidator(manager, 1);
await addValidator(manager, 1);
await expect(await setPreferredDepositValidatorId(manager, 1))
.emit(validatorRegistry, "SetPreferredDepositValidatorId")
.withArgs(1);

await expect(removeValidator(admin, 1)).to.be.revertedWith(
await expect(removeValidator(manager, 1)).to.be.revertedWith(
"Can't remove a preferred validator for deposits"
);
});

it("Should not remove an validator when it is preferred for withdrawals", async function () {
await createValidator(admin, 1);
await addValidator(admin, 1);
await expect(await setPreferredWithdrawalValidatorId(admin, 1))
await createValidator(manager, 1);
await addValidator(manager, 1);
await expect(await setPreferredWithdrawalValidatorId(manager, 1))
.emit(validatorRegistry, "SetPreferredWithdrawalValidatorId")
.withArgs(1);

await expect(removeValidator(admin, 1)).to.be.revertedWith(
await expect(removeValidator(manager, 1)).to.be.revertedWith(
"Can't remove a preferred validator for withdrawals"
);
});

it("Should not remove non existing validator", async function () {
await expect(removeValidator(admin, 1)).to.be.revertedWith(
await expect(removeValidator(manager, 1)).to.be.revertedWith(
"Validator id doesn't exist in our registry"
);
});
Expand Down Expand Up @@ -245,8 +245,8 @@ describe("ValidatorRegistry contract", function () {

it("it should setPreferredDepositValidatorId - accesscontrol check", async () => {
const validatorId = BigNumber.from(1);
await createValidator(admin, validatorId);
await addValidator(admin, validatorId);
await createValidator(manager, validatorId);
await addValidator(manager, validatorId);

const botRole = await validatorRegistry.BOT();
await validatorRegistry.grantRole(botRole, users[1].address);
Expand Down

0 comments on commit 5b12398

Please sign in to comment.