From b0ec215fb8f688d47656d46d22999aaaeb3ab0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8r=E2=88=82=C2=A1?= Date: Mon, 29 Jan 2024 14:28:45 +0100 Subject: [PATCH] Adapting tests WIP --- README.md | 23 + .../MemberAccessExecuteCondition.sol | 48 +- .../governance/governance-build-metadata.json | 2 +- .../governance-plugins-setup.ts | 3 +- .../member-access-condition.ts | 3 +- .../integration-testing/plugin-upgrader.ts | 7 +- .../contracts/test/unit-testing/common.ts | 4 +- .../unit-testing/governance-plugins-setup.ts | 4 +- .../test/unit-testing/main-voting-plugin.ts | 437 ++---------------- .../member-access-execute-condition.ts | 35 -- .../test/unit-testing/member-access-plugin.ts | 121 +++-- .../personal-space-admin-plugin.ts | 3 +- 12 files changed, 135 insertions(+), 555 deletions(-) diff --git a/README.md b/README.md index ab5194d..8097e6f 100644 --- a/README.md +++ b/README.md @@ -609,3 +609,26 @@ When a zero address is passed, only a passed proposal can make the DAO call `PSP Every new version needs to be published to the plugin's repository. [Learn more about plugin upgrades](https://devs.aragon.org/docs/osx/how-to-guides/plugin-development/upgradeable-plugin/updating-versions). + +## Dependencies forked from Aragon + +The plugins from this repo are built on top of many contract primitives from Aragon. In some cases, certain parameters are not required or data types need to differ. For this reason, the `packages/contracts/src/governance/base` folder contains 5 forks of existing Aragon primitives. + +- `Addresslist.sol` + - Functions `addMembers` and `removeMembers` accepted an `address[] calldata` parameter + - However, the plugin needed to pass an `address[] memory` +- `IEditors.sol` and `IMembers.sol` + - Originally from `IMembership.sol` + - Geo defines a concept of members with conflicted with how the address list interprets its "members" (which are editors) + - Using separate, explicit interfaces to clarify the difference between members and editors +- `IMultisig.sol` + - The `accept()` function required 2 parameters, of which the second always has to be `true`. + - Changing the signature of `accept()` to only use relevant parameters +- `MajorityVotingBase.sol` + - `createProposal()` originally had two parameters that didn't apply to the current specs. + - The forked version Omits these 2 parameters (start date and end date) and instead: + - Starts immediately + - Ends after the predefined duration + - `minDuration()` was confusing given that the setting is used as the final duration, so `duration()` is used instead + +The rest of dependencies are imported directly from Aragon or from OpenZeppelin. diff --git a/packages/contracts/src/conditions/MemberAccessExecuteCondition.sol b/packages/contracts/src/conditions/MemberAccessExecuteCondition.sol index f6a784e..72d712a 100644 --- a/packages/contracts/src/conditions/MemberAccessExecuteCondition.sol +++ b/packages/contracts/src/conditions/MemberAccessExecuteCondition.sol @@ -6,6 +6,7 @@ import {IDAO} from "@aragon/osx/core/dao/IDAO.sol"; import {PermissionCondition} from "@aragon/osx/core/permission/PermissionCondition.sol"; import {PermissionManager} from "@aragon/osx/core/permission/PermissionManager.sol"; import {MEMBER_PERMISSION_ID} from "../constants.sol"; +import {MainVotingPlugin} from "../governance/MainVotingPlugin.sol"; /// @notice The condition associated with `TestSharedPlugin` contract MemberAccessExecuteCondition is PermissionCondition { @@ -18,7 +19,7 @@ contract MemberAccessExecuteCondition is PermissionCondition { targetContract = _targetContract; } - /// @notice Checks whether the current action wants to grant membership on the predefined address + /// @notice Checks whether the current action attempts to add or remove members function isGranted( address _where, address _who, @@ -27,35 +28,15 @@ contract MemberAccessExecuteCondition is PermissionCondition { ) external view returns (bool) { (_where, _who, _permissionId); - // Is execute()? - if (getSelector(_data) != IDAO.execute.selector) { + if ( + getSelector(_data) != MainVotingPlugin.addMember.selector && + getSelector(_data) != MainVotingPlugin.removeMember.selector + ) { + return false; + } else if (_where != targetContract) { return false; } - (, IDAO.Action[] memory _actions, ) = abi.decode( - _data[4:], - (bytes32, IDAO.Action[], uint256) - ); - - // Check actions - if (_actions.length != 1) return false; - - // Decode the call being requested (both have the same parameters) - ( - bytes4 _requestedSelector, - address _requestedWhere, - , - bytes32 _requestedPermission - ) = decodeGrantRevokeCalldata(_actions[0].data); - - if ( - _requestedSelector != PermissionManager.grant.selector && - _requestedSelector != PermissionManager.revoke.selector - ) return false; - - if (_requestedWhere != targetContract) return false; - else if (_requestedPermission != MEMBER_PERMISSION_ID) return false; - return true; } @@ -66,17 +47,4 @@ contract MemberAccessExecuteCondition is PermissionCondition { selector := mload(add(_data, 0x20)) // 32 } } - - function decodeGrantRevokeCalldata( - bytes memory _data - ) public pure returns (bytes4 sig, address where, address who, bytes32 permissionId) { - // Slicing is only supported for bytes calldata, not bytes memory - // Bytes memory requires an assembly block - assembly { - sig := mload(add(_data, 0x20)) // 32 - where := mload(add(_data, 0x24)) // 32 + 4 - who := mload(add(_data, 0x44)) // 32 + 4 + 32 - permissionId := mload(add(_data, 0x64)) // 32 + 4 + 32 + 32 - } - } } diff --git a/packages/contracts/src/governance/governance-build-metadata.json b/packages/contracts/src/governance/governance-build-metadata.json index 885f250..4188365 100644 --- a/packages/contracts/src/governance/governance-build-metadata.json +++ b/packages/contracts/src/governance/governance-build-metadata.json @@ -24,7 +24,7 @@ }, { "internalType": "uint64", - "name": "minDuration", + "name": "duration", "type": "uint64" }, { diff --git a/packages/contracts/test/integration-testing/governance-plugins-setup.ts b/packages/contracts/test/integration-testing/governance-plugins-setup.ts index bc0edda..0e4b9b5 100644 --- a/packages/contracts/test/integration-testing/governance-plugins-setup.ts +++ b/packages/contracts/test/integration-testing/governance-plugins-setup.ts @@ -28,10 +28,9 @@ import {ethers} from 'hardhat'; const release = 1; const hardhatForkNetwork = process.env.NETWORK_NAME ?? 'mainnet'; const pluginSettings: MajorityVotingBase.VotingSettingsStruct = { - minDuration: 60 * 60 * 24, + duration: 60 * 60 * 24, minParticipation: 1, supportThreshold: 1, - minProposerVotingPower: 0, votingMode: 0, }; const minMemberAccessProposalDuration = 60 * 60 * 24; diff --git a/packages/contracts/test/integration-testing/member-access-condition.ts b/packages/contracts/test/integration-testing/member-access-condition.ts index eb17826..6e3f63a 100644 --- a/packages/contracts/test/integration-testing/member-access-condition.ts +++ b/packages/contracts/test/integration-testing/member-access-condition.ts @@ -41,10 +41,9 @@ import {ethers, network} from 'hardhat'; const release = 1; const hardhatForkNetwork = process.env.NETWORK_NAME ?? 'mainnet'; const pluginSettings: MajorityVotingBase.VotingSettingsStruct = { - minDuration: 60 * 60 * 24, + duration: 60 * 60 * 24, minParticipation: 1, supportThreshold: 1, - minProposerVotingPower: 0, votingMode: 0, }; const minMemberAccessProposalDuration = 60 * 60 * 24; diff --git a/packages/contracts/test/integration-testing/plugin-upgrader.ts b/packages/contracts/test/integration-testing/plugin-upgrader.ts index a407021..2b4c1ab 100644 --- a/packages/contracts/test/integration-testing/plugin-upgrader.ts +++ b/packages/contracts/test/integration-testing/plugin-upgrader.ts @@ -50,10 +50,9 @@ import {ethers, network} from 'hardhat'; const release = 1; const hardhatForkNetwork = process.env.NETWORK_NAME ?? 'mainnet'; const pluginSettings: MajorityVotingBase.VotingSettingsStruct = { - minDuration: 60 * 60 * 24, + duration: 60 * 60 * 24, minParticipation: 1, supportThreshold: 1, - minProposerVotingPower: 0, votingMode: 0, }; const minMemberAccessProposalDuration = 60 * 60 * 24; @@ -269,8 +268,8 @@ describe('Plugin upgrader', () => { to: mainVotingPlugin.address, value: 0, data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[pluginUpgrader.address]] + 'addEditor', + [pluginUpgrader.address] ), }, ], diff --git a/packages/contracts/test/unit-testing/common.ts b/packages/contracts/test/unit-testing/common.ts index ff91be2..130f93e 100644 --- a/packages/contracts/test/unit-testing/common.ts +++ b/packages/contracts/test/unit-testing/common.ts @@ -89,12 +89,12 @@ export type VotingSettings = { votingMode: number; supportThreshold: BigNumber; minParticipation: BigNumber; - minDuration: number; + duration: number; minProposerVotingPower: number; }; export const defaultMainVotingSettings: VotingSettings = { - minDuration: 60 * 60, // 1 second + duration: 60 * 60, // 1 second minParticipation: pctToRatio(30), // 30% supportThreshold: pctToRatio(50), // 50% + 1 minProposerVotingPower: 0, diff --git a/packages/contracts/test/unit-testing/governance-plugins-setup.ts b/packages/contracts/test/unit-testing/governance-plugins-setup.ts index f08a5e3..fa720f4 100644 --- a/packages/contracts/test/unit-testing/governance-plugins-setup.ts +++ b/packages/contracts/test/unit-testing/governance-plugins-setup.ts @@ -57,7 +57,7 @@ describe('Governance Plugins Setup', function () { votingMode: VotingMode.EarlyExecution, supportThreshold: pctToRatio(25), minParticipation: pctToRatio(50), - minDuration: 60 * 60 * 24 * 5, + duration: 60 * 60 * 24 * 5, minProposerVotingPower: 0, }, [alice.address], @@ -158,7 +158,7 @@ describe('Governance Plugins Setup', function () { votingMode: VotingMode.EarlyExecution, supportThreshold: pctToRatio(25), minParticipation: pctToRatio(50), - minDuration: 60 * 60 * 24 * 5, + duration: 60 * 60 * 24 * 5, minProposerVotingPower: 0, }, [alice.address], diff --git a/packages/contracts/test/unit-testing/main-voting-plugin.ts b/packages/contracts/test/unit-testing/main-voting-plugin.ts index 55fe4e7..7070e87 100644 --- a/packages/contracts/test/unit-testing/main-voting-plugin.ts +++ b/packages/contracts/test/unit-testing/main-voting-plugin.ts @@ -13,7 +13,7 @@ import {ExecutedEvent} from '../../typechain/@aragon/osx/core/dao/DAO'; import { // ProposalCreatedEvent, ProposalExecutedEvent, -} from '../../typechain/src/MainVotingPlugin'; +} from '../../typechain/src/governance/MainVotingPlugin'; import { deployWithProxy, findEvent, @@ -214,8 +214,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -226,8 +224,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -238,8 +234,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -252,8 +246,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -268,8 +260,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -312,8 +302,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -325,8 +313,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -338,8 +324,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -351,8 +335,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -414,8 +396,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -433,8 +413,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -526,8 +504,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -568,8 +544,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -607,8 +581,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -626,8 +598,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -646,8 +616,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -688,8 +656,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -727,8 +693,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -769,8 +733,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -805,8 +767,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.None, true // auto execute ) @@ -867,8 +827,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), [], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -963,106 +921,6 @@ describe('Main Voting Plugin', function () { expect(await mainVotingPlugin.addresslistLength()).to.eq(1); }); - it('Adding more than one editor at once reverts', async () => { - // 2 - let actions: IDAO.ActionStruct[] = [ - { - to: mainVotingPlugin.address, - value: 0, - data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[bob.address, carol.address]] - ), - }, - ]; - - expect(await mainVotingPlugin.isEditor(bob.address)).to.be.false; - await expect( - dao.execute(ZERO_BYTES32, actions, 0) - ).to.be.revertedWithCustomError(dao, 'ActionFailed'); - expect(await mainVotingPlugin.isEditor(bob.address)).to.be.false; - - // 3 - actions = [ - { - to: mainVotingPlugin.address, - value: 0, - data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[bob.address, carol.address, dave.address]] - ), - }, - ]; - expect(await mainVotingPlugin.isEditor(bob.address)).to.be.false; - await expect( - dao.execute(ZERO_BYTES32, actions, 0) - ).to.be.revertedWithCustomError(dao, 'ActionFailed'); - expect(await mainVotingPlugin.isEditor(bob.address)).to.be.false; - - // 1 works - actions = [ - { - to: mainVotingPlugin.address, - value: 0, - data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[bob.address]] - ), - }, - ]; - - await expect(dao.execute(ZERO_BYTES32, actions, 0)).to.not.be.reverted; - }); - - it('Removing more than one editor at once reverts', async () => { - await makeEditor(bob.address); - await makeEditor(carol.address); - - // 2 - let actions: IDAO.ActionStruct[] = [ - { - to: mainVotingPlugin.address, - value: 0, - data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'removeAddresses', - [[bob.address, carol.address]] - ), - }, - ]; - await expect( - dao.execute(ZERO_BYTES32, actions, 0) - ).to.be.revertedWithCustomError(dao, 'ActionFailed'); - - // 3 - actions = [ - { - to: mainVotingPlugin.address, - value: 0, - data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'removeAddresses', - [[bob.address, carol.address]] - ), - }, - ]; - await expect( - dao.execute(ZERO_BYTES32, actions, 0) - ).to.be.revertedWithCustomError(dao, 'ActionFailed'); - - // 1 works - actions = [ - { - to: mainVotingPlugin.address, - value: 0, - data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'removeAddresses', - [[bob.address]] - ), - }, - ]; - - await expect(dao.execute(ZERO_BYTES32, actions, 0)).to.not.be.reverted; - }); - it('Attempting to remove the last editor reverts', async () => { // Try to remove Alice await expect(pullEditor(alice.address)).to.be.revertedWithCustomError( @@ -1179,16 +1037,13 @@ describe('Main Voting Plugin', function () { votingMode: 0, supportThreshold: 12345, minParticipation: 23456, - minDuration: 60 * 60 * 3, - minProposerVotingPower: 0, + duration: 60 * 60 * 3, }, ] ), }, ], 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -1199,14 +1054,14 @@ describe('Main Voting Plugin', function () { it('The DAO can add editors', async () => { // Nobody else can - await expect(mainVotingPlugin.connect(alice).addAddresses([bob.address])) - .to.be.reverted; - await expect(mainVotingPlugin.connect(bob).addAddresses([bob.address])).to + await expect(mainVotingPlugin.connect(alice).addEditor(bob.address)).to.be + .reverted; + await expect(mainVotingPlugin.connect(bob).addEditor(bob.address)).to.be + .reverted; + await expect(mainVotingPlugin.connect(carol).addEditor(dave.address)).to .be.reverted; - await expect(mainVotingPlugin.connect(carol).addAddresses([dave.address])) - .to.be.reverted; - await expect(mainVotingPlugin.connect(dave).addAddresses([dave.address])) - .to.be.reverted; + await expect(mainVotingPlugin.connect(dave).addEditor(dave.address)).to.be + .reverted; // The DAO can const actions: IDAO.ActionStruct[] = [ @@ -1214,8 +1069,8 @@ describe('Main Voting Plugin', function () { to: mainVotingPlugin.address, value: 0, data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[dave.address]] + 'addEditor', + [dave.address] ), }, ]; @@ -1227,17 +1082,14 @@ describe('Main Voting Plugin', function () { await makeEditor(bob.address); // Nobody else can - await expect( - mainVotingPlugin.connect(alice).removeAddresses([bob.address]) - ).to.be.reverted; - await expect(mainVotingPlugin.connect(bob).removeAddresses([bob.address])) - .to.be.reverted; - await expect( - mainVotingPlugin.connect(carol).removeAddresses([bob.address]) - ).to.be.reverted; - await expect( - mainVotingPlugin.connect(dave).removeAddresses([bob.address]) - ).to.be.reverted; + await expect(mainVotingPlugin.connect(alice).removeEditor(bob.address)).to + .be.reverted; + await expect(mainVotingPlugin.connect(bob).removeEditor(bob.address)).to + .be.reverted; + await expect(mainVotingPlugin.connect(carol).removeEditor(bob.address)).to + .be.reverted; + await expect(mainVotingPlugin.connect(dave).removeEditor(bob.address)).to + .be.reverted; // The DAO can const actions: IDAO.ActionStruct[] = [ @@ -1245,8 +1097,8 @@ describe('Main Voting Plugin', function () { to: mainVotingPlugin.address, value: 0, data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'removeAddresses', - [[bob.address]] + 'removeEditor', + [bob.address] ), }, ]; @@ -1313,8 +1165,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), actions, 0, // fail safe - 0, // start date - 0, // end date approving ? VoteOption.Yes : VoteOption.None, true // auto execute ) @@ -1327,8 +1177,8 @@ describe('Main Voting Plugin', function () { to: mainVotingPlugin.address, value: 0, data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[_editor]] + 'addEditor', + [_editor] ), }, ]; @@ -1339,8 +1189,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), actions, 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -1353,8 +1201,8 @@ describe('Main Voting Plugin', function () { to: mainVotingPlugin.address, value: 0, data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'removeAddresses', - [[_editor]] + 'removeEditor', + [_editor] ), }, ]; @@ -1365,8 +1213,6 @@ describe('Main Voting Plugin', function () { toUtf8Bytes('ipfs://'), actions, 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) @@ -1381,7 +1227,7 @@ describe('Main Voting Plugin', function () { UPDATE_ADDRESSES_PERMISSION_ID ) .then(tx => tx.wait()) - .then(() => mainVotingPlugin.addAddresses([targetAddress])) + .then(() => mainVotingPlugin.addEditor(targetAddress)) .then(tx => tx.wait()) .then(() => dao.revoke( @@ -1400,7 +1246,7 @@ describe('Main Voting Plugin', function () { UPDATE_ADDRESSES_PERMISSION_ID ) .then(tx => tx.wait()) - .then(() => mainVotingPlugin.removeAddresses([targetAddress])) + .then(() => mainVotingPlugin.removeEditor(targetAddress)) .then(tx => tx.wait()) .then(() => dao.revoke( @@ -1425,7 +1271,7 @@ describe('Tests replicated from the original AddressList plugin', async () => { let endDate: number; let dummyMetadata: string; let dummyActions: IDAO.ActionStruct[]; - const startOffset = 10; + const startOffset = 0; before(async () => { signers = (await ethers.getSigners()).slice(0, 10); @@ -1489,182 +1335,6 @@ describe('Tests replicated from the original AddressList plugin', async () => { ]; }); - // describe("Proposal creation", async () => { - // it("reverts if the start date is set smaller than the current date", async () => { - // await mainVotingPlugin.initialize( - // dao.address, - // votingSettings, - // [signers[0].address], - // ); - // expect(await mainVotingPlugin.isMember(signers[0].address)).to.be.true; - // expect(await mainVotingPlugin.isEditor(signers[0].address)).to.be.true; - - // const currentDate = await getTime(); - // const startDateInThePast = currentDate - 1; - // const endDate = 0; // startDate + minDuration - - // await expect( - // mainVotingPlugin.createProposal( - // dummyMetadata, - // [], - // 0, - // startDateInThePast, - // endDate, - // VoteOption.None, - // false, - // ), - // ) - // .to.be.revertedWithCustomError(mainVotingPlugin, "DateOutOfBounds") - // .withArgs( - // currentDate + 1, // await takes one second - // startDateInThePast, - // ); - // }); - - // it("reverts if the start date is after the latest start date", async () => { - // await mainVotingPlugin.initialize( - // dao.address, - // votingSettings, - // [signers[0].address], - // ); - // await makeEditors(signers.slice(1)); - - // const latestStartDate = MAX_UINT64.sub(votingSettings.minDuration); - // const tooLateStartDate = latestStartDate.add(1); - // const endDate = 0; // startDate + minDuration - - // await expect( - // mainVotingPlugin.createProposal( - // dummyMetadata, - // [], - // 0, - // tooLateStartDate, - // endDate, - // VoteOption.None, - // false, - // ), - // ).to.be.revertedWithPanic(0x11); - // }); - - // it("reverts if the end date is before the earliest end date so that min duration cannot be met", async () => { - // await mainVotingPlugin.initialize( - // dao.address, - // votingSettings, - // [signers[0].address], - // ); - // await makeEditors(signers.slice(1)); - - // const startDate = (await getTime()) + 1; - // const earliestEndDate = startDate + votingSettings.minDuration; - // const tooEarlyEndDate = earliestEndDate - 1; - - // await expect( - // mainVotingPlugin.createProposal( - // dummyMetadata, - // [], - // 0, - // startDate, - // tooEarlyEndDate, - // VoteOption.None, - // false, - // ), - // ) - // .to.be.revertedWithCustomError(mainVotingPlugin, "DateOutOfBounds") - // .withArgs(earliestEndDate, tooEarlyEndDate); - // }); - - // it("sets the startDate to now and endDate to startDate + minDuration, if 0 is provided as an input", async () => { - // await mainVotingPlugin.initialize( - // dao.address, - // votingSettings, - // [signers[0].address], - // ); - // await makeEditors(signers.slice(1)); - - // // Create a proposal with zero as an input for `_startDate` and `_endDate` - // const startDate = 0; // now - // const endDate = 0; // startDate + minDuration - - // const creationTx = await mainVotingPlugin.createProposal( - // dummyMetadata, - // [], - // 0, - // startDate, - // endDate, - // VoteOption.None, - // false, - // ); - - // const currentTime = ( - // await ethers.provider.getBlock((await creationTx.wait()).blockNumber) - // ).timestamp; - - // const expectedStartDate = currentTime; - // const expectedEndDate = expectedStartDate + votingSettings.minDuration; - - // // Check the state - // const proposal = await mainVotingPlugin.getProposal(id); - // expect(proposal.parameters.startDate).to.eq(expectedStartDate); - // expect(proposal.parameters.endDate).to.eq(expectedEndDate); - - // // Check the event - // const event = await findEvent( - // creationTx, - // "ProposalCreated", - // ); - - // expect(event!.args.proposalId).to.equal(id); - // expect(event!.args.creator).to.equal(signers[0].address); - // expect(event!.args.startDate).to.equal(expectedStartDate); - // expect(event!.args.endDate).to.equal(expectedEndDate); - // expect(event!.args.metadata).to.equal(dummyMetadata); - // expect(event!.args.actions).to.deep.equal([]); - // expect(event!.args.allowFailureMap).to.equal(0); - // }); - - // it("reverts creation if the creator tries to vote and the start date if in the future", async () => { - // await mainVotingPlugin.initialize( - // dao.address, - // votingSettings, - // [signers[0].address], - // ); - // startDate = (await getTime()) + startOffset; - // endDate = startDate + votingSettings.minDuration; - - // expect(await getTime()).to.be.lessThan(startDate); - - // // Reverts if the vote option is not 'None' - // await expect( - // mainVotingPlugin.createProposal( - // dummyMetadata, - // dummyActions, - // 0, - // startDate, - // endDate, - // VoteOption.Yes, - // false, - // ), - // ) - // .to.be.revertedWithCustomError(mainVotingPlugin, "VoteCastForbidden") - // .withArgs(id, signers[0].address, VoteOption.Yes); - - // // Works if the vote option is 'None' - // expect( - // ( - // await mainVotingPlugin.createProposal( - // dummyMetadata, - // dummyActions, - // 0, - // startDate, - // endDate, - // VoteOption.None, - // false, - // ) - // ).value, - // ).to.equal(id); - // }); - // }); - describe('Proposal + Execute:', async () => { context('Standard Mode', async () => { beforeEach(async () => { @@ -1676,14 +1346,12 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - startDate, - endDate, VoteOption.None, false ); @@ -1817,40 +1485,17 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - startDate, - endDate, VoteOption.None, false ); }); - // it("does not allow voting, when the vote has not started yet", async () => { - // expect(await getTime()).to.be.lessThan(startDate); - - // expect( - // await mainVotingPlugin.canVote( - // id, - // signers[0].address, - // VoteOption.Yes, - // ), - // ) - // .to - // .be.false; - - // await expect(mainVotingPlugin.vote(id, VoteOption.Yes, false)) - // .to.be.revertedWithCustomError( - // mainVotingPlugin, - // "VoteCastForbidden", - // ) - // .withArgs(id, signers[0].address, VoteOption.Yes); - // }); - it('increases the yes, no, and abstain count and emits correct events', async () => { await advanceIntoVoteTime(startDate, endDate); @@ -2046,14 +1691,12 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - startDate, - endDate, VoteOption.None, false ); @@ -2198,14 +1841,12 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - 0, - 0, VoteOption.None, false ); @@ -2321,14 +1962,12 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - startDate, - endDate, VoteOption.None, false ); @@ -2480,14 +2119,12 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - startDate, - endDate, VoteOption.None, false ); @@ -2544,14 +2181,12 @@ describe('Tests replicated from the original AddressList plugin', async () => { await makeEditors(signers.slice(1)); // editors 2-10 startDate = (await getTime()) + startOffset; - endDate = startDate + votingSettings.minDuration; + endDate = startDate + votingSettings.duration; await mainVotingPlugin.createProposal( dummyMetadata, dummyActions, 0, - startDate, - endDate, VoteOption.None, false ); @@ -2653,7 +2288,7 @@ describe('Tests replicated from the original AddressList plugin', async () => { Promise.all( targetAddress.map(targetAddress => mainVotingPlugin - .addAddresses([targetAddress.address]) + .addEditor(targetAddress.address) .then(tx => tx.wait()) ) ) diff --git a/packages/contracts/test/unit-testing/member-access-execute-condition.ts b/packages/contracts/test/unit-testing/member-access-execute-condition.ts index 2a5668c..1879525 100644 --- a/packages/contracts/test/unit-testing/member-access-execute-condition.ts +++ b/packages/contracts/test/unit-testing/member-access-execute-condition.ts @@ -458,40 +458,5 @@ describe('Member Access Condition', function () { await memberAccessExecuteCondition.getSelector(actions[1].data) ).to.eq((actions[1].data as string).slice(0, 10)); }); - - it('Should decode decodeGrantRevokeCalldata properly', async () => { - const calldataList = [ - daoInterface.encodeFunctionData('grant', [ - PLUGIN_ADDR_1, - pspAddress, - MEMBER_PERMISSION_ID, - ]), - daoInterface.encodeFunctionData('revoke', [ - PLUGIN_ADDR_2, - bob.address, - ROOT_PERMISSION_ID, - ]), - ]; - - // 1 - let [selector, where, who, permissionId] = - await memberAccessExecuteCondition.decodeGrantRevokeCalldata( - calldataList[0] - ); - expect(selector).to.eq(calldataList[0].slice(0, 10)); - expect(where).to.eq(PLUGIN_ADDR_1); - expect(who).to.eq(pspAddress); - expect(permissionId).to.eq(MEMBER_PERMISSION_ID); - - // 2 - [selector, where, who, permissionId] = - await memberAccessExecuteCondition.decodeGrantRevokeCalldata( - calldataList[1] - ); - expect(selector).to.eq(calldataList[1].slice(0, 10)); - expect(where).to.eq(PLUGIN_ADDR_2); - expect(who).to.eq(bob.address); - expect(permissionId).to.eq(ROOT_PERMISSION_ID); - }); }); }); diff --git a/packages/contracts/test/unit-testing/member-access-plugin.ts b/packages/contracts/test/unit-testing/member-access-plugin.ts index 7461d8d..83b40f4 100644 --- a/packages/contracts/test/unit-testing/member-access-plugin.ts +++ b/packages/contracts/test/unit-testing/member-access-plugin.ts @@ -17,7 +17,7 @@ import { import { ApprovedEvent, ProposalCreatedEvent, -} from '../../typechain/src/MemberAccessPlugin'; +} from '../../typechain/src/governance/MemberAccessPlugin'; import {deployWithProxy, findEvent} from '../../utils/helpers'; import {getInterfaceID} from '../../utils/interfaces'; import {deployTestDao} from '../helpers/test-dao'; @@ -336,15 +336,14 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(carol.address)).to.eq(false); // Approve it (Bob) => fail - await expect(memberAccessPlugin.connect(bob).approve(0, false)).to.be - .reverted; + await expect(memberAccessPlugin.connect(bob).approve(0)).to.be.reverted; // Still not a member expect(await memberAccessPlugin.isMember(carol.address)).to.eq(false); // Approve it (Alice) => success - await expect(memberAccessPlugin.connect(alice).approve(0, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(alice).approve(0)).to.not.be + .reverted; // Now Carol is a member expect(await memberAccessPlugin.isMember(carol.address)).to.eq(true); @@ -405,8 +404,7 @@ describe('Member Access Plugin', function () { ).to.eq(false); // Try to approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(0, false)).to.be - .reverted; + await expect(memberAccessPlugin.connect(alice).approve(0)).to.be.reverted; }); it('Membership approvals are immediate', async () => { @@ -419,15 +417,14 @@ describe('Member Access Plugin', function () { ).to.not.be.reverted; // Approve it (Alice) => success - await expect(memberAccessPlugin.connect(alice).approve(0, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(alice).approve(0)).to.not.be + .reverted; const proposal = await memberAccessPlugin.getProposal(0); expect(proposal.executed).to.eq(true); // Approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(0, false)).to.be - .reverted; + await expect(memberAccessPlugin.connect(alice).approve(0)).to.be.reverted; }); it('Membership rejections are immediate', async () => { @@ -496,15 +493,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Dave cannot - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; await expect(memberAccessPlugin.connect(dave).execute(pid)).to.be .reverted; expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Alice can - await expect(memberAccessPlugin.connect(alice).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + .reverted; expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); }); }); @@ -538,15 +535,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // Dave is still not a member expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Approve it (Alice) - await expect(memberAccessPlugin.connect(alice).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + .reverted; // Dave is now a member expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); @@ -562,15 +559,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(ADDRESS_ONE)).to.eq(false); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // ADDRESS_ONE is still not a member expect(await memberAccessPlugin.isMember(ADDRESS_ONE)).to.eq(false); // Approve it (Bob) - await expect(memberAccessPlugin.connect(bob).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(bob).approve(pid)).to.not.be + .reverted; // ADDRESS_ONE is now a member expect(await memberAccessPlugin.isMember(ADDRESS_ONE)).to.eq(true); @@ -586,15 +583,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(ADDRESS_TWO)).to.eq(false); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // ADDRESS_TWO is still not a member expect(await memberAccessPlugin.isMember(ADDRESS_TWO)).to.eq(false); // Approve it (Carol) - await expect(memberAccessPlugin.connect(carol).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(carol).approve(pid)).to.not.be + .reverted; // ADDRESS_TWO is now a member expect(await memberAccessPlugin.isMember(ADDRESS_TWO)).to.eq(true); @@ -629,15 +626,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // Dave remains as a member expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); // Approve it (Alice) - await expect(memberAccessPlugin.connect(alice).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + .reverted; // Dave is no longer a member expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); @@ -653,15 +650,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(ADDRESS_ONE)).to.eq(true); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // ADDRESS_ONE remains as a member expect(await memberAccessPlugin.isMember(ADDRESS_ONE)).to.eq(true); // Approve it (Bob) - await expect(memberAccessPlugin.connect(bob).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(bob).approve(pid)).to.not.be + .reverted; // ADDRESS_ONE is no longer a member expect(await memberAccessPlugin.isMember(ADDRESS_ONE)).to.eq(false); @@ -677,15 +674,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(ADDRESS_TWO)).to.eq(true); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // ADDRESS_TWO remains as a member expect(await memberAccessPlugin.isMember(ADDRESS_TWO)).to.eq(true); // Approve it (Carol) - await expect(memberAccessPlugin.connect(carol).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(carol).approve(pid)).to.not.be + .reverted; // ADDRESS_TWO is no longer a member expect(await memberAccessPlugin.isMember(ADDRESS_TWO)).to.eq(false); @@ -767,8 +764,7 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Try to approve it (bob) => fail - await expect(memberAccessPlugin.connect(bob).approve(0, false)).to.be - .reverted; + await expect(memberAccessPlugin.connect(bob).approve(0)).to.be.reverted; expect((await memberAccessPlugin.getProposal(0)).executed).to.eq(false); }); @@ -803,8 +799,7 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); // Try to approve it (bob) => fail - await expect(memberAccessPlugin.connect(bob).approve(0, false)).to.be - .reverted; + await expect(memberAccessPlugin.connect(bob).approve(0)).to.be.reverted; expect((await memberAccessPlugin.getProposal(0)).executed).to.eq(false); }); @@ -827,15 +822,15 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Dave cannot - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; await expect(memberAccessPlugin.connect(dave).execute(pid)).to.be .reverted; expect(await memberAccessPlugin.isMember(dave.address)).to.eq(false); // Alice can - await expect(memberAccessPlugin.connect(alice).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + .reverted; expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); }); @@ -870,16 +865,16 @@ describe('Member Access Plugin', function () { expect(proposal.executed).to.eq(false); // Approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(alice).approve(pid)).to.be .reverted; // Approve it (Dave) => fail - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // Approve it (Bob) => succeed - await expect(memberAccessPlugin.connect(bob).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(bob).approve(pid)).to.not.be + .reverted; proposal = await memberAccessPlugin.getProposal(pid); expect(proposal.executed).to.eq(true); @@ -900,19 +895,19 @@ describe('Member Access Plugin', function () { expect(proposal.executed).to.eq(false); // Approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(alice).approve(pid)).to.be .reverted; // Approve it (Dave) => fail - await expect(memberAccessPlugin.connect(dave).approve(pid, false)).to.be + await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be .reverted; // Still a member expect(await memberAccessPlugin.isMember(dave.address)).to.eq(true); // Approve it (Bob) => succeed - await expect(memberAccessPlugin.connect(bob).approve(pid, false)).to.not - .be.reverted; + await expect(memberAccessPlugin.connect(bob).approve(pid)).to.not.be + .reverted; proposal = await memberAccessPlugin.getProposal(pid); expect(proposal.executed).to.eq(true); @@ -1051,8 +1046,8 @@ describe('Member Access Plugin', function () { ).to.not.be.reverted; const pid = 0; - await expect(memberAccessPlugin.approve(pid, false)).to.not.be.reverted; - await expect(memberAccessPlugin.approve(pid, false)).to.be.reverted; + await expect(memberAccessPlugin.approve(pid)).to.not.be.reverted; + await expect(memberAccessPlugin.approve(pid)).to.be.reverted; }); it('Attempting to reject twice fails', async () => { @@ -1116,7 +1111,7 @@ describe('Member Access Plugin', function () { const pid = 0; await expect(memberAccessPlugin.reject(pid)).to.not.be.reverted; - await expect(memberAccessPlugin.approve(pid, false)).to.be.reverted; + await expect(memberAccessPlugin.approve(pid)).to.be.reverted; }); it('Rejected proposals cannot be executed', async () => { @@ -1348,7 +1343,7 @@ describe('Member Access Plugin', function () { memberAccessPlugin.updateMultisigSettings(multisigSettings) ) .to.emit(memberAccessPlugin, 'MultisigSettingsUpdated') - .withArgs(60 * 60 * 24 * 5, mainVotingPlugin.addAddresses); + .withArgs(60 * 60 * 24 * 5, mainVotingPlugin.address); }); }); @@ -1450,7 +1445,7 @@ describe('Member Access Plugin', function () { it('returns `false` if the proposal is already executed', async () => { expect((await memberAccessPlugin.getProposal(id)).executed).to.be.false; - await memberAccessPlugin.connect(bob).approve(id, false); + await memberAccessPlugin.connect(bob).approve(id); expect((await memberAccessPlugin.getProposal(id)).executed).to.be.true; expect(await memberAccessPlugin.canApprove(id, signers[3].address)).to @@ -1467,7 +1462,7 @@ describe('Member Access Plugin', function () { it('returns `false` if the approver has already approved', async () => { expect(await memberAccessPlugin.canApprove(id, bob.address)).to.be.true; - await memberAccessPlugin.connect(bob).approve(id, false); + await memberAccessPlugin.connect(bob).approve(id); expect(await memberAccessPlugin.canApprove(id, bob.address)).to.be .false; }); @@ -1482,7 +1477,7 @@ describe('Member Access Plugin', function () { expect(await memberAccessPlugin.canApprove(id, bob.address)).to.be.true; - await memberAccessPlugin.connect(bob).approve(id, false); + await memberAccessPlugin.connect(bob).approve(id); expect(await memberAccessPlugin.canApprove(id, bob.address)).to.be .false; @@ -1506,7 +1501,7 @@ describe('Member Access Plugin', function () { }); it('returns `true` if user has approved', async () => { - await memberAccessPlugin.connect(bob).approve(id, false); + await memberAccessPlugin.connect(bob).approve(id); expect(await memberAccessPlugin.hasApproved(id, bob.address)).to.be .true; }); @@ -1524,10 +1519,10 @@ describe('Member Access Plugin', function () { }); it('reverts when approving multiple times', async () => { - await memberAccessPlugin.connect(bob).approve(id, true); + await memberAccessPlugin.connect(bob).approve(id); // Try to vote again - await expect(memberAccessPlugin.connect(bob).approve(id, true)) + await expect(memberAccessPlugin.connect(bob).approve(id)) .to.be.revertedWithCustomError( memberAccessPlugin, 'ApprovalCastForbidden' @@ -1551,7 +1546,7 @@ describe('Member Access Plugin', function () { 1 ); - const tx = await memberAccessPlugin.connect(bob).approve(id, false); + const tx = await memberAccessPlugin.connect(bob).approve(id); const event = await findEvent(tx, 'Approved'); expect(event!.args.proposalId).to.eq(id); @@ -1592,7 +1587,7 @@ describe('Member Access Plugin', function () { ); // Approve and execute - await memberAccessPlugin.connect(bob).approve(id, false); + await memberAccessPlugin.connect(bob).approve(id); expect((await memberAccessPlugin.getProposal(id)).executed).to.be.true; @@ -1621,7 +1616,7 @@ describe('Member Access Plugin', function () { }); it('emits the `Approved`, `ProposalExecuted`, and `Executed` events if execute is called inside the `approve` method', async () => { - await expect(memberAccessPlugin.connect(bob).approve(id, false)) + await expect(memberAccessPlugin.connect(bob).approve(id)) .to.emit(dao, 'Executed') .to.emit(memberAccessPlugin, 'ProposalExecuted') .to.emit(memberAccessPlugin, 'Approved'); @@ -1637,8 +1632,8 @@ describe('Member Access Plugin', function () { to: mainVotingPlugin.address, value: 0, data: MainVotingPlugin__factory.createInterface().encodeFunctionData( - 'addAddresses', - [[_editor]] + 'addEditor', + [_editor] ), }, ]; @@ -1649,8 +1644,6 @@ describe('Member Access Plugin', function () { toUtf8Bytes('ipfs://'), actions, 0, // fail safe - 0, // start date - 0, // end date VoteOption.Yes, true // auto execute ) diff --git a/packages/contracts/test/unit-testing/personal-space-admin-plugin.ts b/packages/contracts/test/unit-testing/personal-space-admin-plugin.ts index db1c46b..586b95c 100644 --- a/packages/contracts/test/unit-testing/personal-space-admin-plugin.ts +++ b/packages/contracts/test/unit-testing/personal-space-admin-plugin.ts @@ -1,7 +1,6 @@ import { DAO, IERC165Upgradeable__factory, - IMembership__factory, PersonalSpaceAdminCloneFactory, PersonalSpaceAdminCloneFactory__factory, PersonalSpaceAdminPlugin, @@ -10,7 +9,7 @@ import { SpacePlugin__factory, } from '../../typechain'; import {ExecutedEvent} from '../../typechain/@aragon/osx/core/dao/IDAO'; -import {ProposalCreatedEvent} from '../../typechain/src/PersonalSpaceAdminPlugin'; +import {ProposalCreatedEvent} from '../../typechain/src/personal/PersonalSpaceAdminPlugin'; import { deployWithProxy, findEvent,