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/test/hyperlaneConnectionClient.t...

93 lines
2.9 KiB

import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { expect } from 'chai';
import { ethers } from 'hardhat';
import {
InterchainGasPaymaster,
Mailbox,
Mailbox__factory,
TestHyperlaneConnectionClient,
TestHyperlaneConnectionClient__factory,
TestInterchainGasPaymaster__factory,
} from '../types';
const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner';
describe('HyperlaneConnectionClient', async () => {
let connectionClient: TestHyperlaneConnectionClient,
mailbox: Mailbox,
newMailbox: Mailbox,
signer: SignerWithAddress,
nonOwner: SignerWithAddress;
before(async () => {
[signer, nonOwner] = await ethers.getSigners();
});
beforeEach(async () => {
const mailboxFactory = new Mailbox__factory(signer);
const domain = 1000;
mailbox = await mailboxFactory.deploy(domain, signer.address);
newMailbox = await mailboxFactory.deploy(domain, signer.address);
const connectionClientFactory = new TestHyperlaneConnectionClient__factory(
signer,
);
connectionClient = await connectionClientFactory.deploy();
await connectionClient.initialize(mailbox.address);
});
it('Cannot be initialized twice', async () => {
await expect(
connectionClient.initialize(mailbox.address),
).to.be.revertedWith('Initializable: contract is already initialized');
});
it('owner can set mailbox', async () => {
expect(await connectionClient.mailbox()).to.not.equal(newMailbox.address);
await expect(connectionClient.setMailbox(newMailbox.address)).to.emit(
connectionClient,
'MailboxSet',
);
expect(await connectionClient.mailbox()).to.equal(newMailbox.address);
});
it('non-owner cannot set mailbox', async () => {
await expect(
connectionClient.connect(nonOwner).setMailbox(newMailbox.address),
).to.be.revertedWith(ONLY_OWNER_REVERT_MSG);
});
describe('#setInterchainGasPaymaster', () => {
let newPaymaster: InterchainGasPaymaster;
before(async () => {
const paymasterFactory = new TestInterchainGasPaymaster__factory(signer);
On chain gas oracles in the IGP (#1765) * Rough implementations of all gas oracles, done with StaticGasOracle & tests * more tests, beef up StorageGasOracle * Tests cleaned up, moved to Foundry test for IGP * rm StaticGasOracle, fix all tests * cleaning up * comment * yarn gas, better comments * Fix sdk test * Fix e2e * Rm LZ stuff * fix router test * Rm MockInterchainGasPaymaster * pr comments * Move to setGasConfigs instead of setGasConfig * fix test * nit * yarn gas * IGP deploy & checker tooling, script to update on-chain StorageGasOracle data (#1794) * Add IGP gas oracle to checker * Checker works * Support different gas oracle contracts in IGP deploy tooling too * Export some types * Build out set-storage-gas-oracle-values * nit * nit * rm comment * Add pricing data * nits * nearly there * haven't tested e2e yet, but added new proxy upgrade logic to set gas oracles in IGP in upgradeAndCall * pr comments * lots * Move away from upgradeAndCall for IGP upgrade, trying to debug annoying dependency issue * Got working, cleaned a little * Add test to ensure a new implementation is deployed * yarn hyperlane * nits * cleaning * Map in description * Dedupe submission type logic * yarn gas * Separate beneficiary in IGP (#1801) * Add IGP gas oracle to checker * Checker works * Support different gas oracle contracts in IGP deploy tooling too * Export some types * Build out set-storage-gas-oracle-values * nit * nit * Add separate beneficiary to IGP * Checker / govern / deploy tooling * nits * Add compare-storage-gas-oracle * successful test upgrade, minor changes * Nits * Fix tests * Performed testne3 upgrade. Need to clean up code, but should probably use this for the mainnet upgrade * nit * update prices * Update gas prices and token exchange rates for mainnet * mainnet upgrade. needs lots of cleaning, but here it is in all its glory * Starting to clean up * more cleanup * Use updated submodules * yarn gas * nit * PR comments * yarn hyperlane * yarn gas
2 years ago
newPaymaster = await paymasterFactory.deploy(signer.address);
});
it('Allows owner to set the interchainGasPaymaster', async () => {
await connectionClient.setInterchainGasPaymaster(newPaymaster.address);
expect(await connectionClient.interchainGasPaymaster()).to.equal(
newPaymaster.address,
);
});
it('Emits the SetInterchainGasPaymaster event', async () => {
await expect(
connectionClient.setInterchainGasPaymaster(newPaymaster.address),
)
.to.emit(connectionClient, 'InterchainGasPaymasterSet')
.withArgs(newPaymaster.address);
});
it('Reverts a call from non-owner', async () => {
await expect(
connectionClient
.connect(nonOwner)
.setInterchainGasPaymaster(newPaymaster.address),
).to.be.revertedWith(ONLY_OWNER_REVERT_MSG);
});
});
});