Skip to content

Commit

Permalink
wip: debugging the build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaniza committed Mar 8, 2024
1 parent bc4dce7 commit c42ed8c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GENERAL

## The network used for testing purposes
NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon", "polygonMumbai", "base", "baseSepolia", "arbitrum", "arbitrumSepolia"]
NETWORK_NAME="polygon" # ["mainnet", "sepolia", "polygon", "polygonMumbai", "base", "baseSepolia", "arbitrum", "arbitrumSepolia"]

# CONTRACTS

Expand Down
22 changes: 19 additions & 3 deletions packages/contracts/src/TokenVotingSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {GovernanceWrappedERC20} from "./ERC20/governance/GovernanceWrappedERC20.
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {PermissionLib} from "@aragon/osx-commons-contracts/src/permission/PermissionLib.sol";
import {IPluginSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/IPluginSetup.sol";
import {PluginSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/PluginSetup.sol";
import {PluginUpgradeableSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/PluginUpgradeableSetup.sol";

import {MajorityVotingBase} from "./MajorityVotingBase.sol";
import {TokenVoting} from "./TokenVoting.sol";
Expand All @@ -27,7 +27,7 @@ import {ProxyLib} from "@aragon/osx-commons-contracts/src/utils/deployment/Proxy
/// @notice The setup contract of the `TokenVoting` plugin.
/// @dev v1.3 (Release 1, Build 3)
/// @custom:security-contact [email protected]
contract TokenVotingSetup is PluginSetup {
contract TokenVotingSetup is PluginUpgradeableSetup {
using Address for address;
using Clones for address;
using ERC165Checker for address;
Expand Down Expand Up @@ -79,7 +79,7 @@ contract TokenVotingSetup is PluginSetup {
constructor(
GovernanceERC20 _governanceERC20Base,
GovernanceWrappedERC20 _governanceWrappedERC20Base
) PluginSetup(address(new TokenVoting())) {
) PluginUpgradeableSetup(address(new TokenVoting())) {
tokenVotingBase = TokenVoting(IMPLEMENTATION);
governanceERC20Base = address(_governanceERC20Base);
governanceWrappedERC20Base = address(_governanceWrappedERC20Base);
Expand Down Expand Up @@ -208,6 +208,22 @@ contract TokenVotingSetup is PluginSetup {
preparedSetupData.permissions = permissions;
}

/// @inheritdoc IPluginSetup
/// @dev Nothing needs to happen for the update.
function prepareUpdate(
address _dao,
uint16 _currentBuild,
SetupPayload calldata _payload
)
external
pure
override
returns (bytes memory initData, PreparedSetupData memory preparedSetupData)
// solhint-disable-next-line no-empty-blocks
{

}

/// @inheritdoc IPluginSetup
function prepareUninstallation(
address _dao,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {METADATA, VERSION} from '../../plugin-settings';
import {governance} from '../../typechain/@openzeppelin/contracts-upgradeable';
import {getProductionNetworkName, findPluginRepo} from '../../utils/helpers';
import {
DEFAULT_VOTING_SETTINGS,
TokenVotingSettings,
spreadSettings,
} from '../test-utils/token-voting-constants';
import {
GovernanceERC20__factory,
Expand All @@ -24,10 +22,8 @@ import {
import {
DAO_PERMISSIONS,
PLUGIN_SETUP_PROCESSOR_PERMISSIONS,
TIME,
UnsupportedNetworkError,
getNamedTypesFromMetadata,
pctToRatio,
} from '@aragon/osx-commons-sdk';
import {
PluginSetupProcessor,
Expand Down Expand Up @@ -134,7 +130,7 @@ async function fixture(): Promise<FixtureResult> {
};
}

describe(`PluginSetup processing on network '${productionNetworkName}'`, function () {
describe.only(`PluginSetup processing on network '${productionNetworkName}'`, function () {
it('installs & uninstalls the current build with a token', async () => {
const {
alice,
Expand Down Expand Up @@ -216,7 +212,7 @@ describe(`PluginSetup processing on network '${productionNetworkName}'`, functio
});

it('installs & uninstalls the current build without a token', async () => {
const {alice, bob, deployer, psp, dao, pluginSetupRefLatestBuild} =
const {alice, deployer, psp, dao, pluginSetupRefLatestBuild} =
await loadFixture(fixture);

// Grant deployer all required permissions
Expand Down Expand Up @@ -288,7 +284,7 @@ describe(`PluginSetup processing on network '${productionNetworkName}'`, functio
);
});

it.only('updates from build 1 to the current build', async () => {
it('updates from build 1 to the current build', async () => {
const {
deployer,
psp,
Expand Down Expand Up @@ -316,7 +312,7 @@ describe(`PluginSetup processing on network '${productionNetworkName}'`, functio
);
});

it('updates from build 2 to the current build', async () => {
it.only('updates from build 2 to the current build', async () => {
const {
deployer,
psp,
Expand Down
62 changes: 48 additions & 14 deletions packages/contracts/test/20_integration-testing/test-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {METADATA, VERSION} from '../../plugin-settings';
import {
IPlugin,
PluginSetup__factory,
PluginUpgradeableSetup__factory,
ProxyFactory__factory,
} from '../../typechain';
import {ProxyCreatedEvent} from '../../typechain/@aragon/osx-commons-contracts/src/utils/deployment/ProxyFactory';
Expand Down Expand Up @@ -153,6 +153,7 @@ export async function updatePlugin(
pluginSetupRefUpdate.pluginSetupRepo
);

console.log('2a');
const prepareTx = await psp.connect(signer).prepareUpdate(dao.address, {
currentVersionTag: pluginSetupRefCurrent.versionTag,
newVersionTag: pluginSetupRefUpdate.versionTag,
Expand All @@ -170,22 +171,23 @@ export async function updatePlugin(
);

const preparedPermissions = preparedEvent.args.preparedSetupData.permissions;

console.log('2b');
await checkPermissions(
preparedPermissions,
dao,
psp,
signer,
PLUGIN_SETUP_PROCESSOR_PERMISSIONS.APPLY_UPDATE_PERMISSION_ID
);

console.log('2c');
const applyTx = await psp.connect(signer).applyUpdate(dao.address, {
plugin: plugin.address,
pluginSetupRef: pluginSetupRefUpdate,
initData: preparedEvent.args.initData,
permissions: preparedPermissions,
helpersHash: hashHelpers(preparedEvent.args.preparedSetupData.helpers),
});
console.log('2d');
const appliedEvent =
await findEvent<PluginSetupProcessorEvents.UpdateAppliedEvent>(
applyTx,
Expand Down Expand Up @@ -285,7 +287,7 @@ export async function updateFromBuildTest(
);

// Check that the implementation of the plugin proxy matches the latest build
const implementationBuild1 = await PluginSetup__factory.connect(
const implementationBuild1 = await PluginUpgradeableSetup__factory.connect(
(
await pluginRepo['getVersion((uint8,uint16))'](
pluginSetupRefBuild1.versionTag
Expand All @@ -294,7 +296,6 @@ export async function updateFromBuildTest(
deployer
).implementation();

console.log('3');
expect(await plugin.implementation()).to.equal(implementationBuild1);

// Grant the PSP the permission to upgrade the plugin implementation.
Expand All @@ -306,7 +307,39 @@ export async function updateFromBuildTest(
PLUGIN_UUPS_UPGRADEABLE_PERMISSIONS.UPGRADE_PLUGIN_PERMISSION_ID
);

// Update build 1 to the latest build
// Update build to the latest build
await updatePlugin(
deployer,
psp,
dao,
plugin,
installationResults.preparedEvent.args.preparedSetupData.helpers,
pluginSetupRefBuild1,
pluginSetupRefLatestBuild,
ethers.utils.defaultAbiCoder.encode(
getNamedTypesFromMetadata(
METADATA.build.pluginSetup.prepareUpdate[1].inputs
),
updateInputs
)
);

await updatePlugin(
deployer,
psp,
dao,
plugin,
installationResults.preparedEvent.args.preparedSetupData.helpers,
pluginSetupRefBuild1,
pluginSetupRefLatestBuild,
ethers.utils.defaultAbiCoder.encode(
getNamedTypesFromMetadata(
METADATA.build.pluginSetup.prepareUpdate[1].inputs
),
updateInputs
)
);

await expect(
updatePlugin(
deployer,
Expand All @@ -326,14 +359,15 @@ export async function updateFromBuildTest(
).to.not.be.reverted;

// Check that the implementation of the plugin proxy matches the latest build
const implementationLatestBuild = await PluginSetup__factory.connect(
(
await pluginRepo['getVersion((uint8,uint16))'](
pluginSetupRefLatestBuild.versionTag
)
).pluginSetup,
deployer
).implementation();
const implementationLatestBuild =
await PluginUpgradeableSetup__factory.connect(
(
await pluginRepo['getVersion((uint8,uint16))'](
pluginSetupRefLatestBuild.versionTag
)
).pluginSetup,
deployer
).implementation();
expect(await plugin.implementation()).to.equal(implementationLatestBuild);
}

Expand Down

0 comments on commit c42ed8c

Please sign in to comment.