Skip to content

Commit

Permalink
Clean in-memory fork tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Apr 10, 2024
1 parent 81c7f32 commit 3963eba
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 12 deletions.
15 changes: 11 additions & 4 deletions packages/contracts/deploy/01_repo/10_create_repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
PersonalSpaceAdminPluginSetupParams,
SpacePluginSetupParams,
} from '../../plugin-setup-params';
import {isLocalChain} from '../../utils/hardhat';
import {
findEventTopicLog,
getPluginRepoFactoryAddress,
Expand Down Expand Up @@ -33,19 +34,25 @@ async function deployRepo(
const {network} = hre;
let pluginRepoFactoryAddr: string;

if (!process.env.PLUGIN_REPO_FACTORY_ADDRESS) {
if (
process.env.PLUGIN_REPO_FACTORY_ADDRESS &&
!isLocalChain(hre.network.name)
) {
// Use the given value when deploying to a live network
pluginRepoFactoryAddr = process.env.PLUGIN_REPO_FACTORY_ADDRESS;
} else {
// Use the well-known OSx addresses when in test/fork mode
pluginRepoFactoryAddr = getPluginRepoFactoryAddress(network.name);
if (!pluginRepoFactoryAddr)
if (!pluginRepoFactoryAddr) {
throw new Error(
'PLUGIN_REPO_FACTORY_ADDRESS is empty and no default value is available for ' +
network.name
);
}

console.log(
'Using the default Plugin Repo Factory address (PLUGIN_REPO_FACTORY_ADDRESS is empty)'
);
} else {
pluginRepoFactoryAddr = process.env.PLUGIN_REPO_FACTORY_ADDRESS;
}

console.log(`\nDeploying the "${ensSubdomain}" plugin repo`);
Expand Down
10 changes: 7 additions & 3 deletions packages/contracts/deploy/02_setup/10_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
PersonalSpaceAdminPluginSetupParams,
SpacePluginSetupParams,
} from '../../plugin-setup-params';
import {isLocalChain} from '../../utils/hardhat';
import {getPluginSetupProcessorAddress} from '../../utils/helpers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
Expand All @@ -13,7 +14,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployer} = await getNamedAccounts();

let pspAddress: string;
if (!process.env.PLUGIN_SETUP_PROCESSOR_ADDRESS) {
if (
process.env.PLUGIN_SETUP_PROCESSOR_ADDRESS &&
!isLocalChain(hre.network.name)
) {
pspAddress = process.env.PLUGIN_SETUP_PROCESSOR_ADDRESS;
} else {
pspAddress = getPluginSetupProcessorAddress(network.name);
if (!pspAddress)
throw new Error(
Expand All @@ -24,8 +30,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(
'Using the default Plugin Setup Processor address (PLUGIN_SETUP_PROCESSOR_ADDRESS is empty)'
);
} else {
pspAddress = process.env.PLUGIN_SETUP_PROCESSOR_ADDRESS;
}

// Space Setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
InstallationPreparedEvent,
PluginSetupRefStruct,
} from '../../typechain/@aragon/osx/framework/plugin/setup/PluginSetupProcessor';
import {isLocalChain} from '../../utils/hardhat';
import {findEvent, hashHelpers} from '../../utils/helpers';
import {getPluginRepoInfo} from '../../utils/plugin-repo-info';
import {IDAO, IDAO__factory, PluginSetupProcessor} from '@aragon/osx-ethers';
Expand Down Expand Up @@ -140,3 +141,5 @@ func.tags = [
GovernancePluginsSetupParams.PLUGIN_SETUP_CONTRACT_NAME,
'ManagingDAO',
];
func.skip = (hre: HardhatRuntimeEnvironment) =>
Promise.resolve(isLocalChain(hre.network.name));
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {isLocalChain} from '../../utils/hardhat';
import {DAO__factory, IDAO} from '@aragon/osx-ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
Expand Down Expand Up @@ -36,3 +37,5 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

export default func;
func.tags = ['ManagingDAO'];
func.skip = (hre: HardhatRuntimeEnvironment) =>
Promise.resolve(isLocalChain(hre.network.name));
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {verifyContract} from '../../utils/etherscan';
import {isLocalChain} from '../../utils/hardhat';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

Expand Down Expand Up @@ -31,8 +32,4 @@ export default func;
func.tags = ['Verification'];
func.runAtTheEnd = true;
func.skip = (hre: HardhatRuntimeEnvironment) =>
Promise.resolve(
hre.network.name === 'localhost' ||
hre.network.name === 'hardhat' ||
hre.network.name === 'coverage'
);
Promise.resolve(isLocalChain(hre.network.name));
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {isLocalChain} from '../../utils/hardhat';
import {DAO__factory} from '@aragon/osx-ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
Expand Down Expand Up @@ -31,3 +32,5 @@ export default func;

func.tags = ['Verification'];
func.runAtTheEnd = true;
func.skip = (hre: HardhatRuntimeEnvironment) =>
Promise.resolve(isLocalChain(hre.network.name));
3 changes: 3 additions & 0 deletions packages/contracts/deploy/99_verification/21_mgmt_dao_root.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {isLocalChain} from '../../utils/hardhat';
import {DAO__factory} from '@aragon/osx-ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
Expand Down Expand Up @@ -29,3 +30,5 @@ export default func;

func.tags = ['Verification'];
func.runAtTheEnd = true;
func.skip = (hre: HardhatRuntimeEnvironment) =>
Promise.resolve(isLocalChain(hre.network.name));
3 changes: 3 additions & 0 deletions packages/contracts/utils/hardhat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isLocalChain(networkName: string) {
return ['localhost', 'hardhat', 'coverage'].includes(networkName);
}

0 comments on commit 3963eba

Please sign in to comment.