Skip to content

Commit

Permalink
feat: add couple of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clauBv23 committed Sep 19, 2024
1 parent 61e3b8c commit 61e2cde
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions packages/contracts/test/core/permission/permission-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,17 @@ describe('Core: PermissionManager', function () {
).to.not.be.reverted;
});

it('reverts if both `_who == ANY_ADDR` and `_where == ANY_ADDR', async () => {
await expect(
pm.grantWithCondition(
ANY_ADDR,
ANY_ADDR,
DAO_PERMISSIONS.ROOT_PERMISSION_ID,
conditionMock.address
)
).to.be.revertedWithCustomError(pm, 'AnyAddressDisallowedForWhoAndWhere');
});

it('should add permission', async () => {
await pm.grantWithCondition(
pm.address,
Expand Down Expand Up @@ -1559,6 +1570,45 @@ describe('Core: PermissionManager', function () {
});
});

describe('setApplyTargetMethodGrantee', () => {
beforeEach(async () => {
await pm.createPermission(
ownerSigner.address,
ADMIN_PERMISSION_ID,
otherSigner.address,
['0xb794F5eA0ba39494cE839613fffBA74279579268']
);
});

it('should store the applyTargetMethodGrantee ', async () => {
expect(await pm.applyTargetMethodGrantee()).to.be.equal(addressZero);
await pm.setApplyTargetMethodGrantee(ownerSigner.address);

expect(await pm.applyTargetMethodGrantee()).to.be.equal(
ownerSigner.address
);
});

it('should emit ApplyTargetMethodGranteeSet', async () => {
await expect(pm.setApplyTargetMethodGrantee(ownerSigner.address)).to.emit(
pm,
'ApplyTargetMethodGranteeSet'
);
});

it('should revert if not allowed', async () => {
await expect(
pm.connect(otherSigner).setApplyTargetMethodGrantee(ownerSigner.address)
)
.to.be.revertedWithCustomError(pm, 'Unauthorized')
.withArgs(
pm.address,
otherSigner.address,
DAO_PERMISSIONS.ROOT_PERMISSION_ID
);
});
});

describe('bulk on multiple target', () => {
it('should bulk grant ADMIN_PERMISSION on different targets', async () => {
const bulkItems: MultiTargetPermission[] = [
Expand Down

0 comments on commit 61e2cde

Please sign in to comment.