@@ -17,7 +17,14 @@ describe('AddressUtils', async () => {
17
17
18
18
// the custom errors are not available on the $AddressUtils ABI
19
19
// a placeholder interface is needed in order to expose them to revertedWithCustomError matcher
20
- const placeholder = { interface : AddressUtils__factory . createInterface ( ) } ;
20
+ const placeholder = {
21
+ interface : new ethers . Interface ( [
22
+ 'error TestError()' ,
23
+ 'error AddressUtils__FailedCall()' ,
24
+ 'error AddressUtils__FailedCallWithValue()' ,
25
+ 'error AddressUtils__FailedDelegatecall()' ,
26
+ ] ) ,
27
+ } ;
21
28
22
29
beforeEach ( async ( ) => {
23
30
[ deployer ] = await ethers . getSigners ( ) ;
@@ -209,7 +216,7 @@ describe('AddressUtils', async () => {
209
216
210
217
it ( 'target contract reverts, with provided custom error' , async ( ) => {
211
218
// unrelated custom error, but it must exist on the contract due to limitiations with revertedWithCustomError matcher
212
- const customError = 'AddressUtils__InsufficientBalance ' ;
219
+ const customError = 'TestError ' ;
213
220
const revertReason =
214
221
placeholder . interface . getError ( customError ) ?. selector ! ;
215
222
@@ -223,7 +230,7 @@ describe('AddressUtils', async () => {
223
230
[
224
231
'$functionCall(address,bytes,bytes4)'
225
232
] ( await targetContract . getAddress ( ) , '0x' , revertReason ) ,
226
- ) . to . be . revertedWithCustomError ( instance , customError ) ;
233
+ ) . to . be . revertedWithCustomError ( placeholder , customError ) ;
227
234
} ) ;
228
235
} ) ;
229
236
} ) ;
@@ -449,7 +456,7 @@ describe('AddressUtils', async () => {
449
456
it ( 'target function is not payable and value is included, with provided custom error' , async ( ) => {
450
457
const value = 2n ;
451
458
// unrelated custom error, but it must exist on the contract due to limitiations with revertedWithCustomError matcher
452
- const customError = 'AddressUtils__InsufficientBalance ' ;
459
+ const customError = 'TestError ' ;
453
460
const revertReason =
454
461
placeholder . interface . getError ( customError ) ?. selector ! ;
455
462
@@ -472,7 +479,7 @@ describe('AddressUtils', async () => {
472
479
[
473
480
'$functionCallWithValue(address,bytes,uint256,bytes4)'
474
481
] ( await targetContract . getAddress ( ) , data , value , revertReason ) ,
475
- ) . to . be . revertedWithCustomError ( instance , customError ) ;
482
+ ) . to . be . revertedWithCustomError ( placeholder , customError ) ;
476
483
} ) ;
477
484
478
485
it ( 'target contract reverts, with target contract error message' , async ( ) => {
@@ -500,7 +507,7 @@ describe('AddressUtils', async () => {
500
507
501
508
it ( 'target contract reverts, with provided custom error' , async ( ) => {
502
509
// unrelated custom error, but it must exist on the contract due to limitiations with revertedWithCustomError matcher
503
- const customError = 'AddressUtils__InsufficientBalance ' ;
510
+ const customError = 'TestError ' ;
504
511
const revertReason =
505
512
placeholder . interface . getError ( customError ) ?. selector ! ;
506
513
@@ -514,7 +521,7 @@ describe('AddressUtils', async () => {
514
521
[
515
522
'$functionCallWithValue(address,bytes,uint256,bytes4)'
516
523
] ( await targetContract . getAddress ( ) , '0x' , 0 , revertReason ) ,
517
- ) . to . be . revertedWithCustomError ( instance , customError ) ;
524
+ ) . to . be . revertedWithCustomError ( placeholder , customError ) ;
518
525
} ) ;
519
526
} ) ;
520
527
} ) ;
@@ -661,7 +668,7 @@ describe('AddressUtils', async () => {
661
668
662
669
it ( 'target contract reverts, with provided custom error' , async ( ) => {
663
670
// unrelated custom error, but it must exist on the contract due to limitiations with revertedWithCustomError matcher
664
- const customError = 'AddressUtils__InsufficientBalance ' ;
671
+ const customError = 'TestError ' ;
665
672
const revertReason =
666
673
placeholder . interface . getError ( customError ) ?. selector ! ;
667
674
@@ -675,10 +682,7 @@ describe('AddressUtils', async () => {
675
682
[
676
683
'$functionDelegateCall(address,bytes,bytes4)'
677
684
] ( await targetContract . getAddress ( ) , '0x' , revertReason ) ,
678
- ) . to . be . revertedWithCustomError (
679
- placeholder ,
680
- 'AddressUtils__InsufficientBalance' ,
681
- ) ;
685
+ ) . to . be . revertedWithCustomError ( placeholder , customError ) ;
682
686
} ) ;
683
687
} ) ;
684
688
} ) ;
0 commit comments