@@ -103,14 +103,34 @@ describe('LowLevelCall', function () {
103
103
} ) ;
104
104
105
105
it ( 'calls the requested function and returns false if the subcall reverts' , async function ( ) {
106
- const tx = this . mock . $callReturn64Bytes (
107
- this . target ,
108
- this . target . interface . encodeFunctionData ( 'mockFunctionRevertsNoReason' ) ,
109
- ) ;
110
- await expect ( tx )
106
+ await expect (
107
+ this . mock . $callReturn64Bytes (
108
+ this . target ,
109
+ this . target . interface . encodeFunctionData ( 'mockFunctionRevertsNoReason' ) ,
110
+ ) ,
111
+ )
111
112
. to . emit ( this . mock , 'return$callReturn64Bytes_address_bytes' )
112
113
. withArgs ( false , ethers . ZeroHash , ethers . ZeroHash ) ;
113
114
} ) ;
115
+
116
+ it ( 'returns the first 64 bytes of the revert reason or custom error if the subcall reverts' , async function ( ) {
117
+ const encoded = ethers . Interface . from ( [ 'error Error(string)' ] ) . encodeErrorResult ( 'Error' , [
118
+ 'CallReceiverMock: reverting' ,
119
+ ] ) ;
120
+
121
+ await expect (
122
+ this . mock . $callReturn64Bytes (
123
+ this . target ,
124
+ this . target . interface . encodeFunctionData ( 'mockFunctionRevertsReason' ) ,
125
+ ) ,
126
+ )
127
+ . to . emit ( this . mock , 'return$callReturn64Bytes_address_bytes' )
128
+ . withArgs (
129
+ false ,
130
+ ethers . hexlify ( ethers . getBytes ( encoded ) . slice ( 0x00 , 0x20 ) ) ,
131
+ ethers . hexlify ( ethers . getBytes ( encoded ) . slice ( 0x20 , 0x40 ) ) ,
132
+ ) ;
133
+ } ) ;
114
134
} ) ;
115
135
} ) ;
116
136
@@ -150,6 +170,23 @@ describe('LowLevelCall', function () {
150
170
) ,
151
171
) . to . eventually . deep . equal ( [ false , ethers . ZeroHash , ethers . ZeroHash ] ) ;
152
172
} ) ;
173
+
174
+ it ( 'returns the first 64 bytes of the revert reason or custom error if the subcall reverts' , async function ( ) {
175
+ const encoded = ethers . Interface . from ( [ 'error Error(string)' ] ) . encodeErrorResult ( 'Error' , [
176
+ 'CallReceiverMock: reverting' ,
177
+ ] ) ;
178
+
179
+ await expect (
180
+ this . mock . $staticcallReturn64Bytes (
181
+ this . target ,
182
+ this . target . interface . encodeFunctionData ( 'mockFunctionRevertsReason' ) ,
183
+ ) ,
184
+ ) . to . eventually . deep . equal ( [
185
+ false ,
186
+ ethers . hexlify ( ethers . getBytes ( encoded ) . slice ( 0x00 , 0x20 ) ) ,
187
+ ethers . hexlify ( ethers . getBytes ( encoded ) . slice ( 0x20 , 0x40 ) ) ,
188
+ ] ) ;
189
+ } ) ;
153
190
} ) ;
154
191
} ) ;
155
192
0 commit comments