@@ -8,7 +8,7 @@ use std::str::FromStr;
88fn do_test ( data : & [ u8 ] ) {
99 let s = String :: from_utf8_lossy ( data) ;
1010 if let Ok ( desc) = Descriptor :: < DummyKey > :: from_str ( & s) {
11- let output = format ! ( "{:?}" , desc) ;
11+ let output = desc. to_string ( ) ;
1212
1313 let multi_wrap_pk_re = Regex :: new ( "([a-z]+)c:pk_k\\ (" ) . unwrap ( ) ;
1414 let multi_wrap_pkh_re = Regex :: new ( "([a-z]+)c:pk_h\\ (" ) . unwrap ( ) ;
@@ -19,7 +19,17 @@ fn do_test(data: &[u8]) {
1919 . replace ( "c:pk_k(" , "pk(" )
2020 . replace ( "c:pk_h(" , "pkh(" ) ;
2121
22- assert_eq ! ( normalize_aliases. to_lowercase( ) , output. to_lowercase( ) ) ;
22+ let mut checksum_split = output. split ( '#' ) ;
23+ let pre_checksum = checksum_split. next ( ) . unwrap ( ) ;
24+ assert ! ( checksum_split. next( ) . is_some( ) ) ;
25+ assert ! ( checksum_split. next( ) . is_none( ) ) ;
26+
27+ if normalize_aliases. len ( ) == output. len ( ) {
28+ let len = pre_checksum. len ( ) ;
29+ assert_eq ! ( normalize_aliases[ ..len] . to_lowercase( ) , pre_checksum. to_lowercase( ) ) ;
30+ } else {
31+ assert_eq ! ( normalize_aliases. to_lowercase( ) , pre_checksum. to_lowercase( ) ) ;
32+ }
2333 }
2434}
2535
@@ -43,3 +53,13 @@ fn main() {
4353 } ) ;
4454 }
4555}
56+
57+ #[ cfg( test) ]
58+ mod tests {
59+ use super :: * ;
60+ #[ test]
61+ fn test ( ) {
62+ do_test ( b"pkh()" ) ;
63+ }
64+ }
65+
0 commit comments