File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,7 @@ fn trimmed_hex(s: &[u8]) -> String {
245
245
#[ cfg( test) ]
246
246
mod tests {
247
247
use super :: * ;
248
+
248
249
#[ test]
249
250
fn test_trimmed_hex ( ) {
250
251
assert_eq ! ( trimmed_hex( & hex:: decode( "1234567890" ) . unwrap( ) ) , "1234567890" ) ;
@@ -253,4 +254,35 @@ mod tests {
253
254
"49207769736820727573742073757070…6865722d6b696e646564207479706573 (41 bytes)"
254
255
) ;
255
256
}
257
+
258
+ // https://github.com/foundry-rs/foundry/issues/10162
259
+ #[ test]
260
+ fn partial_decode ( ) {
261
+ /*
262
+ error ValidationFailed(bytes);
263
+ error InvalidNonce();
264
+ */
265
+ let mut decoder = RevertDecoder :: default ( ) ;
266
+ decoder. push_error ( "ValidationFailed(bytes)" . parse ( ) . unwrap ( ) ) ;
267
+
268
+ /*
269
+ abi.encodeWithSelector(ValidationFailed.selector, InvalidNonce.selector)
270
+ */
271
+ let data = & hex ! (
272
+ "0xe17594de"
273
+ "756688fe00000000000000000000000000000000000000000000000000000000"
274
+ ) ;
275
+ assert_eq ! ( decoder. decode( data, None ) , "ValidationFailed(0x)" ) ;
276
+
277
+ /*
278
+ abi.encodeWithSelector(ValidationFailed.selector, abi.encodeWithSelector(InvalidNonce.selector))
279
+ */
280
+ let data = & hex ! (
281
+ "0xe17594de"
282
+ "0000000000000000000000000000000000000000000000000000000000000020"
283
+ "0000000000000000000000000000000000000000000000000000000000000004"
284
+ "756688fe00000000000000000000000000000000000000000000000000000000"
285
+ ) ;
286
+ assert_eq ! ( decoder. decode( data, None ) , "ValidationFailed(0x756688fe)" ) ;
287
+ }
256
288
}
You can’t perform that action at this time.
0 commit comments