Replace error strings with custom errors (#4261)

This commit is contained in:
Francisco Giordano
2023-06-06 01:08:31 -03:00
parent 253bfa68c2
commit 99a4cfca17
133 changed files with 3157 additions and 1204 deletions

View File

@ -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', []);
});
});