1717
1818 // deserialize back
1919 let o2 = T :: from_base32 ( & serialized_32) . unwrap ( ) ;
20- assert_eq ! ( o, o2) ;
20+ assert_eq ! ( o, o2, "Mismatch for {}" , serialized_str ) ;
2121}
2222
2323/// Test base32 encode and decode, and also length hint
@@ -76,7 +76,10 @@ fn bolt11_invoice_features() {
7676 use crate :: Bolt11InvoiceFeatures ;
7777
7878 // Test few values, lengths, and paddings
79- ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 1 , 2 , 3 , 4 , 5 , 42 , 100 , 101 ] ) , "x2ep2q5zqxqsp" ) ;
79+ ser_de_test_len (
80+ Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 1 , 2 , 3 , 4 , 5 , 42 , 100 , 101 ] ) ,
81+ "x2ep2q5zqxqsp" ,
82+ ) ;
8083 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ ] ) , "" ) ;
8184 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 0 ] ) , "" ) ;
8285 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 1 ] ) , "p" ) ;
@@ -88,11 +91,49 @@ fn bolt11_invoice_features() {
8891 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 1 , 2 , 3 ] ) , "xqsp" ) ;
8992 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 1 , 2 , 3 , 4 ] ) , "zqxqsp" ) ;
9093 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 1 , 2 , 3 , 4 , 5 ] ) , "5zqxqsp" ) ;
91- ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 255 , 254 , 253 , 252 , 251 ] ) , "l070mlhl" ) ;
94+ ser_de_test_len (
95+ Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 255 , 254 , 253 , 252 , 251 ] ) ,
96+ "l070mlhl" ,
97+ ) ;
9298 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 100 , 0 ] ) , "ry" ) ;
9399 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 100 , 0 , 0 , 0 ] ) , "ry" ) ;
94100 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 0 , 100 ] ) , "eqq" ) ;
95101 ser_de_test_len ( Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 0 , 0 , 0 , 100 ] ) , "pjqqqqq" ) ;
102+ ser_de_test_len (
103+ Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ] ) ,
104+ "rllllllllllllll" ,
105+ ) ;
106+ ser_de_test_len (
107+ Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 254 ] ) ,
108+ "rl0llllllllllll" ,
109+ ) ;
110+ ser_de_test_len (
111+ Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 127 ] ) ,
112+ "pllllllllllllll" ,
113+ ) ;
114+ ser_de_test_len (
115+ Bolt11InvoiceFeatures :: from_le_bytes ( vec ! [ 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 63 ] ) ,
116+ "llllllllllllll" ,
117+ ) ;
118+
119+ // To test skipping 0's in deserialization, we have to start with deserialization
120+ assert_eq ! (
121+ Bolt11InvoiceFeatures :: from_base32(
122+ & "qqqqqry" . to_string( ) . chars( ) . map( |c| Fe32 :: from_char( c) . unwrap( ) ) . collect:: <Vec <_>>( )
123+ [ ..]
124+ )
125+ . unwrap( )
126+ . le_flags( ) ,
127+ vec![ 100 ]
128+ ) ;
129+ assert_eq ! (
130+ Bolt11InvoiceFeatures :: from_base32(
131+ & "ry" . to_string( ) . chars( ) . map( |c| Fe32 :: from_char( c) . unwrap( ) ) . collect:: <Vec <_>>( ) [ ..]
132+ )
133+ . unwrap( )
134+ . le_flags( ) ,
135+ vec![ 100 ]
136+ ) ;
96137}
97138
98139#[ test]
0 commit comments