Replace error strings with custom errors (#4261)
This commit is contained in:
@ -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(), 'Unpaused', []);
|
||||
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(), 'Paused', []);
|
||||
});
|
||||
|
||||
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(), 'Paused', []);
|
||||
});
|
||||
|
||||
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(), 'Unpaused', []);
|
||||
});
|
||||
|
||||
it('reverts when re-unpausing', async function () {
|
||||
await expectRevert(this.pausable.unpause(), 'Pausable: not paused');
|
||||
await expectRevertCustomError(this.pausable.unpause(), 'Unpaused', []);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
const { expectRevert } = require('@openzeppelin/test-helpers');
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const { expectRevertCustomError } = require('../helpers/customError');
|
||||
|
||||
const ReentrancyMock = artifacts.require('ReentrancyMock');
|
||||
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
|
||||
|
||||
@ -19,7 +20,7 @@ contract('ReentrancyGuard', function () {
|
||||
|
||||
it('does not allow remote callback', async function () {
|
||||
const attacker = await ReentrancyAttack.new();
|
||||
await expectRevert(this.reentrancyMock.countAndCall(attacker.address), 'ReentrancyAttack: failed call');
|
||||
await expectRevert(this.reentrancyMock.countAndCall(attacker.address), 'ReentrancyAttack: failed call', []);
|
||||
});
|
||||
|
||||
it('_reentrancyGuardEntered should be true when guarded', async function () {
|
||||
@ -34,10 +35,10 @@ contract('ReentrancyGuard', function () {
|
||||
// I put them here as documentation, and to monitor any changes
|
||||
// in the side-effects.
|
||||
it('does not allow local recursion', async function () {
|
||||
await expectRevert(this.reentrancyMock.countLocalRecursive(10), 'ReentrancyGuard: reentrant call');
|
||||
await expectRevertCustomError(this.reentrancyMock.countLocalRecursive(10), 'ReentrancyGuardReentrantCall', []);
|
||||
});
|
||||
|
||||
it('does not allow indirect local recursion', async function () {
|
||||
await expectRevert(this.reentrancyMock.countThisRecursive(10), 'ReentrancyMock: failed call');
|
||||
await expectRevert(this.reentrancyMock.countThisRecursive(10), 'ReentrancyMock: failed call', []);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user