Skip to content

Commit

Permalink
test: add interface tests and subgraph renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik committed Sep 28, 2023
1 parent 1c7b8ec commit b662dde
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 97 deletions.
6 changes: 6 additions & 0 deletions packages/contracts/src/test/Migration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ import {MerkleMinter as MerkleMinter_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/plug

import {MerkleDistributor as MerkleDistributor_v1_0_0} from "@aragon/osx-v1.0.1/plugins/token/MerkleDistributor.sol";
import {MerkleDistributor as MerkleDistributor_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/plugins/token/MerkleDistributor.sol";

import {GovernanceERC20 as GovernanceERC20_v1_0_0} from "@aragon/osx-v1.0.1/token/ERC20/governance/GovernanceERC20.sol";
import {GovernanceERC20 as GovernanceERC20_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/token/ERC20/governance/GovernanceERC20.sol";

import {GovernanceWrappedERC20 as GovernanceWrappedERC20_v1_0_0} from "@aragon/osx-v1.0.1/token/ERC20/governance/GovernanceWrappedERC20.sol";
import {GovernanceWrappedERC20 as GovernanceWrappedERC20_v1_3_0} from "@aragon/osx-v1.3.0-rc0.2/token/ERC20/governance/GovernanceWrappedERC20.sol";
4 changes: 0 additions & 4 deletions packages/contracts/test/core/dao/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ describe('DAO', function () {
]);
});

it('does not support the empty interface', async () => {
expect(await dao.supportsInterface('0xffffffff')).to.be.false;
});

describe('initialize', async () => {
it('reverts if trying to re-initialize', async () => {
await expect(
Expand Down
216 changes: 216 additions & 0 deletions packages/contracts/test/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import {expect} from 'chai';

import {getInterfaceID} from './test-utils/interfaces';

import {
// core
IDAO__factory,
IEIP4824__factory,
IPermissionCondition__factory,
IPlugin__factory,
IMembership__factory,
IProposal__factory,
// framework
IPluginRepo__factory,
IPluginSetup__factory,
// plugins
IMajorityVoting__factory,
IMultisig__factory,
IMerkleMinter__factory,
IMerkleDistributor__factory,
// token
IERC20MintableUpgradeable__factory,
IGovernanceWrappedERC20__factory,
// utils
IProtocolVersion__factory,
} from '../typechain';

import {IDAO__factory as IDAO_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/dao/IDAO.sol';
import {IEIP4824__factory as IEIP4824_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/dao/IEIP4824.sol';
import {IPermissionCondition__factory as IPermissionCondition_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/permission/IPermissionCondition.sol';
import {IPlugin__factory as IPlugin_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/plugin/IPlugin.sol';
import {IMembership__factory as IMembership_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/plugin/membership/IMembership.sol';
import {IProposal__factory as IProposal_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/core/plugin/proposal/IProposal.sol';

import {IPluginRepo__factory as IPluginRepo_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/framework/plugin/repo/IPluginRepo.sol';
import {IPluginSetup__factory as IPluginSetup_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/framework/plugin/setup/IPluginSetup.sol';

import {IMajorityVoting__factory as IMajorityVoting_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/governance/majority-voting/IMajorityVoting.sol';
import {IMultisig__factory as IMultisig_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/governance/multisig/IMultisig.sol';
import {IMerkleMinter__factory as IMerkleMinter_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/token/IMerkleMinter.sol';
import {IMerkleDistributor__factory as IMerkleDistributor_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/plugins/token/IMerkleDistributor.sol';

import {IERC20MintableUpgradeable__factory as IERC20MintableUpgradeable_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/token/ERC20/IERC20MintableUpgradeable.sol';
import {IGovernanceWrappedERC20__factory as IGovernanceWrappedERC20_V1_0_0__factory} from '../typechain/@aragon/osx-v1.0.1/token/ERC20/governance/IGovernanceWrappedERC20.sol'; // TODO: For some reason this file is missing.

import {IProtocolVersion__factory as IProtocolVersion_V1_3_0__factory} from '../typechain/@aragon/osx-v1.3.0-rc0.2/utils/protocol/IProtocolVersion.sol';

describe('Interfaces', function () {
context('introduced in v1.0.0', function () {
describe('IDAO', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IDAO__factory.createInterface());
const initial = getInterfaceID(IDAO_V1_0_0__factory.createInterface());
expect(current).to.equal(initial);
});
});

describe('IEIP4824', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IEIP4824__factory.createInterface());
const initial = getInterfaceID(
IEIP4824_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IPermissionCondition', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IPermissionCondition__factory.createInterface()
);
const initial = getInterfaceID(
IPermissionCondition_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});
describe('IPlugin', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IPlugin__factory.createInterface());
const initial = getInterfaceID(
IPlugin_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IMembership', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IMembership__factory.createInterface());
const initial = getInterfaceID(
IMembership_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IProposal', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IProposal__factory.createInterface());
const initial = getInterfaceID(
IProposal_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IPluginRepo', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IPluginRepo__factory.createInterface());
const initial = getInterfaceID(
IPluginRepo_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IPluginSetup', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IPluginSetup__factory.createInterface());
const initial = getInterfaceID(
IPluginSetup_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

// plugins
describe('IMajorityVoting', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IMajorityVoting__factory.createInterface()
);
const initial = getInterfaceID(
IMajorityVoting_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IMultisig', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(IMultisig__factory.createInterface());
const initial = getInterfaceID(
IMultisig_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IMerkleMinter', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IMerkleMinter__factory.createInterface()
);
const initial = getInterfaceID(
IMerkleMinter_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IMerkleDistributor', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IMerkleDistributor__factory.createInterface()
);
const initial = getInterfaceID(
IMerkleDistributor_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

// tokens
describe('IERC20MintableUpgradeable', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IERC20MintableUpgradeable__factory.createInterface()
);
const initial = getInterfaceID(
IERC20MintableUpgradeable_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});

describe('IGovernanceWrappedERC20', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IGovernanceWrappedERC20__factory.createInterface()
);
const initial = getInterfaceID(
IGovernanceWrappedERC20_V1_0_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});
});

// utils
context('introduced in v1.3.0', function () {
describe('IProtocolVersion', function () {
it('has still the same interface ID', async () => {
const current = getInterfaceID(
IProtocolVersion__factory.createInterface()
);
const initial = getInterfaceID(
IProtocolVersion_V1_3_0__factory.createInterface()
);
expect(current).to.equal(initial);
});
});
});
});
14 changes: 6 additions & 8 deletions packages/contracts/test/plugins/governance/admin/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
findEventTopicLog,
} from '../../../../utils/event';
import {deployNewDAO} from '../../../test-utils/dao';
import {getInterfaceID} from '../../../test-utils/interfaces';
import {ADMIN_INTERFACE, getInterfaceID} from '../../../test-utils/interfaces';
import {ADMIN_INTERFACE_ID} from '../../../../../subgraph/src/utils/constants';

import {OZ_ERRORS} from '../../../test-utils/error';
import {toBytes32} from '../../../test-utils/voting';
import {
Expand All @@ -33,11 +35,6 @@ const EXECUTE_PROPOSAL_PERMISSION_ID = ethers.utils.id(
);
const EXECUTE_PERMISSION_ID = ethers.utils.id('EXECUTE_PERMISSION');

export const adminInterface = new ethers.utils.Interface([
'function initialize(address)',
'function executeProposal(bytes,tuple(address,uint256,bytes)[],uint256)',
]);

describe('Admin', function () {
let signers: SignerWithAddress[];
let plugin: any;
Expand Down Expand Up @@ -144,8 +141,9 @@ describe('Admin', function () {
});

it('supports the `Admin` interface', async () => {
expect(await plugin.supportsInterface(getInterfaceID(adminInterface))).to
.be.true;
const iface = getInterfaceID(ADMIN_INTERFACE);
expect(iface).to.equal(ADMIN_INTERFACE_ID); // checks that it didn't change
expect(await plugin.supportsInterface(iface)).to.be.true;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ import {deployNewDAO} from '../../../../test-utils/dao';
import {OZ_ERRORS} from '../../../../test-utils/error';
import {UPGRADE_PERMISSIONS} from '../../../../test-utils/permissions';
import {deployWithProxy} from '../../../../test-utils/proxy';
import {getInterfaceID} from '../../../../test-utils/interfaces';
import {
ADDRESSLIST_VOTING_INTERFACE,
getInterfaceID,
} from '../../../../test-utils/interfaces';
import {ADDRESSLIST_VOTING_INTERFACE_ID} from '../../../../../../subgraph/src/utils/constants';

import {
getProtocolVersion,
Expand All @@ -63,12 +67,6 @@ import {
} from '../../../../test-utils/protocol-version';
import {ExecutedEvent} from '../../../../../typechain/DAO';

export const addresslistVotingInterface = new ethers.utils.Interface([
'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address[])',
'function addAddresses(address[])',
'function removeAddresses(address[])',
]);

describe('AddresslistVoting', function () {
let signers: SignerWithAddress[];
let voting: AddresslistVoting;
Expand Down Expand Up @@ -276,11 +274,9 @@ describe('AddresslistVoting', function () {
});

it('supports the `AddresslistVoting` interface', async () => {
expect(
await voting.supportsInterface(
getInterfaceID(addresslistVotingInterface)
)
).to.be.true;
const iface = getInterfaceID(ADDRESSLIST_VOTING_INTERFACE);
expect(iface).to.equal(ADDRESSLIST_VOTING_INTERFACE_ID); // checks that it didn't change
expect(await voting.supportsInterface(iface)).to.be.true;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ import {
import {deployNewDAO} from '../../../../test-utils/dao';
import {OZ_ERRORS} from '../../../../test-utils/error';
import {deployWithProxy} from '../../../../test-utils/proxy';
import {getInterfaceID} from '../../../../test-utils/interfaces';
import {
TOKEN_VOTING_INTERFACE,
getInterfaceID,
} from '../../../../test-utils/interfaces';
import {TOKEN_VOTING_INTERFACE_ID} from '../../../../../../subgraph/src/utils/constants';

import {UPGRADE_PERMISSIONS} from '../../../../test-utils/permissions';
import {
getProtocolVersion,
Expand All @@ -64,11 +69,6 @@ import {
} from '../../../../test-utils/protocol-version';
import {ExecutedEvent} from '../../../../../typechain/DAO';

export const tokenVotingInterface = new ethers.utils.Interface([
'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address)',
'function getVotingToken()',
]);

describe('TokenVoting', function () {
let signers: SignerWithAddress[];
let voting: TokenVoting;
Expand Down Expand Up @@ -338,9 +338,9 @@ describe('TokenVoting', function () {
});

it('supports the `TokenVoting` interface', async () => {
expect(
await voting.supportsInterface(getInterfaceID(tokenVotingInterface))
).to.be.true;
const iface = getInterfaceID(TOKEN_VOTING_INTERFACE);
expect(iface).to.equal(TOKEN_VOTING_INTERFACE_ID); // checks that it didn't change
expect(await voting.supportsInterface(iface)).to.be.true;
});
});

Expand Down
19 changes: 8 additions & 11 deletions packages/contracts/test/plugins/governance/multisig/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ import {
} from '../../../test-utils/voting';
import {UPGRADE_PERMISSIONS} from '../../../test-utils/permissions';
import {deployWithProxy} from '../../../test-utils/proxy';
import {getInterfaceID} from '../../../test-utils/interfaces';
import {
MULTISIG_INTERFACE,
getInterfaceID,
} from '../../../test-utils/interfaces';
import {MULTISIG_INTERFACE_ID} from '../../../../../subgraph/src/utils/constants';
import {
getProtocolVersion,
deployAndUpgradeFromToCheck,
Expand All @@ -56,13 +60,6 @@ import {
} from '../../../test-utils/protocol-version';
import {ExecutedEvent} from '../../../../typechain/DAO';

export const multisigInterface = new ethers.utils.Interface([
'function initialize(address,address[],tuple(bool,uint16))',
'function updateMultisigSettings(tuple(bool,uint16))',
'function createProposal(bytes,tuple(address,uint256,bytes)[],uint256,bool,bool,uint64,uint64) ',
'function getProposal(uint256)',
]);

export type MultisigSettings = {
minApprovals: number;
onlyListed: boolean;
Expand Down Expand Up @@ -341,9 +338,9 @@ describe('Multisig', function () {
});

it('supports the `Multisig` interface', async () => {
expect(
await multisig.supportsInterface(getInterfaceID(multisigInterface))
).to.be.true;
const iface = getInterfaceID(MULTISIG_INTERFACE);
expect(iface).to.equal(MULTISIG_INTERFACE_ID); // checks that it didn't change
expect(await multisig.supportsInterface(iface)).to.be.true;
});
});

Expand Down
Loading

0 comments on commit b662dde

Please sign in to comment.