Skip to content

Commit

Permalink
test: interfaces and ERC-165 (#40)
Browse files Browse the repository at this point in the history
* build: added version number to allow importing

* revert: remove osx dependency

* fix: use new IDAO

* feat: add former voting helpers

* feat: refactored helpers

* refactor: event function

* refactor: improved naming

* refactor: improve time helpers

* refactor: removed hardhat time

* fix: wrong import

* refactor: improve time constants

* docs: add todo comment

* refactor: move over plugin and plugin setups as well as permissions

* refactor: renaming and changed folder structure

* feat: added bitmap

* refactor: moved metadata into separate file

* refactor: moved events

* refactor: moved permissions

* revert: version bump of solhint

* refactor: improve folder structure

* refactor: folders structure, imports, yarn lock

* ci: fix

* fix: version mismatch with sdk

* revert: remove etherscan

* refactor: rename event constants

* ci: make sdk an alpha version

* feat: move permissions

* build: rename package

* refactor: structure

* build: save yarn lock

* build: use same typescript version

* refactor: imports

* build: contracts start with alpha version

* build: use commons-sdk

* fix: imports

* build: add files to index

* v0.0.1-alpha.1

* fix: bump version and fix import

* fix: imports

* fix: missing export

* chore: bump version

* chore: save lock file

* chore: bump version

* build: no postinstall

* chore: ignore DS_Store files

* v0.0.1-alpha.3

* refactor: remove proxy helper

* build: add protocol version

* v0.0.1-alpha.4

* feat: made ProtocolVersion non-abstract

* refactor: protocol version number

remove protocol version constant and bump osx-commons-contracts package version number to match with the protocol version

* revert: make ProtocolVersion abstract and use mock instead

* v1.4.0-alpha.1

* refactor: renamed function

* chore: maintain changelog

* build: improve build

* ci: added missing secret

* revert: remove duplicate

* build: remove osx-ethers dependencies

* revert: remove TestPlugin

* build: use files allowlist instead of .npmignore denylist

* refactor: improved mocks

* refactor: improved mocks further

* refactor: rename test

* refactor: remove placeholder setup

* feat: added test sekletons and todos

* revert: removed todo that has its own task already

* build: bump version number

* docs: improved plugin setup mock data

* refactor: renamed PluginMockData to PluginSetupMockData

* refactor: setup mocks

* build: remove src folder

* refactor: move and added todo

* refactor: move auth into dao folder

* build: adapt the hardhat solidity source path subtask

* refactor: move auth

* revert: src removal

* revert: delete storage

* refactor: move governance into extensions

* build: remove governance folder from package.json

* fix: wrong path

* refactor: harmonize mock contract naming and move CloneFactory

* revert: author comment for mock

* feat: use name aliases

* feat: added interface related tests

* fix: added missing await

* style: improved linting

* fix: contract linting errors

* style: improve linting

* fix: subgraph linter complaints

* docs: remove todos and add test skeleton

* style: fix enum values

* feat: add custom event error

* chore: use new sdk

* docs: fix comments

* fix: linter

* test: added missing interface test
  • Loading branch information
heueristik authored Jan 12, 2024
1 parent 75cf864 commit 65c9643
Show file tree
Hide file tree
Showing 23 changed files with 923 additions and 174 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extends:

plugins:
- '@typescript-eslint'
- 'unused-imports'

rules:
'@typescript-eslint/no-floating-promises':
Expand All @@ -21,6 +22,8 @@ rules:
- argsIgnorePattern: '_'
varsIgnorePattern: '_'

'unused-imports/no-unused-imports': 'error'

ignorePatterns:
- '*.log'
- '*.env'
Expand Down
1 change: 1 addition & 0 deletions contracts/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ignorePatterns:
- cache
- coverage
- dist
- docs
- typechain
# files
- coverage.json
2 changes: 2 additions & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
},
"devDependencies": {
"@aragon/osx-commons-sdk": "0.0.1-alpha.3",
"@aragon/osx-ethers-v1.0.0": "npm:@aragon/[email protected]",
"@aragon/osx-ethers-v1.3.0": "npm:@aragon/[email protected]",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
Expand Down
12 changes: 12 additions & 0 deletions contracts/test/dao/dao.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {IDAO__factory} from '../../typechain';
import {getInterfaceId} from '@aragon/osx-commons-sdk';
import {IDAO__factory as IDAO_V1_0_0__factory} from '@aragon/osx-ethers-v1.0.0';
import {expect} from 'chai';

describe('IDAO', function () {
it('has the same interface ID as its initial version introduced in v1.0.0', async () => {
const current = getInterfaceId(IDAO__factory.createInterface());
const initial = getInterfaceId(IDAO_V1_0_0__factory.createInterface());
expect(current).to.equal(initial);
});
});
17 changes: 17 additions & 0 deletions contracts/test/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {IERC165__factory} from '../typechain';
import {getInterfaceId} from '@aragon/osx-commons-sdk';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {Contract} from 'ethers';

export async function erc165ComplianceTests(
contract: Contract,
signer: SignerWithAddress
) {
const erc165Contract = IERC165__factory.connect(contract.address, signer);
const erc165InterfaceId = getInterfaceId(IERC165__factory.createInterface());
const emptyInterfaceId = '0xffffffff';

expect(await erc165Contract.supportsInterface(erc165InterfaceId)).to.be.true;
expect(await erc165Contract.supportsInterface(emptyInterfaceId)).to.be.false;
}
2 changes: 0 additions & 2 deletions contracts/test/permission/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {expect} from 'chai';

// TODO

describe.skip('auth', async () => {
it('reverts with an error if the permission is not granted', async () => {
expect(true).to.equal(false);
Expand Down
2 changes: 0 additions & 2 deletions contracts/test/permission/auth/dao-authorizable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {expect} from 'chai';

// TODO

describe.skip('DaoAuthorizable', async () => {
// TODO abstract these common tests that also apply to `DaoAuthorizableUpgradeable`
it('initializes the DAO', async () => {
Expand Down
18 changes: 6 additions & 12 deletions contracts/test/permission/permission-condition.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {
IERC165__factory,
IPermissionCondition__factory,
IProtocolVersion__factory,
PermissionConditionMock,
PermissionConditionMock__factory,
} from '../../typechain';
import {erc165ComplianceTests} from '../helpers';
import {getInterfaceId} from '@aragon/osx-commons-sdk';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {ethers} from 'hardhat';

// TODO

describe('PermissionCondition', async () => {
let condition: PermissionConditionMock;
let deployer: SignerWithAddress;

before(async () => {
const deployer = (await ethers.getSigners())[0];
[deployer] = await ethers.getSigners();
condition = await new PermissionConditionMock__factory(deployer).deploy();
});

Expand All @@ -29,14 +29,8 @@ describe('PermissionCondition', async () => {
});

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

it('supports the `IERC165` interface', async () => {
const iface = IERC165__factory.createInterface();
expect(await condition.supportsInterface(getInterfaceId(iface))).to.be
.true;
it('supports the `ERC-165` standard', async () => {
await erc165ComplianceTests(condition, deployer);
});

it('supports the `IPermissionCondition` interface', async () => {
Expand Down
Loading

0 comments on commit 65c9643

Please sign in to comment.