Implement recommendations from 5.0 audit Phase 1A (#4398)
Co-authored-by: Francisco Giordano <fg@frang.io> Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -16,21 +16,21 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
|
||||
context('when token is paused', function () {
|
||||
const firstTokenId = new BN('37');
|
||||
const firstTokenAmount = new BN('42');
|
||||
const firstTokenValue = new BN('42');
|
||||
|
||||
const secondTokenId = new BN('19842');
|
||||
const secondTokenAmount = new BN('23');
|
||||
const secondTokenValue = new BN('23');
|
||||
|
||||
beforeEach(async function () {
|
||||
await this.token.setApprovalForAll(operator, true, { from: holder });
|
||||
await this.token.$_mint(holder, firstTokenId, firstTokenAmount, '0x');
|
||||
await this.token.$_mint(holder, firstTokenId, firstTokenValue, '0x');
|
||||
|
||||
await this.token.$_pause();
|
||||
});
|
||||
|
||||
it('reverts when trying to safeTransferFrom from holder', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.safeTransferFrom(holder, receiver, firstTokenId, firstTokenAmount, '0x', { from: holder }),
|
||||
this.token.safeTransferFrom(holder, receiver, firstTokenId, firstTokenValue, '0x', { from: holder }),
|
||||
'EnforcedPause',
|
||||
[],
|
||||
);
|
||||
@ -38,7 +38,7 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
|
||||
it('reverts when trying to safeTransferFrom from operator', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.safeTransferFrom(holder, receiver, firstTokenId, firstTokenAmount, '0x', { from: operator }),
|
||||
this.token.safeTransferFrom(holder, receiver, firstTokenId, firstTokenValue, '0x', { from: operator }),
|
||||
'EnforcedPause',
|
||||
[],
|
||||
);
|
||||
@ -46,7 +46,7 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
|
||||
it('reverts when trying to safeBatchTransferFrom from holder', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.safeBatchTransferFrom(holder, receiver, [firstTokenId], [firstTokenAmount], '0x', { from: holder }),
|
||||
this.token.safeBatchTransferFrom(holder, receiver, [firstTokenId], [firstTokenValue], '0x', { from: holder }),
|
||||
'EnforcedPause',
|
||||
[],
|
||||
);
|
||||
@ -54,7 +54,7 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
|
||||
it('reverts when trying to safeBatchTransferFrom from operator', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.safeBatchTransferFrom(holder, receiver, [firstTokenId], [firstTokenAmount], '0x', {
|
||||
this.token.safeBatchTransferFrom(holder, receiver, [firstTokenId], [firstTokenValue], '0x', {
|
||||
from: operator,
|
||||
}),
|
||||
'EnforcedPause',
|
||||
@ -64,7 +64,7 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
|
||||
it('reverts when trying to mint', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.$_mint(holder, secondTokenId, secondTokenAmount, '0x'),
|
||||
this.token.$_mint(holder, secondTokenId, secondTokenValue, '0x'),
|
||||
'EnforcedPause',
|
||||
[],
|
||||
);
|
||||
@ -72,19 +72,19 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
|
||||
it('reverts when trying to mintBatch', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.$_mintBatch(holder, [secondTokenId], [secondTokenAmount], '0x'),
|
||||
this.token.$_mintBatch(holder, [secondTokenId], [secondTokenValue], '0x'),
|
||||
'EnforcedPause',
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts when trying to burn', async function () {
|
||||
await expectRevertCustomError(this.token.$_burn(holder, firstTokenId, firstTokenAmount), 'EnforcedPause', []);
|
||||
await expectRevertCustomError(this.token.$_burn(holder, firstTokenId, firstTokenValue), 'EnforcedPause', []);
|
||||
});
|
||||
|
||||
it('reverts when trying to burnBatch', async function () {
|
||||
await expectRevertCustomError(
|
||||
this.token.$_burnBatch(holder, [firstTokenId], [firstTokenAmount]),
|
||||
this.token.$_burnBatch(holder, [firstTokenId], [firstTokenValue]),
|
||||
'EnforcedPause',
|
||||
[],
|
||||
);
|
||||
@ -98,9 +98,9 @@ contract('ERC1155Pausable', function (accounts) {
|
||||
});
|
||||
|
||||
describe('balanceOf', function () {
|
||||
it('returns the amount of tokens owned by the given address', async function () {
|
||||
it('returns the token value owned by the given address', async function () {
|
||||
const balance = await this.token.balanceOf(holder, firstTokenId);
|
||||
expect(balance).to.be.bignumber.equal(firstTokenAmount);
|
||||
expect(balance).to.be.bignumber.equal(firstTokenValue);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user