File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -124,11 +124,28 @@ pub fn maybe_decode_revert(
124
124
}
125
125
126
126
fn trimmed_hex ( s : & [ u8 ] ) -> String {
127
- let s = hex:: encode ( s) ;
128
- let n = 32 * 2 ;
127
+ let n = 32 ;
129
128
if s. len ( ) <= n {
130
- s
129
+ hex :: encode ( s )
131
130
} else {
132
- format ! ( "{}…{} ({} bytes)" , & s[ ..n / 2 ] , & s[ s. len( ) - n / 2 ..] , s. len( ) )
131
+ format ! (
132
+ "{}…{} ({} bytes)" ,
133
+ & hex:: encode( & s[ ..n / 2 ] ) ,
134
+ & hex:: encode( & s[ s. len( ) - n / 2 ..] ) ,
135
+ s. len( )
136
+ )
137
+ }
138
+ }
139
+
140
+ #[ cfg( test) ]
141
+ mod tests {
142
+ use super :: * ;
143
+ #[ test]
144
+ fn test_trimmed_hex ( ) {
145
+ assert_eq ! ( trimmed_hex( & hex:: decode( "1234567890" ) . unwrap( ) ) , "1234567890" ) ;
146
+ assert_eq ! (
147
+ trimmed_hex( & hex:: decode( "492077697368207275737420737570706F72746564206869676865722D6B696E646564207479706573" ) . unwrap( ) ) ,
148
+ "49207769736820727573742073757070…6865722d6b696e646564207479706573 (41 bytes)"
149
+ ) ;
133
150
}
134
151
}
You can’t perform that action at this time.
0 commit comments