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 {
245245#[ cfg( test) ]
246246mod tests {
247247 use super :: * ;
248+
248249 #[ test]
249250 fn test_trimmed_hex ( ) {
250251 assert_eq ! ( trimmed_hex( & hex:: decode( "1234567890" ) . unwrap( ) ) , "1234567890" ) ;
@@ -253,4 +254,35 @@ mod tests {
253254 "49207769736820727573742073757070…6865722d6b696e646564207479706573 (41 bytes)"
254255 ) ;
255256 }
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+ }
256288}
You can’t perform that action at this time.
0 commit comments