chore: streamline evm module/deployer test setup (#4475)

chore: streamline module test setup
- move reusable setup into `before`
- keep necessary per-test setup in `beforeEach`
- shaves off several minutes from `yarn test:ci` time
-
[~15m](https://github.com/hyperlane-xyz/hyperlane-monorepo/actions/runs/10797378870/job/29948649484)
->
[~6m](https://github.com/hyperlane-xyz/hyperlane-monorepo/actions/runs/10802337166/job/29964269588?pr=4475)

---------

Signed-off-by: pbio <10051819+paulbalaji@users.noreply.github.com>
pull/4477/head
Paul Balaji 2 months ago committed by GitHub
parent 2e6176f675
commit 952e2df759
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      typescript/sdk/src/hook/EvmHookModule.hardhat-test.ts
  2. 8
      typescript/sdk/src/ism/EvmIsmModule.hardhat-test.ts
  3. 42
      typescript/sdk/src/ism/HyperlaneIsmFactory.hardhat-test.ts
  4. 8
      typescript/sdk/src/token/EvmERC20WarpRouteReader.hardhat-test.ts

@ -180,7 +180,7 @@ describe('EvmHookModule', async () => {
let factoryContracts: HyperlaneContracts<ProxyFactoryFactories>;
let exampleRoutingConfig: DomainRoutingHookConfig | FallbackRoutingHookConfig;
beforeEach(async () => {
before(async () => {
[signer, funder] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });

@ -98,7 +98,7 @@ describe('EvmIsmModule', async () => {
let factoryAddresses: HyperlaneAddresses<ProxyFactoryFactories>;
let factoryContracts: HyperlaneContracts<ProxyFactoryFactories>;
beforeEach(async () => {
before(async () => {
const [signer, funder] = await hre.ethers.getSigners();
fundingAccount = funder;
multiProvider = MultiProvider.createTestMultiProvider({ signer });
@ -125,6 +125,12 @@ describe('EvmIsmModule', async () => {
mailboxAddress = (
await new TestCoreDeployer(multiProvider, legacyIsmFactory).deployApp()
).getContracts(chain).mailbox.address;
});
beforeEach(async () => {
// Reset the MultiProvider for each test
const [signer] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });
// example routing config
exampleRoutingConfig = {

@ -6,9 +6,10 @@ import { DomainRoutingIsm, TrustedRelayerIsm } from '@hyperlane-xyz/core';
import { Address, randomElement, randomInt } from '@hyperlane-xyz/utils';
import { TestChainName, testChains } from '../consts/testChains.js';
import { TestCoreApp } from '../core/TestCoreApp.js';
import { HyperlaneContractsMap } from '../contracts/types.js';
import { TestCoreDeployer } from '../core/TestCoreDeployer.js';
import { HyperlaneProxyFactoryDeployer } from '../deploy/HyperlaneProxyFactoryDeployer.js';
import { ProxyFactoryFactories } from '../deploy/contracts.js';
import { MultiProvider } from '../providers/MultiProvider.js';
import { randomAddress } from '../test/testUtils.js';
@ -132,29 +133,42 @@ export const randomIsmConfig = (
};
describe('HyperlaneIsmFactory', async () => {
let ismFactoryDeployer: HyperlaneProxyFactoryDeployer;
let ismFactory: HyperlaneIsmFactory;
let coreApp: TestCoreApp;
let multiProvider: MultiProvider;
let ismFactoryDeployer: HyperlaneProxyFactoryDeployer;
let exampleRoutingConfig: RoutingIsmConfig;
let mailboxAddress: Address, newMailboxAddress: Address;
let mailboxAddress: Address;
let newMailboxAddress: Address;
let contractsMap: HyperlaneContractsMap<ProxyFactoryFactories> = {};
const chain = TestChainName.test1;
beforeEach(async () => {
before(async () => {
const [signer] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });
ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider);
ismFactory = new HyperlaneIsmFactory(
await ismFactoryDeployer.deploy(multiProvider.mapKnownChains(() => ({}))),
multiProvider,
contractsMap = await ismFactoryDeployer.deploy(
multiProvider.mapKnownChains(() => ({})),
);
let coreDeployer = new TestCoreDeployer(multiProvider, ismFactory);
coreApp = await coreDeployer.deployApp();
mailboxAddress = coreApp.getContracts(chain).mailbox.address;
ismFactory = new HyperlaneIsmFactory(contractsMap, multiProvider);
mailboxAddress = (
await new TestCoreDeployer(multiProvider, ismFactory).deployApp()
).getContracts(chain).mailbox.address;
coreDeployer = new TestCoreDeployer(multiProvider, ismFactory);
coreApp = await coreDeployer.deployApp();
newMailboxAddress = coreApp.getContracts(chain).mailbox.address;
newMailboxAddress = (
await new TestCoreDeployer(multiProvider, ismFactory).deployApp()
).getContracts(chain).mailbox.address;
});
beforeEach(async () => {
const [signer] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });
ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider);
ismFactory = new HyperlaneIsmFactory(contractsMap, multiProvider);
ismFactory.setDeployer(new TestCoreDeployer(multiProvider, ismFactory));
exampleRoutingConfig = {
type: IsmType.ROUTING,

@ -49,7 +49,7 @@ describe('ERC20WarpRouterReader', async () => {
let mailbox: Mailbox;
let evmERC20WarpRouteReader: EvmERC20WarpRouteReader;
let vault: ERC4626;
beforeEach(async () => {
before(async () => {
[signer] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });
const ismFactoryDeployer = new HyperlaneProxyFactoryDeployer(multiProvider);
@ -77,6 +77,12 @@ describe('ERC20WarpRouterReader', async () => {
vault = await vaultFactory.deploy(token.address, TOKEN_NAME, TOKEN_NAME);
});
beforeEach(async () => {
// Reset the MultiProvider and create a new deployer for each test
multiProvider = MultiProvider.createTestMultiProvider({ signer });
deployer = new HypERC20Deployer(multiProvider);
});
it('should derive a token type from contract', async () => {
const typesToDerive = [
TokenType.collateral,

Loading…
Cancel
Save