@@ -150,7 +150,13 @@ impl Id {
150150 /// Will panic if byte slice does not contains the exact amount of bytes need for the `Id`.
151151 #[ must_use]
152152 pub fn from_bytes ( bytes : & [ u8 ] ) -> Self {
153- assert_eq ! ( bytes. len( ) , PEER_ID_BYTES_LEN ) ;
153+ assert_eq ! (
154+ PEER_ID_BYTES_LEN ,
155+ bytes. len( ) ,
156+ "we are testing the equality of the constant: `PEER_ID_BYTES_LEN` ({}) and the supplied `bytes` length: {}" ,
157+ PEER_ID_BYTES_LEN ,
158+ bytes. len( ) ,
159+ ) ;
154160 let mut ret = Self ( [ 0u8 ; PEER_ID_BYTES_LEN ] ) ;
155161 ret. 0 . clone_from_slice ( bytes) ;
156162 ret
@@ -363,14 +369,14 @@ mod test {
363369 }
364370
365371 #[ test]
366- #[ should_panic]
372+ #[ should_panic = "we are testing the equality of the constant: `PEER_ID_BYTES_LEN` (20) and the supplied `bytes` length: 19" ]
367373 fn should_fail_trying_to_instantiate_from_a_byte_slice_with_less_than_20_bytes ( ) {
368374 let less_than_20_bytes = [ 0 ; 19 ] ;
369375 let _: peer:: Id = peer:: Id :: from_bytes ( & less_than_20_bytes) ;
370376 }
371377
372378 #[ test]
373- #[ should_panic]
379+ #[ should_panic = "we are testing the equality of the constant: `PEER_ID_BYTES_LEN` (20) and the supplied `bytes` length: 21" ]
374380 fn should_fail_trying_to_instantiate_from_a_byte_slice_with_more_than_20_bytes ( ) {
375381 let more_than_20_bytes = [ 0 ; 21 ] ;
376382 let _: peer:: Id = peer:: Id :: from_bytes ( & more_than_20_bytes) ;
@@ -418,13 +424,13 @@ mod test {
418424 }
419425
420426 #[ test]
421- #[ should_panic]
427+ #[ should_panic = "NotEnoughBytes" ]
422428 fn should_fail_trying_to_convert_from_a_byte_vector_with_less_than_20_bytes ( ) {
423429 let _: peer:: Id = peer:: Id :: try_from ( [ 0 ; 19 ] . to_vec ( ) ) . unwrap ( ) ;
424430 }
425431
426432 #[ test]
427- #[ should_panic]
433+ #[ should_panic = "TooManyBytes" ]
428434 fn should_fail_trying_to_convert_from_a_byte_vector_with_more_than_20_bytes ( ) {
429435 let _: peer:: Id = peer:: Id :: try_from ( [ 0 ; 21 ] . to_vec ( ) ) . unwrap ( ) ;
430436 }
0 commit comments