Skip to content

Commit

Permalink
add tests for iexecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Sep 26, 2024
1 parent 2f488d9 commit f27e23a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
54 changes: 52 additions & 2 deletions packages/contracts/test/core/dao/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ import {
IProtocolVersion__factory,
PermissionConditionMock__factory,
PermissionConditionMock,
IExecutor__factory,
IDAO,
ERC165,
} from '../../../typechain';
import {DAO__factory as DAO_V1_0_0__factory} from '../../../typechain/@aragon/osx-v1.0.1/core/dao/DAO.sol';
import {IDAO__factory as IDAO_V1_0_0_factory} from '../../../typechain/@aragon/osx-v1.0.1/core/dao/IDAO.sol';
import {DAO__factory as DAO_V1_3_0__factory} from '../../../typechain/@aragon/osx-v1.3.0/core/dao/DAO.sol';
import {IDAO__factory as IDAO_V3_0_0_factory} from '../../../typechain/@aragon/osx-v1.3.0/core/dao/IDAO.sol';
import {ExecutedEvent} from '../../../typechain/DAO';
import {
getActions,
Expand Down Expand Up @@ -301,13 +306,36 @@ describe('DAO', function () {
).toNumber()
).to.equal(0);
});

it('registers IExecutor interface for versions < 1.4.0', async () => {
// Create an uninitialized DAO.
const uninitializedDao = await deployWithProxy<DAO>(DAO);

expect(
await uninitializedDao.supportsInterface(
getInterfaceId(IExecutor__factory.createInterface())
)
).to.be.false;

await uninitializedDao.initializeFrom([1, 3, 0], EMPTY_DATA);

expect(
await uninitializedDao.supportsInterface(
getInterfaceId(IExecutor__factory.createInterface())
)
).to.be.true;
});
});

describe('Upgrades', async () => {
let legacyContractFactory: ContractFactory;
let currentContractFactory: ContractFactory;
let initArgs: any;

const IExecutorInterfaceId = getInterfaceId(
IExecutor__factory.createInterface()
);

before(() => {
currentContractFactory = new DAO__factory(signers[0]);

Expand All @@ -333,7 +361,7 @@ describe('DAO', function () {
it('upgrades from v1.0.0', async () => {
legacyContractFactory = new DAO_V1_0_0__factory(signers[0]);

const {fromImplementation, toImplementation} =
const {proxy, fromImplementation, toImplementation} =
await deployAndUpgradeFromToCheck(
signers[0],
signers[1],
Expand All @@ -357,12 +385,23 @@ describe('DAO', function () {
IMPLICIT_INITIAL_PROTOCOL_VERSION
);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());

await proxy.initializeFrom([1, 0, 0], EMPTY_DATA);

// Check that it still supports old interfaceId for backwards compatibility.
expect(
await proxy.supportsInterface(
getInterfaceId(IDAO_V1_0_0_factory.createInterface())
)
).to.be.true;

expect(await proxy.supportsInterface(IExecutorInterfaceId)).to.be.true;
});

it('from v1.3.0', async () => {
legacyContractFactory = new DAO_V1_3_0__factory(signers[0]);

const {fromImplementation, toImplementation} =
const {proxy, fromImplementation, toImplementation} =
await deployAndUpgradeFromToCheck(
signers[0],
signers[1],
Expand All @@ -384,6 +423,17 @@ describe('DAO', function () {
expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 3, 0]);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());

await proxy.initializeFrom([1, 3, 0], EMPTY_DATA);

// Check that it still supports old interfaceId for backwards compatibility.
expect(
await proxy.supportsInterface(
getInterfaceId(IDAO_V3_0_0_factory.createInterface())
)
).to.be.true;

expect(await proxy.supportsInterface(IExecutorInterfaceId)).to.be.true;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const FREEZE_ADDRESS = '0x0000000000000000000000000000000000000001';
const someWhere = '0xb794F5eA0ba39494cE839613fffBA74279579268';
const somePermissionId = ethers.utils.id('SOME_PERMISSION');

describe.only('Core: PermissionManager', function () {
describe('Core: PermissionManager', function () {
let pm: PermissionManagerTest;
let signers: SignerWithAddress[];
let ownerSigner: SignerWithAddress;
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/test/test-utils/uups-upgradeable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export async function deployAndUpgradeFromToCheck(
}

// Upgrade the proxy to a new implementation from a different factory
await upgrades.upgradeProxy(proxy.address, to.connect(upgrader), {
proxy = await upgrades.upgradeProxy(proxy.address, to.connect(upgrader), {
unsafeAllow: ['constructor'],
constructorArgs: [],
});
Expand Down

0 comments on commit f27e23a

Please sign in to comment.