88// licenses.
99
1010use crate :: utils:: test_logger;
11- use bech32:: { u5 , FromBase32 , ToBase32 } ;
11+ use bech32:: Fe32 ;
1212use bitcoin:: secp256k1:: { Secp256k1 , SecretKey } ;
1313use lightning_invoice:: {
14- Bolt11Invoice , RawBolt11Invoice , RawDataPart , RawHrp , RawTaggedField , TaggedField ,
14+ Base32Iterable , Bolt11Invoice , FromBase32 , RawBolt11Invoice , RawDataPart , RawHrp ,
15+ RawTaggedField , TaggedField ,
1516} ;
1617use std:: str:: FromStr ;
1718
@@ -25,19 +26,19 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
2526 Err ( _) => return ,
2627 } ;
2728 let bech32 =
28- data. iter ( ) . skip ( hrp_len) . map ( |x| u5 :: try_from_u8 ( x % 32 ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ;
29+ data. iter ( ) . skip ( hrp_len) . map ( |x| Fe32 :: try_from ( x % 32 ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ;
2930 let invoice_data = match RawDataPart :: from_base32 ( & bech32) {
3031 Ok ( invoice) => invoice,
3132 Err ( _) => return ,
3233 } ;
3334
35+ let invoice_data_base32 = invoice_data. fe_iter ( ) . collect :: < Vec < _ > > ( ) ;
3436 // Our data encoding is not worse than the input
35- assert ! ( invoice_data . to_base32 ( ) . len( ) <= bech32. len( ) ) ;
37+ assert ! ( invoice_data_base32 . len( ) <= bech32. len( ) ) ;
3638
3739 // Our data serialization is loss-less
3840 assert_eq ! (
39- RawDataPart :: from_base32( & invoice_data. to_base32( ) )
40- . expect( "faild parsing out own encoding" ) ,
41+ RawDataPart :: from_base32( & invoice_data_base32) . expect( "faild parsing out own encoding" ) ,
4142 invoice_data
4243 ) ;
4344
0 commit comments