Skip to content

Commit

Permalink
test: fix some tests with non-standard values
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Aug 15, 2023
1 parent 0047be6 commit 4f2548c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = (
],
dataValues: [
extensionB,
ethers.utils.hexZeroPad(ethers.utils.hexlify(8), 32),
ethers.utils.hexZeroPad(ethers.utils.hexlify(8), 16),
'0xaabb',
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
// set some random bytes under AddressPermissions[7]

await expect(context.universalProfile.connect(context.owner).setData(key, randomValue))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -236,11 +233,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
// set some random bytes under AddressPermissions[7]

await expect(context.universalProfile.connect(context.owner).setData(key, randomValue))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down Expand Up @@ -270,11 +264,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
// set some random bytes under AddressPermissions[7]

await expect(context.universalProfile.connect(context.owner).setData(key, randomValue))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -286,11 +277,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
// set some random bytes under AddressPermissions[7]

await expect(context.universalProfile.connect(context.owner).setData(key, randomValue))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down Expand Up @@ -434,11 +422,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
await expect(
context.universalProfile.connect(canOnlyAddController).setData(key, randomValue),
)
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -450,11 +435,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
await expect(
context.universalProfile.connect(canOnlyAddController).setData(key, randomValue),
)
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down Expand Up @@ -590,7 +572,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = (

const newLength = ethers.BigNumber.from(currentLength).sub(1).toNumber();

const value = ethers.utils.hexZeroPad(ethers.utils.hexlify(newLength), 32);
const value = ethers.utils.hexZeroPad(ethers.utils.hexlify(newLength), 16);

await context.universalProfile.connect(canOnlyEditPermissions).setData(key, value);

Expand Down Expand Up @@ -643,11 +625,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
await expect(
context.universalProfile.connect(canOnlyEditPermissions).setData(key, randomValue),
)
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -661,11 +640,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
await expect(
context.universalProfile.connect(canOnlyEditPermissions).setData(key, randomValue),
)
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ export const shouldBehaveLikePermissionChangeOrAddExtensions = (
],
dataValues: [
extensionB,
ethers.utils.hexZeroPad(ethers.utils.hexlify(8), 32),
ethers.utils.hexZeroPad(ethers.utils.hexlify(8), 16),
'0xaabb',
],
};
Expand Down
4 changes: 2 additions & 2 deletions tests/LSP6KeyManager/LSP6ControlledToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => {
const key =
ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] +
addressCanSetData.address.substring(2);
const value = ARRAY_LENGTH.ZERO;
const value = '0x';
const payload = context.token.interface.encodeFunctionData('setData', [key, value]);

await expect(context.keyManager.connect(addressCanAddController).execute(payload))
Expand All @@ -443,7 +443,7 @@ describe('When deploying LSP7 with LSP6 as owner', () => {
const key =
ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] +
addressCanSetData.address.substring(2);
const value = ARRAY_LENGTH.ZERO;
const value = '0x';
const payload = context.token.interface.encodeFunctionData('setData', [key, value]);

await context.keyManager.connect(context.owner).execute(payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(context.owner).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -274,11 +271,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(context.owner).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down Expand Up @@ -313,11 +307,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(context.owner).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -331,11 +322,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(context.owner).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down Expand Up @@ -511,11 +499,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(canOnlyAddController).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -529,11 +514,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(canOnlyAddController).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down Expand Up @@ -698,7 +680,7 @@ export const shouldBehaveLikePermissionChangeOrAddController = (

const newLength = ethers.BigNumber.from(currentLength).sub(1).toNumber();

const value = ethers.utils.hexZeroPad(ethers.utils.hexlify(newLength), 32);
const value = ethers.utils.hexZeroPad(ethers.utils.hexlify(newLength), 16);

const payload = context.universalProfile.interface.encodeFunctionData('setData', [
key,
Expand Down Expand Up @@ -760,11 +742,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(canOnlyEditPermissions).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});

it('should revert when setting a random 30 bytes value', async () => {
Expand All @@ -778,11 +757,8 @@ export const shouldBehaveLikePermissionChangeOrAddController = (
]);

await expect(context.keyManager.connect(canOnlyEditPermissions).execute(setupPayload))
.to.be.revertedWithCustomError(
context.keyManager,
'AddressPermissionArrayIndexValueNotAnAddress',
)
.withArgs(key, randomValue);
.to.be.revertedWithCustomError(context.keyManager, 'InvalidDataValuesForDataKeys')
.withArgs(key, randomValue, 20);
});
});

Expand Down

0 comments on commit 4f2548c

Please sign in to comment.