Replace revert strings with custom errors (#4261)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
Ernesto García
2023-06-12 17:41:52 -06:00
committed by GitHub
parent 08fd777f6d
commit b425a72240
138 changed files with 3220 additions and 1287 deletions

View File

@ -1,7 +1,8 @@
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { expectRevertCustomError } = require('../helpers/customError');
const PausableMock = artifacts.require('PausableMock');
contract('Pausable', function (accounts) {
@ -24,7 +25,7 @@ contract('Pausable', function (accounts) {
});
it('cannot take drastic measure in non-pause', async function () {
await expectRevert(this.pausable.drasticMeasure(), 'Pausable: not paused');
await expectRevertCustomError(this.pausable.drasticMeasure(), 'ExpectedPause', []);
expect(await this.pausable.drasticMeasureTaken()).to.equal(false);
});
@ -38,7 +39,7 @@ contract('Pausable', function (accounts) {
});
it('cannot perform normal process in pause', async function () {
await expectRevert(this.pausable.normalProcess(), 'Pausable: paused');
await expectRevertCustomError(this.pausable.normalProcess(), 'EnforcedPause', []);
});
it('can take a drastic measure in a pause', async function () {
@ -47,7 +48,7 @@ contract('Pausable', function (accounts) {
});
it('reverts when re-pausing', async function () {
await expectRevert(this.pausable.pause(), 'Pausable: paused');
await expectRevertCustomError(this.pausable.pause(), 'EnforcedPause', []);
});
describe('unpausing', function () {
@ -72,11 +73,11 @@ contract('Pausable', function (accounts) {
});
it('should prevent drastic measure', async function () {
await expectRevert(this.pausable.drasticMeasure(), 'Pausable: not paused');
await expectRevertCustomError(this.pausable.drasticMeasure(), 'ExpectedPause', []);
});
it('reverts when re-unpausing', async function () {
await expectRevert(this.pausable.unpause(), 'Pausable: not paused');
await expectRevertCustomError(this.pausable.unpause(), 'ExpectedPause', []);
});
});
});