The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/core/test/common.test.ts

46 lines
1.6 KiB

import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { ethers } from 'hardhat';
import { expect } from 'chai';
import { TestCommon__factory, TestCommon } from '../types';
const localDomain = 1000;
const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner';
describe('Common', async () => {
let owner: SignerWithAddress, nonowner: SignerWithAddress, common: TestCommon;
before(async () => {
[owner, nonowner] = await ethers.getSigners();
});
beforeEach(async () => {
const commonFactory = new TestCommon__factory(owner);
common = await commonFactory.deploy(localDomain);
// The ValidatorManager is unused in these tests *but* needs to be a
// contract.
await common.initialize(common.address);
expect(await common.validatorManager()).to.equal(common.address);
});
it('Cannot be initialized twice', async () => {
await expect(common.initialize(common.address)).to.be.revertedWith(
'Initializable: contract is already initialized',
);
});
it('Allows owner to update the ValidatorManager', async () => {
const commonFactory = new TestCommon__factory(owner);
const newValidatorManager = await commonFactory.deploy(localDomain);
await common.setValidatorManager(newValidatorManager.address);
expect(await common.validatorManager()).to.equal(
newValidatorManager.address,
);
});
it('Does not allow nonowner to update the ValidatorManager', async () => {
await expect(
common.connect(nonowner).setValidatorManager(common.address),
).to.be.revertedWith(ONLY_OWNER_REVERT_MSG);
});
});